public class RestoreService extends AbstractComponent implements ClusterStateListener
#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 RestoreMetaData
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
IndexShardGatewayService.recover(boolean, org.elasticsearch.index.gateway.IndexShardGatewayService.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 IndexShardSnapshotAndRestoreService.restore(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 RestoreMetaData
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
|
Modifier and Type | Field and Description |
---|---|
static String |
UPDATE_RESTORE_ACTION_NAME |
componentSettings, logger, settings
Constructor and Description |
---|
RestoreService(Settings settings,
ClusterService clusterService,
RepositoriesService repositoriesService,
TransportService transportService,
AllocationService allocationService,
MetaDataCreateIndexService createIndexService,
DynamicSettings dynamicSettings) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ActionListener<RestoreService.RestoreCompletionResponse> listener)
Adds restore completion listener
This listener is called for each snapshot that finishes restore operation in the cluster.
|
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
IndexShardSnapshotAndRestoreService 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
This listener is called for each snapshot that finishes restore operation in the cluster.
|
void |
restoreSnapshot(RestoreService.RestoreRequest request,
ActionListener<RestoreInfo> listener)
Restores snapshot specified in the restore request.
|
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)
public void restoreSnapshot(RestoreService.RestoreRequest request, ActionListener<RestoreInfo> listener)
request
- restore requestlistener
- restore listenerpublic void indexShardRestoreCompleted(SnapshotId snapshotId, ShardId shardId)
IndexShardSnapshotAndRestoreService
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)
listener
- restore completion listenerpublic void removeListener(ActionListener<RestoreService.RestoreCompletionResponse> listener)
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–2015. All rights reserved.