Class RestoreService
- java.lang.Object
-
- org.elasticsearch.snapshots.RestoreService
-
- All Implemented Interfaces:
ClusterStateApplier
public class RestoreService extends java.lang.Object implements ClusterStateApplier
Service responsible for restoring snapshotsRestore 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, createsRestoreInProgress
record with list of shards that needs to be restored and adds this shard to the routing table usingRoutingTable.Builder.addAsRestore(IndexMetaData, SnapshotRecoverySource)
method.Individual shards are getting restored as part of normal recovery process in
IndexShard.restoreFromRepository(Repository)
)} method, which detects that shard should be restored from snapshot rather than recovered from gateway by looking at theShardRouting.recoverySource()
property.At the end of the successful restore process
RestoreService
callscleanupRestoreState(ClusterChangedEvent)
, which removesRestoreInProgress
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 class
RestoreService.RestoreCompletionResponse
static class
RestoreService.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 void
applyClusterState(ClusterChangedEvent event)
Called when a new cluster state (ClusterChangedEvent.state()
needs to be appliedstatic void
checkIndexClosing(ClusterState currentState, java.util.Set<IndexMetaData> indices)
Check if any of the indices to be closed are currently being restored from a snapshot and fail closing if such an index is found as closing an index that is being restored makes the index unusable (it cannot be recovered).static boolean
completed(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards)
static int
failedShards(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards)
static boolean
isRepositoryInUse(ClusterState clusterState, java.lang.String repository)
Checks if a repository is currently in use by one of the snapshotsstatic RestoreInProgress.State
overallState(RestoreInProgress.State nonCompletedState, ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards)
static RestoreInProgress.Entry
restoreInProgress(ClusterState state, java.lang.String restoreUUID)
void
restoreSnapshot(RestoreSnapshotRequest request, ActionListener<RestoreService.RestoreCompletionResponse> listener)
Restores snapshot specified in the restore request.static RestoreInProgress
updateRestoreStateWithDeletedIndices(RestoreInProgress oldRestore, java.util.Set<Index> deletedIndices)
-
-
-
Constructor Detail
-
RestoreService
@Inject public RestoreService(ClusterService clusterService, RepositoriesService repositoriesService, AllocationService allocationService, MetaDataCreateIndexService createIndexService, MetaDataIndexUpgradeService metaDataIndexUpgradeService, ClusterSettings clusterSettings)
-
-
Method Detail
-
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)
-
overallState
public static RestoreInProgress.State overallState(RestoreInProgress.State nonCompletedState, ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards)
-
completed
public static boolean completed(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards)
-
failedShards
public static int failedShards(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards)
-
checkIndexClosing
public static void checkIndexClosing(ClusterState currentState, java.util.Set<IndexMetaData> indices)
Check if any of the indices to be closed are currently being restored from a snapshot and fail closing if such an index is found as closing an index that is being restored makes the index unusable (it cannot be recovered).
-
applyClusterState
public void applyClusterState(ClusterChangedEvent event)
Description copied from interface:ClusterStateApplier
Called when a new cluster state (ClusterChangedEvent.state()
needs to be applied- Specified by:
applyClusterState
in interfaceClusterStateApplier
-
isRepositoryInUse
public static boolean isRepositoryInUse(ClusterState clusterState, java.lang.String repository)
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
-
-