Package org.nuxeo.ecm.core.storage.dbs
Class DBSCachingConnection
java.lang.Object
org.nuxeo.ecm.core.storage.dbs.DBSCachingConnection
- All Implemented Interfaces:
AutoCloseable,LockManager,DBSConnection
The DBS Cache layer used to cache some method call of real repository
- Since:
- 11.1 (introduced in 8.10 as DBSCachingRepository)
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.nuxeo.ecm.core.storage.dbs.DBSConnection
DBSConnection.DBSQueryOperator -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDBSCachingConnection(DBSConnection connection, DBSCachingRepository repository) -
Method Summary
Modifier and TypeMethodDescriptionvoidbegin()Starts a new transaction.voidclose()Closes this connection.voidcommit()Commits the current transaction.voidcreateState(State state) Creates a document.voidcreateStates(List<State> states) Creates documents.voiddeleteStates(Set<String> ids) Deletes a set of document.Generates a new id for a document.getDescendants(String id, Set<String> keys) Returns a stream of descendants from a given root document, in no particular order.getDescendants(String id, Set<String> keys, int limit) Returns a stream of descendants from a given root document, in no particular order.Gets the lock on a document.Gets the root id.booleanChecks if a document has a child with the given nameprotected voidqueryAndFetch(DBSExpressionEvaluator evaluator, OrderByClause orderByClause, boolean distinctDocuments, int limit, int offset, int countUpTo) Queries the repository for documents matching a NXQL query, and returns a projection of the documents.Queries the repository for documents having key1 = value1 and key2 = value2.queryKeyValue(String key, Object value, Set<String> ignored) Queries the repository for documents having key = value.booleanqueryKeyValuePresence(String key, String value, Set<String> ignored) Queries the repository to check if there are documents having key = value.queryKeyValueWithOperator(String key1, Object value1, String key2, DBSConnection.DBSQueryOperator operator, Object value2, Set<String> ignored) Queries the repository for documents having key1 = value1 and key2 ${operator} value2.readChildState(String parentId, String name, Set<String> ignored) Reads the state of a child document.readPartialState(String id, Collection<String> keys) Reads the partial state of a document.Reads the state of a document.readStates(List<String> ids) Reads the states of several documents.removeLock(String id, String owner) Removes the lock from a document.voidrollback()Rolls back the current transaction.Get the next batch of results containing id of documents, thescrollIdis part of the previousScrollResultresponse.scroll(DBSExpressionEvaluator evaluator, int batchSize, int keepAliveSeconds) Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within thekeepAliveSecondsdelay.protected voidSets a lock on a document.voidupdateState(String id, State.StateDiff diff, DBSTransactionState.ConditionalUpdates conditionalUpdates) Updates a document.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.nuxeo.ecm.core.api.lock.LockManager
clearLockManagerCaches, closeLockManager
-
Field Details
-
connection
-
-
Constructor Details
-
DBSCachingConnection
-
-
Method Details
-
close
public void close()Description copied from interface:DBSConnectionCloses this connection.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDBSConnection
-
begin
public void begin()Description copied from interface:DBSConnectionStarts a new transaction.- Specified by:
beginin interfaceDBSConnection- See Also:
-
commit
public void commit()Description copied from interface:DBSConnectionCommits the current transaction.- Specified by:
commitin interfaceDBSConnection- See Also:
-
rollback
public void rollback()Description copied from interface:DBSConnectionRolls back the current transaction.- Specified by:
rollbackin interfaceDBSConnection- See Also:
-
readState
Description copied from interface:DBSConnectionReads the state of a document.- Specified by:
readStatein interfaceDBSConnection- Parameters:
id- the document id- Returns:
- the document state, or
nullif not found
-
readPartialState
Description copied from interface:DBSConnectionReads the partial state of a document.- Specified by:
readPartialStatein interfaceDBSConnection- Parameters:
id- the document idkeys- the keys to read- Returns:
- the document partial state, or
nullif not found
-
readStates
Description copied from interface:DBSConnectionReads the states of several documents.The returned states may be in a different order than the ids.
- Specified by:
readStatesin interfaceDBSConnection- Parameters:
ids- the document ids- Returns:
- the document states, an element by be
nullif not found
-
createState
Description copied from interface:DBSConnectionCreates a document.- Specified by:
createStatein interfaceDBSConnection- Parameters:
state- the document state
-
createStates
Description copied from interface:DBSConnectionCreates documents.- Specified by:
createStatesin interfaceDBSConnection- Parameters:
states- the document states
-
updateState
public void updateState(String id, State.StateDiff diff, DBSTransactionState.ConditionalUpdates conditionalUpdates) Description copied from interface:DBSConnectionUpdates a document.- Specified by:
updateStatein interfaceDBSConnection- Parameters:
id- the document iddiff- the diff to applyconditionalUpdates- the conditional updates, ornull
-
deleteStates
Description copied from interface:DBSConnectionDeletes a set of document.- Specified by:
deleteStatesin interfaceDBSConnection- Parameters:
ids- the document ids
-
readChildState
Description copied from interface:DBSConnectionReads the state of a child document.- Specified by:
readChildStatein interfaceDBSConnection- Parameters:
parentId- the parent document idname- the name of the childignored- a set of document ids that should not be considered- Returns:
- the state of the child document, or
nullif not found
-
sendInvalidationsToOthers
protected void sendInvalidationsToOthers() -
processReceivedInvalidations
protected void processReceivedInvalidations() -
getRootId
Description copied from interface:DBSConnectionGets the root id.- Specified by:
getRootIdin interfaceDBSConnection- Returns:
- the root id.
-
generateNewId
Description copied from interface:DBSConnectionGenerates a new id for a document.- Specified by:
generateNewIdin interfaceDBSConnection- Returns:
- the new id
-
hasChild
Description copied from interface:DBSConnectionChecks if a document has a child with the given name- Specified by:
hasChildin interfaceDBSConnection- Parameters:
parentId- the parent document idname- the name of the childignored- a set of document ids that should not be considered- Returns:
trueif the child exists,falseif not
-
queryKeyValue
Description copied from interface:DBSConnectionQueries the repository for documents having key = value.- Specified by:
queryKeyValuein interfaceDBSConnection- Parameters:
key- the keyvalue- the valueignored- a set of document ids that should not be considered- Returns:
- the document states matching the query
-
queryKeyValue
public List<State> queryKeyValue(String key1, Object value1, String key2, Object value2, Set<String> ignored) Description copied from interface:DBSConnectionQueries the repository for documents having key1 = value1 and key2 = value2.- Specified by:
queryKeyValuein interfaceDBSConnection- Parameters:
key1- the first keyvalue1- the first valuekey2- the second keyvalue2- the second valueignored- a set of document ids that should not be considered- Returns:
- the document states matching the query
-
getDescendants
Description copied from interface:DBSConnectionReturns a stream of descendants from a given root document, in no particular order. This does not include information about the root document itself.THE STREAM MUST BE CLOSED WHEN DONE to release resources.
- Specified by:
getDescendantsin interfaceDBSConnection- Parameters:
id- the root document idkeys- what to collect about the descendants in addition to their ids- Returns:
- a stream of
States; THE STREAM MUST BE CLOSED WHEN DONE
-
getDescendants
Description copied from interface:DBSConnectionReturns a stream of descendants from a given root document, in no particular order. This does not include information about the root document itself.THE STREAM MUST BE CLOSED WHEN DONE to release resources.
- Specified by:
getDescendantsin interfaceDBSConnection- Parameters:
id- the root document idkeys- what to collect about the descendants in addition to their idslimit- the maximum number of descendants to return- Returns:
- a stream of
States; THE STREAM MUST BE CLOSED WHEN DONE
-
queryKeyValuePresence
Description copied from interface:DBSConnectionQueries the repository to check if there are documents having key = value.- Specified by:
queryKeyValuePresencein interfaceDBSConnection- Parameters:
key- the keyvalue- the valueignored- a set of document ids that should not be considered- Returns:
trueif the query matches at least one document,falseif the query matches nothing
-
queryAndFetch
public PartialList<Map<String,Serializable>> queryAndFetch(DBSExpressionEvaluator evaluator, OrderByClause orderByClause, boolean distinctDocuments, int limit, int offset, int countUpTo) Description copied from interface:DBSConnectionQueries the repository for documents matching a NXQL query, and returns a projection of the documents.- Specified by:
queryAndFetchin interfaceDBSConnection- Parameters:
evaluator- the map-based evaluator for the queryorderByClause- an ORDER BY clausedistinctDocuments-trueif the projection should return a maximum of one row per documentlimit- the limit on the number of documents to returnoffset- the offset in the list of documents to returncountUpTo- if-1, count the total size without offset/limit.
If0, don't count the total size, set it to-1.
Ifn, count the total number if there are less than n documents otherwise set the total size to-2.- Returns:
- a partial list of maps containing the NXQL projections requested, and the total size according to countUpTo
-
scroll
public ScrollResult<String> scroll(DBSExpressionEvaluator evaluator, int batchSize, int keepAliveSeconds) Description copied from interface:DBSConnectionExecutes the given query and returns the first batch of results containing id of documents, next batch must be requested within thekeepAliveSecondsdelay.- Specified by:
scrollin interfaceDBSConnection
-
scroll
Description copied from interface:DBSConnectionGet the next batch of results containing id of documents, thescrollIdis part of the previousScrollResultresponse.- Specified by:
scrollin interfaceDBSConnection
-
getLock
Description copied from interface:LockManagerGets the lock on a document.If the document does not exist,
nullis returned.- Specified by:
getLockin interfaceLockManager- Parameters:
id- the document id- Returns:
- the existing lock, or
nullwhen there is no lock
-
setLock
Description copied from interface:LockManagerSets 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:
setLockin interfaceLockManager- Parameters:
id- the document idlock- the lock to set- Returns:
nullif locking succeeded, or the existing lock if locking failed
-
removeLock
Description copied from interface:LockManagerRemoves the lock from a document.The previous lock is returned.
If
ownerisnullthen the lock is unconditionally removed.If
owneris notnull, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will returntrueforLock.getFailed().- Specified by:
removeLockin interfaceLockManager- Parameters:
id- the document idowner- the owner to check, ornullfor no check- Returns:
- the previous lock (may be
null), with a failed flag if locking failed
-
queryKeyValueWithOperator
public List<State> queryKeyValueWithOperator(String key1, Object value1, String key2, DBSConnection.DBSQueryOperator operator, Object value2, Set<String> ignored) Description copied from interface:DBSConnectionQueries the repository for documents having key1 = value1 and key2 ${operator} value2.- Specified by:
queryKeyValueWithOperatorin interfaceDBSConnection- Parameters:
key1- the first keyvalue1- the first valuekey2- the second keyoperator- the operator to apply between key2 and value2value2- the second valueignored- a set of document ids that should not be considered- Returns:
- the document states matching the query
-