Class DBSCachingConnection

java.lang.Object
org.nuxeo.ecm.core.storage.dbs.DBSCachingConnection
All Implemented Interfaces:
AutoCloseable, LockManager, DBSConnection

public class DBSCachingConnection extends Object implements DBSConnection
The DBS Cache layer used to cache some method call of real repository
Since:
11.1 (introduced in 8.10 as DBSCachingRepository)
  • Field Details

  • Constructor Details

  • Method Details

    • close

      public void close()
      Description copied from interface: DBSConnection
      Closes this connection.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface DBSConnection
    • begin

      public void begin()
      Description copied from interface: DBSConnection
      Starts a new transaction.
      Specified by:
      begin in interface DBSConnection
      See Also:
    • commit

      public void commit()
      Description copied from interface: DBSConnection
      Commits the current transaction.
      Specified by:
      commit in interface DBSConnection
      See Also:
    • rollback

      public void rollback()
      Description copied from interface: DBSConnection
      Rolls back the current transaction.
      Specified by:
      rollback in interface DBSConnection
      See Also:
    • readState

      public State readState(String id)
      Description copied from interface: DBSConnection
      Reads the state of a document.
      Specified by:
      readState in interface DBSConnection
      Parameters:
      id - the document id
      Returns:
      the document state, or null if not found
    • readPartialState

      public State readPartialState(String id, Collection<String> keys)
      Description copied from interface: DBSConnection
      Reads the partial state of a document.
      Specified by:
      readPartialState in interface DBSConnection
      Parameters:
      id - the document id
      keys - the keys to read
      Returns:
      the document partial state, or null if not found
    • readStates

      public List<State> readStates(List<String> ids)
      Description copied from interface: DBSConnection
      Reads the states of several documents.

      The returned states may be in a different order than the ids.

      Specified by:
      readStates in interface DBSConnection
      Parameters:
      ids - the document ids
      Returns:
      the document states, an element by be null if not found
    • createState

      public void createState(State state)
      Description copied from interface: DBSConnection
      Creates a document.
      Specified by:
      createState in interface DBSConnection
      Parameters:
      state - the document state
    • createStates

      public void createStates(List<State> states)
      Description copied from interface: DBSConnection
      Creates documents.
      Specified by:
      createStates in interface DBSConnection
      Parameters:
      states - the document states
    • updateState

      public void updateState(String id, State.StateDiff diff, DBSTransactionState.ConditionalUpdates conditionalUpdates)
      Description copied from interface: DBSConnection
      Updates a document.
      Specified by:
      updateState in interface DBSConnection
      Parameters:
      id - the document id
      diff - the diff to apply
      conditionalUpdates - the conditional updates, or null
    • deleteStates

      public void deleteStates(Set<String> ids)
      Description copied from interface: DBSConnection
      Deletes a set of document.
      Specified by:
      deleteStates in interface DBSConnection
      Parameters:
      ids - the document ids
    • readChildState

      public State readChildState(String parentId, String name, Set<String> ignored)
      Description copied from interface: DBSConnection
      Reads the state of a child document.
      Specified by:
      readChildState in interface DBSConnection
      Parameters:
      parentId - the parent document id
      name - the name of the child
      ignored - a set of document ids that should not be considered
      Returns:
      the state of the child document, or null if not found
    • sendInvalidationsToOthers

      protected void sendInvalidationsToOthers()
    • processReceivedInvalidations

      protected void processReceivedInvalidations()
    • getRootId

      public String getRootId()
      Description copied from interface: DBSConnection
      Gets the root id.
      Specified by:
      getRootId in interface DBSConnection
      Returns:
      the root id.
    • generateNewId

      public String generateNewId()
      Description copied from interface: DBSConnection
      Generates a new id for a document.
      Specified by:
      generateNewId in interface DBSConnection
      Returns:
      the new id
    • hasChild

      public boolean hasChild(String parentId, String name, Set<String> ignored)
      Description copied from interface: DBSConnection
      Checks if a document has a child with the given name
      Specified by:
      hasChild in interface DBSConnection
      Parameters:
      parentId - the parent document id
      name - the name of the child
      ignored - a set of document ids that should not be considered
      Returns:
      true if the child exists, false if not
    • queryKeyValue

      public List<State> queryKeyValue(String key, Object value, Set<String> ignored)
      Description copied from interface: DBSConnection
      Queries the repository for documents having key = value.
      Specified by:
      queryKeyValue in interface DBSConnection
      Parameters:
      key - the key
      value - the value
      ignored - 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: DBSConnection
      Queries the repository for documents having key1 = value1 and key2 = value2.
      Specified by:
      queryKeyValue in interface DBSConnection
      Parameters:
      key1 - the first key
      value1 - the first value
      key2 - the second key
      value2 - the second value
      ignored - a set of document ids that should not be considered
      Returns:
      the document states matching the query
    • getDescendants

      public Stream<State> getDescendants(String id, Set<String> keys)
      Description copied from interface: DBSConnection
      Returns 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:
      getDescendants in interface DBSConnection
      Parameters:
      id - the root document id
      keys - what to collect about the descendants in addition to their ids
      Returns:
      a stream of States; THE STREAM MUST BE CLOSED WHEN DONE
    • getDescendants

      public Stream<State> getDescendants(String id, Set<String> keys, int limit)
      Description copied from interface: DBSConnection
      Returns 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:
      getDescendants in interface DBSConnection
      Parameters:
      id - the root document id
      keys - what to collect about the descendants in addition to their ids
      limit - the maximum number of descendants to return
      Returns:
      a stream of States; THE STREAM MUST BE CLOSED WHEN DONE
    • queryKeyValuePresence

      public boolean queryKeyValuePresence(String key, String value, Set<String> ignored)
      Description copied from interface: DBSConnection
      Queries the repository to check if there are documents having key = value.
      Specified by:
      queryKeyValuePresence in interface DBSConnection
      Parameters:
      key - the key
      value - the value
      ignored - a set of document ids that should not be considered
      Returns:
      true if the query matches at least one document, false if 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: DBSConnection
      Queries the repository for documents matching a NXQL query, and returns a projection of the documents.
      Specified by:
      queryAndFetch in interface DBSConnection
      Parameters:
      evaluator - the map-based evaluator for the query
      orderByClause - an ORDER BY clause
      distinctDocuments - true if the projection should return a maximum of one row per document
      limit - the limit on the number of documents to return
      offset - the offset in the list of documents to return
      countUpTo - if -1, count the total size without offset/limit.
      If 0, don't count the total size, set it to -1 .
      If n, 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: DBSConnection
      Executes the given query and returns the first batch of results containing id of documents, next batch must be requested within the keepAliveSeconds delay.
      Specified by:
      scroll in interface DBSConnection
    • scroll

      public ScrollResult<String> scroll(String scrollId)
      Description copied from interface: DBSConnection
      Get the next batch of results containing id of documents, the scrollId is part of the previous ScrollResult response.
      Specified by:
      scroll in interface DBSConnection
    • 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 interface LockManager
      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 interface LockManager
      Parameters:
      id - the document id
      lock - 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 is null then the lock is unconditionally removed.

      If owner is not null, it must match the existing lock owner for the lock to be removed. If it doesn't match, the returned lock will return true for Lock.getFailed().

      Specified by:
      removeLock in interface LockManager
      Parameters:
      id - the document id
      owner - the owner to check, or null for 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: DBSConnection
      Queries the repository for documents having key1 = value1 and key2 ${operator} value2.
      Specified by:
      queryKeyValueWithOperator in interface DBSConnection
      Parameters:
      key1 - the first key
      value1 - the first value
      key2 - the second key
      operator - the operator to apply between key2 and value2
      value2 - the second value
      ignored - a set of document ids that should not be considered
      Returns:
      the document states matching the query