public class SoftRefCachingRowMapper extends Object implements RowMapper
RowMapper.CopyResult, RowMapper.IdWithTypes, RowMapper.NodeInfo, RowMapper.RowBatch, RowMapper.RowUpdate
Modifier and Type | Field and Description |
---|---|
protected com.codahale.metrics.Timer |
cacheGetTimer |
protected com.codahale.metrics.Counter |
cacheHitCount |
InvalidationsQueue |
cacheQueue
The queue of cache invalidations received from other session, to process at pre-transaction time.
|
protected com.codahale.metrics.MetricRegistry |
registry
Cache statistics
|
protected com.codahale.metrics.Timer |
sorGetTimer |
protected com.codahale.metrics.Counter |
sorRows |
Constructor and Description |
---|
SoftRefCachingRowMapper() |
Modifier and Type | Method and 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)
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 size
|
void |
initialize(String repositoryName,
Model model,
RowMapper rowMapper,
InvalidationsPropagator 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 given
RowId s. |
Serializable[] |
readCollectionRowArray(RowId rowId)
Gets an array for a
CollectionFragment 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.
|
Row |
readSimpleRow(RowId rowId)
Gets a row for a
SimpleFragment from the database, given its table name and id. |
Invalidations |
receiveInvalidations()
Processes and returns the invalidations queued for processing by the cache (if any).
|
List<RowMapper.NodeInfo> |
remove(RowMapper.NodeInfo rootInfo)
Deletes a hierarchy and returns information to generate invalidations.
|
void |
rollback(Xid xid)
Rollback the XA Resource.
|
void |
sendInvalidations(Invalidations 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.
|
public final InvalidationsQueue cacheQueue
protected final com.codahale.metrics.MetricRegistry registry
protected com.codahale.metrics.Counter cacheHitCount
protected com.codahale.metrics.Timer cacheGetTimer
protected com.codahale.metrics.Counter sorRows
protected com.codahale.metrics.Timer sorGetTimer
public SoftRefCachingRowMapper()
public void initialize(String repositoryName, Model model, RowMapper rowMapper, InvalidationsPropagator cachePropagator, Map<String,String> properties)
protected void setMetrics(String repositoryName)
public void close()
public Serializable generateNewId()
RowMapper
generateNewId
in interface RowMapper
protected ACLRow[] sortACLRows(ACLRow[] acls)
protected void cachePutAbsent(RowId rowId)
protected void cachePutAbsentIfNull(RowId rowId, Row row)
protected void cachePutAbsentIfRowId(RowId rowId)
protected void cacheRemove(RowId rowId)
public Invalidations receiveInvalidations()
RowMapper
Called pre-transaction by session start or transactionless save;
receiveInvalidations
in interface RowMapper
null
public void sendInvalidations(Invalidations invalidations)
RowMapper
Called post-transaction by session commit/rollback or transactionless save.
sendInvalidations
in interface RowMapper
invalidations
- the known invalidations to send to others, or null
public void clearCache()
RowMapper
Called after a rollback, or a manual clear through RepositoryStatus MBean.
clearCache
in interface RowMapper
public long getCacheSize()
RowMapper
getCacheSize
in interface RowMapper
public void rollback(Xid xid) throws XAException
RowMapper
This is in the RowMapper
interface because on rollback the cache must be invalidated.
rollback
in interface RowMapper
XAException
public List<? extends RowId> read(Collection<RowId> rowIds, boolean cacheOnly)
RowMapper
public void write(RowMapper.RowBatch batch)
RowMapper
public Row readSimpleRow(RowId rowId)
RowMapper
SimpleFragment
from the database, given its table name and id. If the row doesn't exist,
null
is returned.readSimpleRow
in interface RowMapper
rowId
- the row idnull
public Map<String,String> getBinaryFulltext(RowId rowId)
RowMapper
getBinaryFulltext
in interface RowMapper
rowId
- the row idnull
if unsupportedpublic Serializable[] readCollectionRowArray(RowId rowId)
RowMapper
CollectionFragment
from the database, given its table name and id. If no rows are
found, an empty array is returned.readCollectionRowArray
in interface RowMapper
rowId
- the row idpublic List<Row> readSelectionRows(SelectionType selType, Serializable selId, Serializable filter, Serializable criterion, boolean limitToOne)
RowMapper
readSelectionRows
in interface RowMapper
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 retrievedpublic RowMapper.CopyResult copy(RowMapper.IdWithTypes source, Serializable destParentId, String destName, Row overwriteRow)
RowMapper
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.
copy
in interface RowMapper
source
- the id, primary type and mixin types of the row to copydestParentId
- the new parent id, or null
destName
- the new nameoverwriteRow
- when not null
, the copy is done onto this existing row, and the values are set in
hierarchypublic List<RowMapper.NodeInfo> remove(RowMapper.NodeInfo rootInfo)
RowMapper
Copyright © 2016 Nuxeo SA. All rights reserved.