Package com.atlassian.jira.index.ha
Class ClusterNodeIndexCounterManager
java.lang.Object
com.atlassian.jira.index.IndexCounterManager
com.atlassian.jira.index.ha.ClusterNodeIndexCounterManager
- All Implemented Interfaces:
NodeIndexCounterStore,PeriodicIndexWriterCommitObserver
Decouples internal reporting of current state of replication of other nodes index operations from status reported to the DB.
NodeIndexCounter changes reported by storeHighestIdForNode(String, long) are buffered and are not saved to persistent storage
until commit operation is explicitly called.
The commit operation is two step, and is expected to be part of IndexWriter atomic save to disk operation.
-
Constructor Summary
ConstructorsConstructorDescriptionClusterNodeIndexCounterManager(OfBizNodeIndexCounterStore ofBizNodeIndexCounterStore, ClusterManager clusterManager) -
Method Summary
Modifier and TypeMethodDescriptionlonggetIndexOperationCounterForNodeId(String sendingNodeId) If local cache contains operation for given sendingNodeId returns it, otherwise returns it from the databasevoidAttempts to persist latest operation ids to indexCounterStore .voidCopies the buffer of latest replicated operations for each node to working buffer.voidstoreHighestIdForNode(String sendingNodeId, long indexOperationId) Stores given operationId in local cache until nextonAfterCommit()is completed.
-
Constructor Details
-
ClusterNodeIndexCounterManager
public ClusterNodeIndexCounterManager(OfBizNodeIndexCounterStore ofBizNodeIndexCounterStore, ClusterManager clusterManager)
-
-
Method Details
-
storeHighestIdForNode
Stores given operationId in local cache until nextonAfterCommit()is completed.- Parameters:
sendingNodeId- - id of node that generated the operatonindexOperationId-
-
getIndexOperationCounterForNodeId
If local cache contains operation for given sendingNodeId returns it, otherwise returns it from the database- Parameters:
sendingNodeId- - id of node that generated the operation- Returns:
-
onBeforeCommit
public void onBeforeCommit()Copies the buffer of latest replicated operations for each node to working buffer. Only cache content copied during this step will be processed during next call ofonAfterCommit()Warning: this method is not thread safe and should be called withing one thread along withonAfterCommit(). -
onAfterCommit
public void onAfterCommit()Attempts to persist latest operation ids to indexCounterStore . Processes in sequence operations copied into working buffer during the preceding calls ofonBeforeCommit(). If the process is interrupted by an exception, the saved node operations are removed from the local cache, while others remain until the next call. Warning: this method is not thread safe and should be called within one thread along withonBeforeCommit().
-