Class ClusterNodeIndexCounterManager

java.lang.Object
com.atlassian.jira.index.IndexCounterManager
com.atlassian.jira.index.ha.ClusterNodeIndexCounterManager
All Implemented Interfaces:
NodeIndexCounterStore, PeriodicIndexWriterCommitObserver

public class ClusterNodeIndexCounterManager extends IndexCounterManager

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 Details

  • Method Details

    • storeHighestIdForNode

      public void storeHighestIdForNode(String sendingNodeId, long indexOperationId)
      Stores given operationId in local cache until next onAfterCommit() is completed.
      Parameters:
      sendingNodeId - - id of node that generated the operaton
      indexOperationId -
    • getIndexOperationCounterForNodeId

      public long getIndexOperationCounterForNodeId(String sendingNodeId)
      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 of onAfterCommit() Warning: this method is not thread safe and should be called withing one thread along with onAfterCommit().
    • onAfterCommit

      public void onAfterCommit()
      Attempts to persist latest operation ids to indexCounterStore . Processes in sequence operations copied into working buffer during the preceding calls of onBeforeCommit(). 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 with onBeforeCommit().