ClusterStateApplier
public class RestoreService extends AbstractComponent implements ClusterStateApplier
Restore operation is performed in several stages.
First restoreSnapshot(RestoreRequest, 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(Repository)
)}
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.
Modifier and Type | Class | Description |
---|---|---|
static class |
RestoreService.RestoreCompletionResponse |
|
static class |
RestoreService.RestoreInProgressUpdater |
|
static class |
RestoreService.RestoreRequest |
Restore snapshot request
|
deprecationLogger, logger, settings
Constructor | Description |
---|---|
RestoreService(Settings settings,
ClusterService clusterService,
RepositoriesService repositoriesService,
AllocationService allocationService,
MetaDataCreateIndexService createIndexService,
MetaDataIndexUpgradeService metaDataIndexUpgradeService,
ClusterSettings clusterSettings) |
Modifier and Type | Method | Description |
---|---|---|
void |
applyClusterState(ClusterChangedEvent event) |
Called when a new cluster state (
ClusterChangedEvent.state() needs to be applied |
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).
|
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 snapshots
|
static RestoreInProgress.State |
overallState(RestoreInProgress.State nonCompletedState,
ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards) |
|
static RestoreInProgress.Entry |
restoreInProgress(ClusterState state,
Snapshot snapshot) |
|
void |
restoreSnapshot(RestoreService.RestoreRequest request,
ActionListener<RestoreService.RestoreCompletionResponse> listener) |
Restores snapshot specified in the restore request.
|
static RestoreInProgress |
updateRestoreStateWithDeletedIndices(RestoreInProgress oldRestore,
java.util.Set<Index> deletedIndices) |
logDeprecatedSetting, logRemovedSetting, nodeName
@Inject public RestoreService(Settings settings, ClusterService clusterService, RepositoriesService repositoriesService, AllocationService allocationService, MetaDataCreateIndexService createIndexService, MetaDataIndexUpgradeService metaDataIndexUpgradeService, ClusterSettings clusterSettings)
public void restoreSnapshot(RestoreService.RestoreRequest request, ActionListener<RestoreService.RestoreCompletionResponse> listener)
request
- restore requestlistener
- restore listenerpublic static RestoreInProgress updateRestoreStateWithDeletedIndices(RestoreInProgress oldRestore, java.util.Set<Index> deletedIndices)
public static RestoreInProgress.Entry restoreInProgress(ClusterState state, Snapshot snapshot)
public static RestoreInProgress.State overallState(RestoreInProgress.State nonCompletedState, ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards)
public static boolean completed(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards)
public static int failedShards(ImmutableOpenMap<ShardId,RestoreInProgress.ShardRestoreStatus> shards)
public static void checkIndexClosing(ClusterState currentState, java.util.Set<IndexMetaData> indices)
public void applyClusterState(ClusterChangedEvent event)
ClusterStateApplier
ClusterChangedEvent.state()
needs to be appliedapplyClusterState
in interface ClusterStateApplier
public static boolean isRepositoryInUse(ClusterState clusterState, java.lang.String repository)
clusterState
- cluster staterepository
- repository id