Class RestoreService
- All Implemented Interfaces:
ClusterStateApplier
Restore operation is performed in several stages.
First restoreSnapshot(RestoreSnapshotRequest, org.elasticsearch.action.ActionListener)
method reads information about snapshot and metadata from repository. In update cluster state task it checks restore
preconditions, restores global state if needed, creates RestoreInProgress
record with list of shards that needs
to be restored and adds this shard to the routing table using
RoutingTable.Builder.addAsRestore(IndexMetadata, SnapshotRecoverySource)
method.
Individual shards are getting restored as part of normal recovery process in
IndexShard.restoreFromRepository(org.elasticsearch.repositories.Repository, org.elasticsearch.action.ActionListener<java.lang.Boolean>)
)}
method, which detects that shard should be restored from snapshot rather than recovered from gateway by looking
at the ShardRouting.recoverySource()
property.
At the end of the successful restore process RestoreService
calls removeCompletedRestoresFromClusterState()
,
which removes RestoreInProgress
when all shards are completed. In case of
restore failure a normal recovery fail-over process kicks in.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
static class
-
Field Summary
-
Constructor Summary
ConstructorDescriptionRestoreService(ClusterService clusterService, RepositoriesService repositoriesService, AllocationService allocationService, MetadataCreateIndexService createIndexService, MetadataDeleteIndexService metadataDeleteIndexService, IndexMetadataVerifier indexMetadataVerifier, ShardLimitValidator shardLimitValidator, SystemIndices systemIndices)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Called when a new cluster state (ClusterChangedEvent.state()
needs to be applied.static boolean
static boolean
failed(SnapshotInfo snapshot, String index)
static int
static RestoreInProgress.Entry
restoreInProgress(ClusterState state, String restoreUUID)
void
restoreSnapshot(RestoreSnapshotRequest request, ActionListener<RestoreService.RestoreCompletionResponse> listener)
Restores snapshot specified in the restore request.void
restoreSnapshot(RestoreSnapshotRequest request, ActionListener<RestoreService.RestoreCompletionResponse> listener, BiConsumer<ClusterState,Metadata.Builder> updater)
Restores snapshot specified in the restore request.restoringIndices(ClusterState currentState, Set<Index> indicesToCheck)
Returns the indices that are currently being restored and that are contained in the indices-to-check set.static RestoreInProgress
updateRestoreStateWithDeletedIndices(RestoreInProgress oldRestore, Set<Index> deletedIndices)
-
Field Details
-
REFRESH_REPO_UUID_ON_RESTORE_SETTING
-
-
Constructor Details
-
RestoreService
public RestoreService(ClusterService clusterService, RepositoriesService repositoriesService, AllocationService allocationService, MetadataCreateIndexService createIndexService, MetadataDeleteIndexService metadataDeleteIndexService, IndexMetadataVerifier indexMetadataVerifier, ShardLimitValidator shardLimitValidator, SystemIndices systemIndices)
-
-
Method Details
-
restoreSnapshot
public void restoreSnapshot(RestoreSnapshotRequest request, ActionListener<RestoreService.RestoreCompletionResponse> listener)Restores snapshot specified in the restore request.- Parameters:
request
- restore requestlistener
- restore listener
-
restoreSnapshot
public void restoreSnapshot(RestoreSnapshotRequest request, ActionListener<RestoreService.RestoreCompletionResponse> listener, BiConsumer<ClusterState,Metadata.Builder> updater)Restores snapshot specified in the restore request.- Parameters:
request
- restore requestlistener
- restore listenerupdater
- handler that allows callers to make modifications toMetadata
in the same cluster state update as the restore operation
-
updateRestoreStateWithDeletedIndices
public static RestoreInProgress updateRestoreStateWithDeletedIndices(RestoreInProgress oldRestore, Set<Index> deletedIndices) -
completed
public static boolean completed(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards) -
failedShards
public static int failedShards(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards) -
failed
-
restoringIndices
Returns the indices that are currently being restored and that are contained in the indices-to-check set. -
restoreInProgress
-
applyClusterState
Description copied from interface:ClusterStateApplier
Called when a new cluster state (ClusterChangedEvent.state()
needs to be applied. The cluster state to be applied is already committed when this method is called, so an applier must therefore be prepared to deal with any state it receives without throwing an exception. Throwing an exception from an applier is very bad because it will stop the application of this state before it has reached all the other appliers, and will likely result in another attempt to apply the same (or very similar) cluster state which might continue until this node is removed from the cluster.- Specified by:
applyClusterState
in interfaceClusterStateApplier
-