Class RestoreService

java.lang.Object
org.elasticsearch.snapshots.RestoreService
All Implemented Interfaces:
ClusterStateApplier

public class RestoreService extends Object implements ClusterStateApplier
Service responsible for restoring snapshots

Restore 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, 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(org.elasticsearch.repositories.Repository, org.elasticsearch.action.ActionListener<java.lang.Boolean>) )} 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 removeCompletedRestoresFromClusterState(), which removes RestoreInProgress when all shards are completed. In case of restore failure a normal recovery fail-over process kicks in.