Class RestoreService
- All Implemented Interfaces:
ClusterStateApplier
public class RestoreService extends java.lang.Object implements 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 cleanupRestoreState(ClusterChangedEvent),
which removes RestoreInProgress when all shards are completed. In case of
restore failure a normal recovery fail-over process kicks in.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classRestoreService.RestoreCompletionResponsestatic classRestoreService.RestoreInProgressUpdater -
Constructor Summary
Constructors Constructor Description RestoreService(ClusterService clusterService, RepositoriesService repositoriesService, AllocationService allocationService, MetaDataCreateIndexService createIndexService, MetaDataIndexUpgradeService metaDataIndexUpgradeService, ClusterSettings clusterSettings) -
Method Summary
Modifier and Type Method Description voidapplyClusterState(ClusterChangedEvent event)Called when a new cluster state (ClusterChangedEvent.state()needs to be applied.static booleancompleted(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards)static intfailedShards(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards)static booleanisRepositoryInUse(ClusterState clusterState, java.lang.String repository)Checks if a repository is currently in use by one of the snapshotsstatic RestoreInProgress.EntryrestoreInProgress(ClusterState state, java.lang.String restoreUUID)voidrestoreSnapshot(RestoreSnapshotRequest request, ActionListener<RestoreService.RestoreCompletionResponse> listener)Restores snapshot specified in the restore request.static java.util.Set<Index>restoringIndices(ClusterState currentState, java.util.Set<Index> indicesToCheck)Returns the indices that are currently being restored and that are contained in the indices-to-check set.static RestoreInProgressupdateRestoreStateWithDeletedIndices(RestoreInProgress oldRestore, java.util.Set<Index> deletedIndices)
-
Constructor Details
-
RestoreService
public RestoreService(ClusterService clusterService, RepositoriesService repositoriesService, AllocationService allocationService, MetaDataCreateIndexService createIndexService, MetaDataIndexUpgradeService metaDataIndexUpgradeService, ClusterSettings clusterSettings)
-
-
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
-
updateRestoreStateWithDeletedIndices
public static RestoreInProgress updateRestoreStateWithDeletedIndices(RestoreInProgress oldRestore, java.util.Set<Index> deletedIndices) -
restoreInProgress
public static RestoreInProgress.Entry restoreInProgress(ClusterState state, java.lang.String restoreUUID) -
completed
public static boolean completed(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards) -
failedShards
public static int failedShards(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards) -
restoringIndices
public static java.util.Set<Index> restoringIndices(ClusterState currentState, java.util.Set<Index> indicesToCheck)Returns the indices that are currently being restored and that are contained in the indices-to-check set. -
applyClusterState
Description copied from interface:ClusterStateApplierCalled 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:
applyClusterStatein interfaceClusterStateApplier
-
isRepositoryInUse
Checks if a repository is currently in use by one of the snapshots- Parameters:
clusterState- cluster staterepository- repository id- Returns:
- true if repository is currently in use by one of the running snapshots
-