Package org.nuxeo.ecm.core.storage.dbs
Class DBSCachingRepository
- java.lang.Object
-
- org.nuxeo.ecm.core.storage.dbs.DBSCachingRepository
-
- All Implemented Interfaces:
LockManager
,Repository
,DBSRepository
public class DBSCachingRepository extends Object implements DBSRepository
The DBS Cache layer used to cache some method call of real repository- Since:
- 8.10
-
-
Field Summary
Fields Modifier and Type Field Description protected com.google.common.cache.Cache<String,State>
cache
protected com.google.common.cache.Cache<String,String>
childCache
protected DBSClusterInvalidator
clusterInvalidator
protected DBSRepositoryDescriptor
descriptor
protected DBSInvalidationsPropagator
invalidationsPropagator
protected static String
METRIC_CACHE_NAME
protected static String
METRIC_CHILD_CACHE_NAME
protected io.dropwizard.metrics5.MetricRegistry
registry
-
Constructor Summary
Constructors Constructor Description DBSCachingRepository(DBSRepository repository, DBSRepositoryDescriptor descriptor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearLockManagerCaches()
Clears any cache held by the lock manager.void
closeLockManager()
Closes the lock manager and releases resources.protected DBSClusterInvalidator
createClusterInvalidator(DBSRepositoryDescriptor descriptor)
BlobManager
getBlobManager()
Gets the blob manager.protected com.google.common.cache.Cache<String,State>
getCache()
protected com.google.common.cache.Cache<String,String>
getChildCache()
protected DBSClusterInvalidator
getClusterInvalidator()
DBSConnection
getConnection()
Gets a new connection to this repository.FulltextConfiguration
getFulltextConfiguration()
Gets the fulltext configuration for this repository.protected DBSInvalidationsPropagator
getInvalidationsPropagator()
Lock
getLock(String id)
Gets the lock on a document.LockManager
getLockManager()
Gets the lock manager for this repository.String
getName()
Session
getSession()
protected DBSClusterInvalidator
initClusterInvalidator(DBSRepositoryDescriptor descriptor)
protected DBSInvalidationsPropagator
initInvalidationsPropagator()
Invalidations need to be propagated between connection caches only if there is such a cache, which is the case only if transactions are used.boolean
isChangeTokenEnabled()
Checks if database-managed document change tokens are enabled.boolean
isFulltextDisabled()
Checks if fulltext indexing (and search) is disabled.boolean
isFulltextSearchDisabled()
Checks if fulltext search is disabled.boolean
isFulltextStoredInBlob()
Checks if fulltext is stored in a blob.void
markReferencedBinaries()
Marks the binaries in use by passing them to the binary manager(s)'s GC mark() method.protected com.google.common.cache.Cache<String,State>
newCache(boolean metrics)
protected <T> com.google.common.cache.Cache<String,T>
newCache(DBSRepositoryDescriptor descriptor)
protected com.google.common.cache.Cache<String,String>
newChildCache(boolean metrics)
protected void
removeCacheMetrics()
Lock
removeLock(String id, String owner)
Removes the lock from a document.Lock
setLock(String id, Lock lock)
Sets a lock on a document.void
shutdown()
boolean
supportsTransactions()
Checks whether this repository supports transactions.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.model.Repository
getActiveSessionsCount
-
-
-
-
Field Detail
-
METRIC_CACHE_NAME
protected static final String METRIC_CACHE_NAME
- See Also:
- Constant Field Values
-
METRIC_CHILD_CACHE_NAME
protected static final String METRIC_CHILD_CACHE_NAME
- See Also:
- Constant Field Values
-
childCache
protected final com.google.common.cache.Cache<String,String> childCache
-
descriptor
protected final DBSRepositoryDescriptor descriptor
-
invalidationsPropagator
protected final DBSInvalidationsPropagator invalidationsPropagator
-
clusterInvalidator
protected final DBSClusterInvalidator clusterInvalidator
-
registry
protected final io.dropwizard.metrics5.MetricRegistry registry
-
-
Constructor Detail
-
DBSCachingRepository
public DBSCachingRepository(DBSRepository repository, DBSRepositoryDescriptor descriptor)
-
-
Method Detail
-
getChildCache
protected com.google.common.cache.Cache<String,String> getChildCache()
-
getInvalidationsPropagator
protected DBSInvalidationsPropagator getInvalidationsPropagator()
-
getClusterInvalidator
protected DBSClusterInvalidator getClusterInvalidator()
-
newChildCache
protected com.google.common.cache.Cache<String,String> newChildCache(boolean metrics)
-
removeCacheMetrics
protected void removeCacheMetrics()
-
newCache
protected <T> com.google.common.cache.Cache<String,T> newCache(DBSRepositoryDescriptor descriptor)
-
initInvalidationsPropagator
protected DBSInvalidationsPropagator initInvalidationsPropagator()
Invalidations need to be propagated between connection caches only if there is such a cache, which is the case only if transactions are used.
-
initClusterInvalidator
protected DBSClusterInvalidator initClusterInvalidator(DBSRepositoryDescriptor descriptor)
-
createClusterInvalidator
protected DBSClusterInvalidator createClusterInvalidator(DBSRepositoryDescriptor descriptor)
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceRepository
-
getConnection
public DBSConnection getConnection()
Description copied from interface:DBSRepository
Gets a new connection to this repository.- Specified by:
getConnection
in interfaceDBSRepository
- Returns:
- a new connection
-
supportsTransactions
public boolean supportsTransactions()
Description copied from interface:DBSRepository
Checks whether this repository supports transactions.- Specified by:
supportsTransactions
in interfaceDBSRepository
- Returns:
true
if the repository supports transactions- See Also:
DBSConnection.begin()
,DBSConnection.commit()
,DBSConnection.rollback()
-
getBlobManager
public BlobManager getBlobManager()
Description copied from interface:DBSRepository
Gets the blob manager.- Specified by:
getBlobManager
in interfaceDBSRepository
- Returns:
- the blob manager.
-
getFulltextConfiguration
public FulltextConfiguration getFulltextConfiguration()
Description copied from interface:Repository
Gets the fulltext configuration for this repository.- Specified by:
getFulltextConfiguration
in interfaceRepository
-
isFulltextDisabled
public boolean isFulltextDisabled()
Description copied from interface:DBSRepository
Checks if fulltext indexing (and search) is disabled.- Specified by:
isFulltextDisabled
in interfaceDBSRepository
- Returns:
true
if fulltext indexing is disabled,false
if it is enabled
-
isFulltextStoredInBlob
public boolean isFulltextStoredInBlob()
Description copied from interface:DBSRepository
Checks if fulltext is stored in a blob.- Specified by:
isFulltextStoredInBlob
in interfaceDBSRepository
- Returns:
true
if fulltext is stored in a blob,false
if it is stored as a regular string
-
isFulltextSearchDisabled
public boolean isFulltextSearchDisabled()
Description copied from interface:DBSRepository
Checks if fulltext search is disabled.- Specified by:
isFulltextSearchDisabled
in interfaceDBSRepository
- Returns:
true
if fulltext search is disabled,false
if it is enabled
-
isChangeTokenEnabled
public boolean isChangeTokenEnabled()
Description copied from interface:DBSRepository
Checks if database-managed document change tokens are enabled.- Specified by:
isChangeTokenEnabled
in interfaceDBSRepository
- Returns:
true
if the database maintains document change tokens
-
getLockManager
public LockManager getLockManager()
Description copied from interface:DBSRepository
Gets the lock manager for this repository.- Specified by:
getLockManager
in interfaceDBSRepository
- Returns:
- the lock manager
-
getLock
public Lock getLock(String id)
Description copied from interface:LockManager
Gets the lock on a document.If the document does not exist,
null
is returned.- Specified by:
getLock
in interfaceLockManager
- Parameters:
id
- the document id- Returns:
- the existing lock, or
null
when there is no lock
-
setLock
public Lock setLock(String id, Lock lock)
Description copied from interface:LockManager
Sets a lock on a document.If the document is already locked, returns its existing lock status (there is no re-locking,
LockManager.removeLock(java.lang.String, java.lang.String)
must be called first).- Specified by:
setLock
in interfaceLockManager
- Parameters:
id
- the document idlock
- the lock to set- Returns:
null
if locking succeeded, or the existing lock if locking failed
-
removeLock
public Lock removeLock(String id, String owner)
Description copied from interface:LockManager
Removes the lock from a document.The previous lock is returned.
If
owner
isnull
then the lock is unconditionally removed.If
owner
is notnull
, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will returntrue
forLock.getFailed()
.- Specified by:
removeLock
in interfaceLockManager
- Parameters:
id
- the document idowner
- the owner to check, ornull
for no check- Returns:
- the previous lock (may be
null
), with a failed flag if locking failed
-
closeLockManager
public void closeLockManager()
Description copied from interface:LockManager
Closes the lock manager and releases resources.- Specified by:
closeLockManager
in interfaceLockManager
-
clearLockManagerCaches
public void clearLockManagerCaches()
Description copied from interface:LockManager
Clears any cache held by the lock manager.- Specified by:
clearLockManagerCaches
in interfaceLockManager
-
getName
public String getName()
- Specified by:
getName
in interfaceRepository
-
getSession
public Session getSession()
- Specified by:
getSession
in interfaceRepository
-
markReferencedBinaries
public void markReferencedBinaries()
Description copied from interface:Repository
Marks the binaries in use by passing them to the binary manager(s)'s GC mark() method.- Specified by:
markReferencedBinaries
in interfaceRepository
-
-