public class SequenceNumbersService extends AbstractIndexShardComponent
deprecationLogger, indexSettings, logger, shardId
Constructor and Description |
---|
SequenceNumbersService(ShardId shardId,
java.lang.String allocationId,
IndexSettings indexSettings,
long maxSeqNo,
long localCheckpoint,
long globalCheckpoint)
Initialize the sequence number service.
|
Modifier and Type | Method and Description |
---|---|
void |
abortRelocationHandoff()
Fails a relocation handoff attempt.
|
void |
activatePrimaryMode(long localCheckpoint)
Activates the global checkpoint tracker in primary mode (see
GlobalCheckpointTracker.primaryMode . |
void |
activateWithPrimaryContext(GlobalCheckpointTracker.PrimaryContext primaryContext)
Activates the global checkpoint tracker in primary mode (see
GlobalCheckpointTracker.primaryMode . |
void |
completeRelocationHandoff()
Marks a relocation handoff attempt as successful.
|
long |
generateSeqNo()
Issue the next sequence number.
|
long |
getGlobalCheckpoint()
Returns the global checkpoint for the shard.
|
com.carrotsearch.hppc.ObjectLongMap<java.lang.String> |
getInSyncGlobalCheckpoints()
Get the local knowledge of the global checkpoints for all in-sync allocation IDs.
|
long |
getLocalCheckpoint()
Returns the local checkpoint for the shard.
|
long |
getMaxSeqNo()
The maximum sequence number issued so far.
|
ReplicationGroup |
getReplicationGroup()
Returns the current replication group for the shard.
|
long |
getTrackedLocalCheckpointForShard(java.lang.String allocationId)
Returns the local checkpoint information tracked for a specific shard.
|
void |
initiateTracking(java.lang.String allocationId)
Called when the recovery process for a shard is ready to open the engine on the target shard.
|
void |
markAllocationIdAsInSync(java.lang.String allocationId,
long localCheckpoint)
Marks the shard with the provided allocation ID as in-sync with the primary shard.
|
void |
markSeqNoAsCompleted(long seqNo)
Marks the processing of the provided sequence number as completed as updates the checkpoint if possible.
|
boolean |
pendingInSync()
Check if there are any recoveries pending in-sync.
|
void |
resetLocalCheckpoint(long localCheckpoint)
Resets the local checkpoint to the specified value.
|
GlobalCheckpointTracker.PrimaryContext |
startRelocationHandoff()
Get the primary context for the shard.
|
SeqNoStats |
stats()
The current sequence number stats.
|
void |
updateAllocationIdsFromMaster(long applyingClusterStateVersion,
java.util.Set<java.lang.String> inSyncAllocationIds,
IndexShardRoutingTable routingTable,
java.util.Set<java.lang.String> pre60AllocationIds)
Notifies the service of the current allocation IDs in the cluster state.
|
void |
updateGlobalCheckpointForShard(java.lang.String allocationId,
long globalCheckpoint)
Update the local knowledge of the global checkpoint for the specified allocation ID.
|
void |
updateGlobalCheckpointOnReplica(long globalCheckpoint,
java.lang.String reason)
Updates the global checkpoint on a replica shard after it has been updated by the primary.
|
void |
updateLocalCheckpointForShard(java.lang.String allocationId,
long checkpoint)
Notifies the service to update the local checkpoint for the shard with the provided allocation ID.
|
void |
waitForOpsToComplete(long seqNo)
Waits for all operations up to the provided sequence number to complete.
|
indexSettings, nodeName, shardId
public SequenceNumbersService(ShardId shardId, java.lang.String allocationId, IndexSettings indexSettings, long maxSeqNo, long localCheckpoint, long globalCheckpoint)
maxSeqNo
should be set to the last sequence number assigned by this shard, or
SequenceNumbers.NO_OPS_PERFORMED
, localCheckpoint
should be set to the last known local checkpoint for this
shard, or SequenceNumbers.NO_OPS_PERFORMED
, and globalCheckpoint
should be set to the last known global
checkpoint for this shard, or SequenceNumbers.UNASSIGNED_SEQ_NO
.shardId
- the shard this service is providing tracking local checkpoints forindexSettings
- the index settingsmaxSeqNo
- the last sequence number assigned by this shard, or SequenceNumbers.NO_OPS_PERFORMED
localCheckpoint
- the last known local checkpoint for this shard, or SequenceNumbers.NO_OPS_PERFORMED
globalCheckpoint
- the last known global checkpoint for this shard, or SequenceNumbers.UNASSIGNED_SEQ_NO
public final long generateSeqNo()
markSeqNoAsCompleted(long)
after the operation for which the
issued sequence number completes (whether or not the operation completes successfully).public long getMaxSeqNo()
LocalCheckpointTracker.getMaxSeqNo()
for additional details.public void waitForOpsToComplete(long seqNo) throws java.lang.InterruptedException
seqNo
- the sequence number that the checkpoint must advance to before this method returnsjava.lang.InterruptedException
- if the thread was interrupted while blocking on the conditionpublic void markSeqNoAsCompleted(long seqNo)
LocalCheckpointTracker.markSeqNoAsCompleted(long)
for additional details.seqNo
- the sequence number to mark as completedpublic void resetLocalCheckpoint(long localCheckpoint)
localCheckpoint
- the local checkpoint to reset topublic SeqNoStats stats()
public void updateLocalCheckpointForShard(java.lang.String allocationId, long checkpoint)
GlobalCheckpointTracker.updateLocalCheckpoint(String, long)
for details.allocationId
- the allocation ID of the shard to update the local checkpoint forcheckpoint
- the local checkpoint for the shardpublic void updateGlobalCheckpointForShard(java.lang.String allocationId, long globalCheckpoint)
allocationId
- the allocation ID to update the global checkpoint forglobalCheckpoint
- the global checkpointpublic com.carrotsearch.hppc.ObjectLongMap<java.lang.String> getInSyncGlobalCheckpoints()
public void initiateTracking(java.lang.String allocationId)
GlobalCheckpointTracker.initiateTracking(String)
for details.allocationId
- the allocation ID of the shard for which recovery was initiatedpublic void markAllocationIdAsInSync(java.lang.String allocationId, long localCheckpoint) throws java.lang.InterruptedException
GlobalCheckpointTracker.markAllocationIdAsInSync(String, long)
for additional details.allocationId
- the allocation ID of the shard to mark as in-synclocalCheckpoint
- the current local checkpoint on the shardjava.lang.InterruptedException
public long getLocalCheckpoint()
public ReplicationGroup getReplicationGroup()
public long getGlobalCheckpoint()
public void updateGlobalCheckpointOnReplica(long globalCheckpoint, java.lang.String reason)
globalCheckpoint
- the global checkpointreason
- the reason the global checkpoint was updatedpublic long getTrackedLocalCheckpointForShard(java.lang.String allocationId)
public void activatePrimaryMode(long localCheckpoint)
GlobalCheckpointTracker.primaryMode
.
Called on primary activation or promotion.public void updateAllocationIdsFromMaster(long applyingClusterStateVersion, java.util.Set<java.lang.String> inSyncAllocationIds, IndexShardRoutingTable routingTable, java.util.Set<java.lang.String> pre60AllocationIds)
GlobalCheckpointTracker.updateFromMaster(long, Set, IndexShardRoutingTable, Set)
for details.applyingClusterStateVersion
- the cluster state version being applied when updating the allocation IDs from the masterinSyncAllocationIds
- the allocation IDs of the currently in-sync shard copiesroutingTable
- the shard routing tablepre60AllocationIds
- the allocation IDs of shards that are allocated to pre-6.0 nodespublic void activateWithPrimaryContext(GlobalCheckpointTracker.PrimaryContext primaryContext)
GlobalCheckpointTracker.primaryMode
.
Called on primary relocation target during primary relocation handoff.primaryContext
- the primary context used to initialize the statepublic boolean pendingInSync()
true
if there is at least one shard pending in-sync, otherwise falsepublic GlobalCheckpointTracker.PrimaryContext startRelocationHandoff()
public void completeRelocationHandoff()
public void abortRelocationHandoff()