public class RestoreService extends AbstractComponent implements ClusterStateListener
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, RestoreSource)
method.
Individual shards are getting restored as part of normal recovery process in
IndexShard.restoreFromRepository(IndexShardRepository)
)}
method, which detects that shard should be restored from snapshot rather than recovered from gateway by looking
at the ShardRouting.restoreSource()
property.
At the end of the successful restore process IndexShardSnapshotAndRestoreService
calls indexShardRestoreCompleted(Snapshot, ShardId)
,
which updates RestoreInProgress
in cluster state or removes it when all shards are completed. In case of
restore failure a normal recovery fail-over process kicks in.
Modifier and Type | Class and Description |
---|---|
static class |
RestoreService.RestoreCompletionResponse |
static class |
RestoreService.RestoreRequest
Restore snapshot request
|
static class |
RestoreService.UpdateIndexShardRestoreStatusRequest
Internal class that is used to send notifications about finished shard restore operations to master node
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
UPDATE_RESTORE_ACTION_NAME |
deprecationLogger, logger, settings
Constructor and Description |
---|
RestoreService(Settings settings,
ClusterService clusterService,
RepositoriesService repositoriesService,
TransportService transportService,
AllocationService allocationService,
MetaDataCreateIndexService createIndexService,
MetaDataIndexUpgradeService metaDataIndexUpgradeService,
ClusterSettings clusterSettings) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ActionListener<RestoreService.RestoreCompletionResponse> listener)
Adds restore completion listener
|
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).
|
void |
clusterChanged(ClusterChangedEvent event)
Called when cluster state changes.
|
void |
failRestore(Snapshot snapshot,
ShardId shardId)
Fails the given snapshot restore operation for the given shard
|
void |
indexShardRestoreCompleted(Snapshot snapshot,
ShardId shardId)
This method is used by
IndexShard to notify
RestoreService about shard restore completion. |
static boolean |
isRepositoryInUse(ClusterState clusterState,
java.lang.String repository)
Checks if a repository is currently in use by one of the snapshots
|
void |
removeListener(ActionListener<RestoreService.RestoreCompletionResponse> listener)
Removes restore completion listener
|
void |
restoreSnapshot(RestoreService.RestoreRequest request,
ActionListener<RestoreInfo> listener)
Restores snapshot specified in the restore request.
|
logDeprecatedSetting, logRemovedSetting, nodeName
public static final java.lang.String UPDATE_RESTORE_ACTION_NAME
@Inject public RestoreService(Settings settings, ClusterService clusterService, RepositoriesService repositoriesService, TransportService transportService, AllocationService allocationService, MetaDataCreateIndexService createIndexService, MetaDataIndexUpgradeService metaDataIndexUpgradeService, ClusterSettings clusterSettings)
public void restoreSnapshot(RestoreService.RestoreRequest request, ActionListener<RestoreInfo> listener)
request
- restore requestlistener
- restore listenerpublic void indexShardRestoreCompleted(Snapshot snapshot, ShardId shardId)
IndexShard
to notify
RestoreService
about shard restore completion.snapshot
- snapshotshardId
- shard idpublic void failRestore(Snapshot snapshot, ShardId shardId)
public static void checkIndexClosing(ClusterState currentState, java.util.Set<IndexMetaData> indices)
public void addListener(ActionListener<RestoreService.RestoreCompletionResponse> listener)
This listener is called for each snapshot that finishes restore operation in the cluster. It's responsibility of the listener to decide if it's called for the appropriate snapshot or not.
listener
- restore completion listenerpublic void removeListener(ActionListener<RestoreService.RestoreCompletionResponse> listener)
This listener is called for each snapshot that finishes restore operation in the cluster.
listener
- restore completion listenerpublic void clusterChanged(ClusterChangedEvent event)
ClusterStateListener
clusterChanged
in interface ClusterStateListener
public static boolean isRepositoryInUse(ClusterState clusterState, java.lang.String repository)
clusterState
- cluster staterepository
- repository id