Class JCRIndexingServiceImpl

java.lang.Object
org.exoplatform.services.jcr.ext.index.persistent.impl.JCRIndexingServiceImpl
All Implemented Interfaces:
JCRIndexingService, org.picocontainer.Startable

public class JCRIndexingServiceImpl extends Object implements JCRIndexingService, org.picocontainer.Startable
  • Field Details

    • LAST_OPERATION_FILE_NAME

      public static final String LAST_OPERATION_FILE_NAME
      See Also:
    • IN_FLIGHT_OPERATION_MARGIN

      public static final long IN_FLIGHT_OPERATION_MARGIN
      Each queue operation is written in its own short transaction: the margin covers one, plus the clock difference between two cluster nodes
      See Also:
    • WORKSPACE_LAST_OPERATION_FILE_NAME

      public static final String WORKSPACE_LAST_OPERATION_FILE_NAME
      In each workspace's index directory: an operation id up to which the index holds every queue operation, the cluster node that wrote it and the time it read that id. A copy of the index from another node brings that node's file along.
      See Also:
  • Constructor Details

    • JCRIndexingServiceImpl

      public JCRIndexingServiceImpl(org.exoplatform.container.ExoContainerContext containerContext, org.exoplatform.commons.persistence.impl.EntityManagerService entityManagerService, org.exoplatform.services.jcr.RepositoryService repositoryService, JCRIndexingQueueDAO indexingQueueDAO, org.exoplatform.container.xml.InitParams params)
  • Method Details

    • processIndexingQueue

      public void processIndexingQueue() throws Exception
      1/ Read from Queue
      2/ Index in JCR
      3/ Update Queue to mark operation as executed for this node
      Specified by:
      processIndexingQueue in interface JCRIndexingService
      Throws:
      Exception
    • start

      public void start()
      Specified by:
      start in interface org.picocontainer.Startable
    • stop

      public void stop()
      Specified by:
      stop in interface org.picocontainer.Startable
    • applyIndexChangesOnQueue

      public void applyIndexChangesOnQueue(org.exoplatform.services.jcr.impl.core.query.ChangesFilterListsWrapper changes, String workspaceId)
      JCR Index Changes applied on JCR to propagate for other nodes through Queue
      Specified by:
      applyIndexChangesOnQueue in interface JCRIndexingService
      Parameters:
      changes -
      workspaceId - REPOSITORY_WORKSPACE
    • applyIndexChangesOnQueue

      public void applyIndexChangesOnQueue(Set<String> removedNodes, Set<String> addedNodes, Set<String> parentRemovedNodes, Set<String> parentAddedNodes, String workspaceId)
      Description copied from interface: JCRIndexingService
      JCR Index Changes applied on JCR to propagate for other nodes through Queue
      Specified by:
      applyIndexChangesOnQueue in interface JCRIndexingService
      Parameters:
      removedNodes - removed nodes JCR UUID
      addedNodes - added nodes JCR UUID
      parentRemovedNodes - removed Parent JCR nodes UUID
      parentAddedNodes - added Parent JCR nodes UUID
      workspaceId - REPOSITORY_WORKSPACE
    • init

      public void init(org.exoplatform.services.jcr.impl.core.query.QueryHandler handler, org.exoplatform.services.jcr.config.QueryHandlerEntry config)
      Update Queue, JCR indexes and status file. Initialize JCR Indexing Service
      Specified by:
      init in interface JCRIndexingService
      Parameters:
      handler -
      config -
    • registerWorkspaceIndex

      public void registerWorkspaceIndex(String workspaceId, String indexDirectory, BooleanSupplier preparingACopy)
      Called once a workspace's index is ready at startup. When the index was copied from another cluster node, the queue operations of the workspace are marked as that copy holds them, so that this node applies what the copy lacks. The index's marker names the cluster node whose queue marks the index matches, an operation id up to which that node had applied every operation, and the time it read that id: another node's marker came with a copy of that node's index. The operations of the workspace, parent changes included, then lose this node's marks and get them back only where the other node applied them, up to that id and queued well before that time: the queue gives this node back everything else. An unreadable marker gives back every operation of the workspace, applied twice rather than lost. Each batch of marks is its own transaction; when the marks cannot be taken, the copied marker is kept beside the index directory, where only this node's next start reads it, and the index's own marker is left unreadable, so that a copy of the index meanwhile gives every operation back.
      Specified by:
      registerWorkspaceIndex in interface JCRIndexingService
      Parameters:
      workspaceId - the workspace of the index, as its queue operations name it
      indexDirectory - the index's directory
      preparingACopy - true while this node prepares a copy of the index for another node: the index's marker is not written meanwhile
    • applyIndexChangesOnJCR

      public void applyIndexChangesOnJCR(List<JCRIndexQueueEntity> indexingQueueEntities) throws Exception
      Apply the changes coming from queue to JCR. The changes are identitifed by JCR UUID and Operation type.
      Parameters:
      indexingQueueEntities - List of JCRIndexQueueEntity to index
      Throws:
      Exception - when an error happens while indexing the operation
    • findNextOperations

      public List<JCRIndexQueueEntity> findNextOperations(int offset, int batchNumber)
    • index

      public void index(String jcrUUID, String workspaceId, boolean parentChange)
    • reindex

      public void reindex(String jcrUUID, String workspaceId, boolean parentChange)
    • unindex

      public void unindex(String jcrUUID, String workspaceId, boolean parentChange)
    • unindexAll

      public void unindexAll(String workspaceId)
    • updateQueueSwitchStatusInFile

      public void updateQueueSwitchStatusInFile()
    • getLastExecutedOperation

      public String getLastExecutedOperation()
    • getQueueProcessingPeriod

      public int getQueueProcessingPeriod()
    • persistQueueOperations

      public void persistQueueOperations()
    • persistLastOperationId

      public void persistLastOperationId()