Class DefaultReIndexJobManager
- java.lang.Object
-
- com.atlassian.confluence.internal.index.status.DefaultReIndexJobManager
-
- All Implemented Interfaces:
ReIndexJobManager
,ReIndexJobManagerInternal
public class DefaultReIndexJobManager extends Object implements ReIndexJobManagerInternal
This implementation ofReIndexJobManager
listens to indexing-related events and update re-index status accordingly- Since:
- 7.6.0
-
-
Field Summary
-
Fields inherited from interface com.atlassian.confluence.internal.index.status.ReIndexJobManagerInternal
JOB_PERSISTER_LOCK_NAME, REINDEX_IMPROVEMENT_DARKFEATURE_KEY
-
-
Constructor Summary
Constructors Constructor Description DefaultReIndexJobManager(ReIndexJobPersister persister, com.atlassian.event.api.EventPublisher eventPublisher, com.atlassian.scheduler.SchedulerService schedulerService, ClusterManager clusterManager, com.atlassian.beehive.ClusterLockService clusterLockService, com.atlassian.sal.api.features.DarkFeatureManager darkFeatureManager, BootstrapManager bootstrapManager, SystemMaintenanceTaskQueue systemMaintenanceTaskQueue)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
acknowledgeRunningJob()
Mark most recent or running re-index job as acknowledged.void
clear()
Delete most recent or running re-index job.Optional<ReIndexJob>
createNewJob(List<String> spaceKeys)
Create a new job which may replace a completed job stored in the bandana table.Optional<ReIndexJob>
getRunningOrMostRecentReIndex()
void
onIndexRebuildFinished(ReindexFinishedEvent reindexFinishedEvent)
void
onIndexRebuildStarted(ReindexStartedEvent startedEvent)
void
onIndexSnapshotCreationFailedEvent(IndexSnapshotCreationFailedEvent failedEvent)
void
onIndexSnapshotRestorationFailedEvent(IndexSnapshotRestorationFailedEvent failedEvent)
void
onIndexSnapshotRestoredSuccessfullyEvent(IndexSnapshotRestoredSuccessfullyEvent indexSnapshotRestoredSuccessfullyEvent)
void
onReIndexRequest(ReIndexRequestEvent reIndexRequestEvent)
void
onRestoreIndexSnapshotStartedEvent(RestoreIndexSnapshotStartedEvent ignored)
void
register()
void
unregister()
void
updateReIndexJob(ReIndexJob reIndexJob)
Update the reindexJob in an atomic operation (i.e.void
updateReIndexJobIfPresent(Consumer<ReIndexJob> updater)
Try to update running re-index job in an atomic operation, synchronised by a cluster-wide lock.
-
-
-
Constructor Detail
-
DefaultReIndexJobManager
public DefaultReIndexJobManager(ReIndexJobPersister persister, com.atlassian.event.api.EventPublisher eventPublisher, com.atlassian.scheduler.SchedulerService schedulerService, ClusterManager clusterManager, com.atlassian.beehive.ClusterLockService clusterLockService, com.atlassian.sal.api.features.DarkFeatureManager darkFeatureManager, BootstrapManager bootstrapManager, SystemMaintenanceTaskQueue systemMaintenanceTaskQueue)
-
-
Method Detail
-
register
@PostConstruct public void register()
-
unregister
@PreDestroy public void unregister()
-
getRunningOrMostRecentReIndex
public Optional<ReIndexJob> getRunningOrMostRecentReIndex()
- Specified by:
getRunningOrMostRecentReIndex
in interfaceReIndexJobManager
- Returns:
- most recent or running re-index job. Empty if there is neither.
-
acknowledgeRunningJob
public boolean acknowledgeRunningJob() throws InterruptedException
Description copied from interface:ReIndexJobManager
Mark most recent or running re-index job as acknowledged. No-op if there is neither.- Specified by:
acknowledgeRunningJob
in interfaceReIndexJobManager
- Returns:
- true if most recent/running re-index job has been successfully marked as acknowledged.
- Throws:
InterruptedException
- if interrupted when trying to ack the job
-
updateReIndexJobIfPresent
public void updateReIndexJobIfPresent(Consumer<ReIndexJob> updater) throws InterruptedException, TimeoutException
Try to update running re-index job in an atomic operation, synchronised by a cluster-wide lock.- Specified by:
updateReIndexJobIfPresent
in interfaceReIndexJobManagerInternal
- Parameters:
updater
- a callback to mutate runningReIndexJob
- Throws:
InterruptedException
- if interrupted while waiting to update the jobTimeoutException
- if cannot obtain exclusive access in order to update the job within reasonable time
-
updateReIndexJob
public void updateReIndexJob(ReIndexJob reIndexJob) throws InterruptedException, TimeoutException
Description copied from interface:ReIndexJobManagerInternal
Update the reindexJob in an atomic operation (i.e. with a cluster lock)- Specified by:
updateReIndexJob
in interfaceReIndexJobManagerInternal
- Throws:
InterruptedException
TimeoutException
-
createNewJob
public Optional<ReIndexJob> createNewJob(List<String> spaceKeys)
Description copied from interface:ReIndexJobManager
Create a new job which may replace a completed job stored in the bandana table.- Specified by:
createNewJob
in interfaceReIndexJobManager
- Returns:
- the new job if it can be created
-
clear
public void clear()
Description copied from interface:ReIndexJobManager
Delete most recent or running re-index job. No-op if there is neither- Specified by:
clear
in interfaceReIndexJobManager
-
onReIndexRequest
@EventListener public void onReIndexRequest(ReIndexRequestEvent reIndexRequestEvent)
-
onIndexRebuildStarted
@EventListener public void onIndexRebuildStarted(ReindexStartedEvent startedEvent)
-
onIndexRebuildFinished
@EventListener public void onIndexRebuildFinished(ReindexFinishedEvent reindexFinishedEvent) throws InterruptedException
- Throws:
InterruptedException
-
onRestoreIndexSnapshotStartedEvent
@EventListener public void onRestoreIndexSnapshotStartedEvent(RestoreIndexSnapshotStartedEvent ignored) throws InterruptedException
- Throws:
InterruptedException
-
onIndexSnapshotCreationFailedEvent
@EventListener public void onIndexSnapshotCreationFailedEvent(IndexSnapshotCreationFailedEvent failedEvent) throws InterruptedException
- Throws:
InterruptedException
-
onIndexSnapshotRestoredSuccessfullyEvent
@EventListener public void onIndexSnapshotRestoredSuccessfullyEvent(IndexSnapshotRestoredSuccessfullyEvent indexSnapshotRestoredSuccessfullyEvent) throws InterruptedException
- Throws:
InterruptedException
-
onIndexSnapshotRestorationFailedEvent
@EventListener public void onIndexSnapshotRestorationFailedEvent(IndexSnapshotRestorationFailedEvent failedEvent) throws InterruptedException
- Throws:
InterruptedException
-
-