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 Summary
FieldsModifier and TypeFieldDescriptionstatic final longEach queue operation is written in its own short transaction: the margin covers one, plus the clock difference between two cluster nodesstatic final Stringstatic final StringIn 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. -
Constructor Summary
ConstructorsConstructorDescriptionJCRIndexingServiceImpl(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 Summary
Modifier and TypeMethodDescriptionvoidapplyIndexChangesOnJCR(List<JCRIndexQueueEntity> indexingQueueEntities) Apply the changes coming from queue to JCR.voidapplyIndexChangesOnQueue(Set<String> removedNodes, Set<String> addedNodes, Set<String> parentRemovedNodes, Set<String> parentAddedNodes, String workspaceId) JCR Index Changes applied on JCR to propagate for other nodes through QueuevoidapplyIndexChangesOnQueue(org.exoplatform.services.jcr.impl.core.query.ChangesFilterListsWrapper changes, String workspaceId) JCR Index Changes applied on JCR to propagate for other nodes through QueuefindNextOperations(int offset, int batchNumber) intvoidvoidinit(org.exoplatform.services.jcr.impl.core.query.QueryHandler handler, org.exoplatform.services.jcr.config.QueryHandlerEntry config) Update Queue, JCR indexes and status file.voidvoidvoid1/ Read from Queue
2/ Index in JCR
3/ Update Queue to mark operation as executed for this nodevoidregisterWorkspaceIndex(String workspaceId, String indexDirectory, BooleanSupplier preparingACopy) Called once a workspace's index is ready at startup.voidvoidstart()voidstop()voidvoidunindexAll(String workspaceId) void
-
Field Details
-
LAST_OPERATION_FILE_NAME
- See Also:
-
IN_FLIGHT_OPERATION_MARGIN
public static final long IN_FLIGHT_OPERATION_MARGINEach 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
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
1/ Read from Queue
2/ Index in JCR
3/ Update Queue to mark operation as executed for this node- Specified by:
processIndexingQueuein interfaceJCRIndexingService- Throws:
Exception
-
start
public void start()- Specified by:
startin interfaceorg.picocontainer.Startable
-
stop
public void stop()- Specified by:
stopin interfaceorg.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:
applyIndexChangesOnQueuein interfaceJCRIndexingService- 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:JCRIndexingServiceJCR Index Changes applied on JCR to propagate for other nodes through Queue- Specified by:
applyIndexChangesOnQueuein interfaceJCRIndexingService- Parameters:
removedNodes- removed nodes JCR UUIDaddedNodes- added nodes JCR UUIDparentRemovedNodes- removed Parent JCR nodes UUIDparentAddedNodes- added Parent JCR nodes UUIDworkspaceId- 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:
initin interfaceJCRIndexingService- 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:
registerWorkspaceIndexin interfaceJCRIndexingService- Parameters:
workspaceId- the workspace of the index, as its queue operations name itindexDirectory- the index's directorypreparingACopy- 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-ListofJCRIndexQueueEntityto index- Throws:
Exception- when an error happens while indexing the operation
-
findNextOperations
-
index
-
reindex
-
unindex
-
unindexAll
-
updateQueueSwitchStatusInFile
public void updateQueueSwitchStatusInFile() -
getLastExecutedOperation
-
getQueueProcessingPeriod
public int getQueueProcessingPeriod() -
persistQueueOperations
public void persistQueueOperations() -
persistLastOperationId
public void persistLastOperationId()
-