java.util.function.LongSupplier
, IndexShardComponent
public class ReplicationTracker extends AbstractIndexShardComponent implements java.util.function.LongSupplier
The global checkpoint is maintained by the primary shard and is replicated to all the replicas (via GlobalCheckpointSyncAction
).
Modifier and Type | Class | Description |
---|---|---|
static class |
ReplicationTracker.CheckpointState |
|
static class |
ReplicationTracker.PrimaryContext |
Represents the sequence number component of the primary context.
|
deprecationLogger, indexSettings, logger, shardId
Constructor | Description |
---|---|
ReplicationTracker(ShardId shardId,
java.lang.String allocationId,
IndexSettings indexSettings,
long globalCheckpoint) |
Initialize the global checkpoint service.
|
Modifier and Type | Method | Description |
---|---|---|
void |
abortRelocationHandoff() |
Fails a relocation handoff attempt.
|
void |
activatePrimaryMode(long localCheckpoint) |
Initializes the global checkpoint tracker in primary mode (see
primaryMode . |
void |
activateWithPrimaryContext(ReplicationTracker.PrimaryContext primaryContext) |
Activates the global checkpoint tracker in primary mode (see
primaryMode . |
void |
completeRelocationHandoff() |
Marks a relocation handoff attempt as successful.
|
long |
getAsLong() |
|
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.
|
ReplicationGroup |
getReplicationGroup() |
Returns the current replication group for the shard.
|
ReplicationTracker.CheckpointState |
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 has opened the engine on the target shard.
|
boolean |
isPrimaryMode() |
Returns whether the replication tracker is in primary mode, i.e., whether the current shard is acting as primary from the point of
view of replication.
|
void |
markAllocationIdAsInSync(java.lang.String allocationId,
long localCheckpoint) |
Marks the shard with the provided allocation ID as in-sync with the primary shard.
|
boolean |
pendingInSync() |
Whether the are shards blocking global checkpoint advancement.
|
ReplicationTracker.PrimaryContext |
startRelocationHandoff() |
Initiates a relocation handoff and returns the corresponding primary context.
|
void |
updateFromMaster(long applyingClusterStateVersion,
java.util.Set<java.lang.String> inSyncAllocationIds,
IndexShardRoutingTable routingTable,
java.util.Set<java.lang.String> pre60AllocationIds) |
Notifies the tracker 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 |
updateLocalCheckpoint(java.lang.String allocationId,
long localCheckpoint) |
Notifies the service to update the local checkpoint for the shard with the provided allocation ID.
|
indexSettings, nodeName, shardId
public ReplicationTracker(ShardId shardId, java.lang.String allocationId, IndexSettings indexSettings, long globalCheckpoint)
SequenceNumbers.UNASSIGNED_SEQ_NO
.shardId
- the shard IDallocationId
- the allocation IDindexSettings
- the index settingsglobalCheckpoint
- the last known global checkpoint for this shard, or SequenceNumbers.UNASSIGNED_SEQ_NO
public com.carrotsearch.hppc.ObjectLongMap<java.lang.String> getInSyncGlobalCheckpoints()
public boolean isPrimaryMode()
public ReplicationGroup getReplicationGroup()
public long getGlobalCheckpoint()
public long getAsLong()
getAsLong
in interface java.util.function.LongSupplier
public void updateGlobalCheckpointOnReplica(long globalCheckpoint, java.lang.String reason)
globalCheckpoint
- the global checkpointreason
- the reason the global checkpoint was updatedpublic void updateGlobalCheckpointForShard(java.lang.String allocationId, long globalCheckpoint)
allocationId
- the allocation ID to update the global checkpoint forglobalCheckpoint
- the global checkpointpublic void activatePrimaryMode(long localCheckpoint)
primaryMode
. Called on primary activation or promotion.public void updateFromMaster(long applyingClusterStateVersion, java.util.Set<java.lang.String> inSyncAllocationIds, IndexShardRoutingTable routingTable, java.util.Set<java.lang.String> pre60AllocationIds)
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 initiateTracking(java.lang.String allocationId)
allocationId
- the allocation ID of the shard for which recovery was initiatedpublic void markAllocationIdAsInSync(java.lang.String allocationId, long localCheckpoint) throws java.lang.InterruptedException
allocationId
- the allocation ID of the shard to mark as in-synclocalCheckpoint
- the current local checkpoint on the shardjava.lang.InterruptedException
public void updateLocalCheckpoint(java.lang.String allocationId, long localCheckpoint)
allocationId
- the allocation ID of the shard to update the local checkpoint forlocalCheckpoint
- the local checkpoint for the shardpublic ReplicationTracker.PrimaryContext startRelocationHandoff()
public void abortRelocationHandoff()
public void completeRelocationHandoff()
public void activateWithPrimaryContext(ReplicationTracker.PrimaryContext primaryContext)
primaryMode
. Called on primary relocation target during
primary relocation handoff.primaryContext
- the primary context used to initialize the statepublic boolean pendingInSync()
public ReplicationTracker.CheckpointState getTrackedLocalCheckpointForShard(java.lang.String allocationId)