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
StoreRecoveryService.recover(IndexShard, boolean, StoreRecoveryService.RecoveryListener)
method, which detects that shard should be restored from snapshot rather than recovered from gateway by looking
at the ShardRouting.restoreSource()
property. If this property is not null
recover
method uses StoreRecoveryService.restore(org.elasticsearch.index.shard.IndexShard, org.elasticsearch.indices.recovery.RecoveryState)
method to start shard restore process.
At the end of the successful restore process IndexShardSnapshotAndRestoreService
calls indexShardRestoreCompleted(SnapshotId, 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 String |
UPDATE_RESTORE_ACTION_NAME |
deprecationLogger, logger, settings
Constructor and Description |
---|
RestoreService(Settings settings,
ClusterService clusterService,
RepositoriesService repositoriesService,
TransportService transportService,
AllocationService allocationService,
MetaDataCreateIndexService createIndexService,
DynamicSettings dynamicSettings,
MetaDataIndexUpgradeService metaDataIndexUpgradeService) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ActionListener<RestoreService.RestoreCompletionResponse> listener)
Adds restore completion listener
|
void |
clusterChanged(ClusterChangedEvent event)
Called when cluster state changes.
|
void |
failRestore(SnapshotId snapshotId,
ShardId shardId)
Fails the given snapshot restore operation for the given shard
|
void |
indexShardRestoreCompleted(SnapshotId snapshotId,
ShardId shardId)
This method is used by
StoreRecoveryService to notify
RestoreService about shard restore completion. |
static boolean |
isRepositoryInUse(ClusterState clusterState,
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 String UPDATE_RESTORE_ACTION_NAME
@Inject public RestoreService(Settings settings, ClusterService clusterService, RepositoriesService repositoriesService, TransportService transportService, AllocationService allocationService, MetaDataCreateIndexService createIndexService, @ClusterDynamicSettings DynamicSettings dynamicSettings, MetaDataIndexUpgradeService metaDataIndexUpgradeService)
public void restoreSnapshot(RestoreService.RestoreRequest request, ActionListener<RestoreInfo> listener)
request
- restore requestlistener
- restore listenerpublic void indexShardRestoreCompleted(SnapshotId snapshotId, ShardId shardId)
StoreRecoveryService
to notify
RestoreService
about shard restore completion.snapshotId
- snapshot idshardId
- shard idpublic void failRestore(SnapshotId snapshotId, ShardId shardId)
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, String repository)
clusterState
- cluster staterepository
- repository idCopyright © 2009–2016. All rights reserved.