Package org.nuxeo.ecm.core.storage.sql
Class SoftRefCachingRowMapper
- java.lang.Object
-
- org.nuxeo.ecm.core.storage.sql.SoftRefCachingRowMapper
-
- All Implemented Interfaces:
RowMapper
- Direct Known Subclasses:
SoftRefCachingMapper
public class SoftRefCachingRowMapper extends Object implements RowMapper
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.storage.sql.RowMapper
RowMapper.CopyResult, RowMapper.IdWithTypes, RowMapper.NodeInfo, RowMapper.RowBatch, RowMapper.RowUpdate
-
-
Field Summary
Fields Modifier and Type Field Description protected io.dropwizard.metrics5.Timer
cacheGetTimer
protected io.dropwizard.metrics5.Counter
cacheHitCount
VCSInvalidationsQueue
cacheQueue
The queue of cache invalidations received from other session, to process at pre-transaction time.protected io.dropwizard.metrics5.MetricRegistry
registry
Cache statisticsprotected io.dropwizard.metrics5.Timer
sorGetTimer
protected io.dropwizard.metrics5.Counter
sorRows
-
Constructor Summary
Constructors Constructor Description SoftRefCachingRowMapper()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Row
cacheGet(RowId rowId)
protected void
cachePut(Row row)
protected void
cachePutAbsent(RowId rowId)
protected void
cachePutAbsentIfNull(RowId rowId, Row row)
protected void
cachePutAbsentIfRowId(RowId rowId)
protected void
cacheRemove(RowId rowId)
void
clearCache()
Clears the mapper's cache (if any)void
close()
RowMapper.CopyResult
copy(RowMapper.IdWithTypes source, Serializable destParentId, String destName, Row overwriteRow, boolean excludeSpecialChildren, boolean excludeACL)
Copies the hierarchy starting from a given row to a new parent with a new name.Serializable
generateNewId()
Computes a new unique id.Map<String,String>
getBinaryFulltext(RowId rowId)
Gets the fulltext extracted from the binary fields.long
getCacheSize()
Evaluate the cached elements sizeList<RowMapper.NodeInfo>
getDescendantsInfo(Serializable rootId)
Gets descendants infos from a given root node.void
initialize(String repositoryName, Model model, RowMapper rowMapper, VCSInvalidationsPropagator cachePropagator, Map<String,String> properties)
protected static boolean
isAbsent(Row row)
List<? extends RowId>
read(Collection<RowId> rowIds, boolean cacheOnly)
Reads a set of rows for the givenRowId
s.Serializable[]
readCollectionRowArray(RowId rowId)
Gets an array for aCollectionFragment
from the database, given its table name and id.List<Row>
readSelectionRows(SelectionType selType, Serializable selId, Serializable filter, Serializable criterion, boolean limitToOne)
Reads the rows corresponding to a selection.Set<Serializable>
readSelectionsIds(SelectionType selType, List<Serializable> values)
Gets all the selection ids for a given list of values.Row
readSimpleRow(RowId rowId)
Gets a row for aSimpleFragment
from the database, given its table name and id.VCSInvalidations
receiveInvalidations()
Processes and returns the invalidations queued for processing by the cache (if any).void
remove(Serializable rootId, List<RowMapper.NodeInfo> nodeInfos)
Deletes a hierarchy.void
rollback()
Rollback the transaction.void
sendInvalidations(VCSInvalidations invalidations)
Post-transaction invalidations notification.protected void
setMetrics(String repositoryName)
protected ACLRow[]
sortACLRows(ACLRow[] acls)
void
write(RowMapper.RowBatch batch)
Writes a set of rows.
-
-
-
Field Detail
-
cacheQueue
public final VCSInvalidationsQueue cacheQueue
The queue of cache invalidations received from other session, to process at pre-transaction time.
-
registry
protected final io.dropwizard.metrics5.MetricRegistry registry
Cache statistics- Since:
- 5.7
-
cacheHitCount
protected io.dropwizard.metrics5.Counter cacheHitCount
-
cacheGetTimer
protected io.dropwizard.metrics5.Timer cacheGetTimer
-
sorRows
protected io.dropwizard.metrics5.Counter sorRows
-
sorGetTimer
protected io.dropwizard.metrics5.Timer sorGetTimer
-
-
Method Detail
-
initialize
public void initialize(String repositoryName, Model model, RowMapper rowMapper, VCSInvalidationsPropagator cachePropagator, Map<String,String> properties)
-
setMetrics
protected void setMetrics(String repositoryName)
-
close
public void close()
-
generateNewId
public Serializable generateNewId()
Description copied from interface:RowMapper
Computes a new unique id.- Specified by:
generateNewId
in interfaceRowMapper
- Returns:
- a new unique id
-
isAbsent
protected static boolean isAbsent(Row row)
-
cachePut
protected void cachePut(Row row)
-
cachePutAbsent
protected void cachePutAbsent(RowId rowId)
-
cachePutAbsentIfRowId
protected void cachePutAbsentIfRowId(RowId rowId)
-
cacheRemove
protected void cacheRemove(RowId rowId)
-
receiveInvalidations
public VCSInvalidations receiveInvalidations()
Description copied from interface:RowMapper
Processes and returns the invalidations queued for processing by the cache (if any).Called pre-transaction by session start or transactionless save;
- Specified by:
receiveInvalidations
in interfaceRowMapper
- Returns:
- the invalidations, or
null
-
sendInvalidations
public void sendInvalidations(VCSInvalidations invalidations)
Description copied from interface:RowMapper
Post-transaction invalidations notification.Called post-transaction by session commit/rollback or transactionless save.
- Specified by:
sendInvalidations
in interfaceRowMapper
- Parameters:
invalidations
- the known invalidations to send to others, ornull
-
clearCache
public void clearCache()
Description copied from interface:RowMapper
Clears the mapper's cache (if any)Called after a rollback, or a manual clear through RepositoryStatus MBean.
- Specified by:
clearCache
in interfaceRowMapper
-
getCacheSize
public long getCacheSize()
Description copied from interface:RowMapper
Evaluate the cached elements size- Specified by:
getCacheSize
in interfaceRowMapper
-
rollback
public void rollback()
Description copied from interface:RowMapper
Rollback the transaction.This is in the
RowMapper
interface because on rollback the cache must be invalidated.
-
read
public List<? extends RowId> read(Collection<RowId> rowIds, boolean cacheOnly)
Description copied from interface:RowMapper
-
write
public void write(RowMapper.RowBatch batch)
Description copied from interface:RowMapper
Writes a set of rows. This includes creating, updating and deleting rows.
-
readSimpleRow
public Row readSimpleRow(RowId rowId)
Description copied from interface:RowMapper
Gets a row for aSimpleFragment
from the database, given its table name and id. If the row doesn't exist,null
is returned.- Specified by:
readSimpleRow
in interfaceRowMapper
- Parameters:
rowId
- the row id- Returns:
- the row, or
null
-
getBinaryFulltext
public Map<String,String> getBinaryFulltext(RowId rowId)
Description copied from interface:RowMapper
Gets the fulltext extracted from the binary fields.- Specified by:
getBinaryFulltext
in interfaceRowMapper
- Parameters:
rowId
- the row id- Returns:
- the fulltext string representation or
null
if unsupported
-
readCollectionRowArray
public Serializable[] readCollectionRowArray(RowId rowId)
Description copied from interface:RowMapper
Gets an array for aCollectionFragment
from the database, given its table name and id. If no rows are found, an empty array is returned.- Specified by:
readCollectionRowArray
in interfaceRowMapper
- Parameters:
rowId
- the row id- Returns:
- the array
-
readSelectionRows
public List<Row> readSelectionRows(SelectionType selType, Serializable selId, Serializable filter, Serializable criterion, boolean limitToOne)
Description copied from interface:RowMapper
Reads the rows corresponding to a selection.- Specified by:
readSelectionRows
in interfaceRowMapper
- Parameters:
selType
- the selection typeselId
- the selection id (parent id for a hierarchy selection)filter
- the filter value (name for a hierarchy selection)criterion
- an optional additional criterion depending on the selection type (complex prop flag for a hierarchy selection)limitToOne
- whether to stop after one row retrieved- Returns:
- the list of rows
-
readSelectionsIds
public Set<Serializable> readSelectionsIds(SelectionType selType, List<Serializable> values)
Description copied from interface:RowMapper
Gets all the selection ids for a given list of values.- Specified by:
readSelectionsIds
in interfaceRowMapper
-
copy
public RowMapper.CopyResult copy(RowMapper.IdWithTypes source, Serializable destParentId, String destName, Row overwriteRow, boolean excludeSpecialChildren, boolean excludeACL)
Description copied from interface:RowMapper
Copies the hierarchy starting from a given row to a new parent with a new name.If the new parent is
null
, then this is a version creation, which doesn't recurse in regular children.If
overwriteRow
is passed, the copy is done onto this existing node as its root (version restore) instead of creating a new node in the parent.- Specified by:
copy
in interfaceRowMapper
- Parameters:
source
- the id, primary type and mixin types of the row to copydestParentId
- the new parent id, ornull
destName
- the new nameoverwriteRow
- when notnull
, the copy is done onto this existing row, and the values are set in hierarchyexcludeSpecialChildren
- the flag to exclude special children from copyexcludeACL
- the flag to exclude ACL from copy- Returns:
- info about the copy
-
getDescendantsInfo
public List<RowMapper.NodeInfo> getDescendantsInfo(Serializable rootId)
Description copied from interface:RowMapper
Gets descendants infos from a given root node. This does not include information about the root node itself.- Specified by:
getDescendantsInfo
in interfaceRowMapper
- Parameters:
rootId
- the root node id from which to get descendants info- Returns:
- the list of descendant nodes info
-
remove
public void remove(Serializable rootId, List<RowMapper.NodeInfo> nodeInfos)
Description copied from interface:RowMapper
Deletes a hierarchy.
-
-