public class SnapshotsService extends AbstractLifecycleComponent<SnapshotsService> implements ClusterStateListener
createSnapshot(SnapshotRequest, CreateSnapshotListener) is called and makes sure that no snapshots is currently running
and registers the new snapshot in cluster statebeginSnapshot(ClusterState, SnapshotMetaData.Entry, boolean, CreateSnapshotListener) method
kicks in and initializes the snapshot in the repository and then populates list of shards that needs to be snapshotted in cluster stateprocessIndexShardSnapshots(org.elasticsearch.cluster.ClusterChangedEvent) methodupdateIndexShardSnapshotStatus(UpdateIndexShardSnapshotStatusRequest) methodinnerUpdateSnapshotState(org.elasticsearch.snapshots.SnapshotsService.UpdateIndexShardSnapshotStatusRequest) method marks the snapshot as completedendSnapshot(SnapshotMetaData.Entry) finalizes snapshot in the repository,
notifies all snapshotCompletionListeners that snapshot is completed, and finally calls removeSnapshotFromClusterState(SnapshotId, SnapshotInfo, Throwable) to remove snapshot from cluster state| Modifier and Type | Class and Description |
|---|---|
static interface |
SnapshotsService.CreateSnapshotListener
Listener for create snapshot operation
|
static interface |
SnapshotsService.DeleteSnapshotListener
Listener for delete snapshot operation
|
static interface |
SnapshotsService.SnapshotCompletionListener |
static class |
SnapshotsService.SnapshotRequest
Snapshot creation request
|
| Modifier and Type | Field and Description |
|---|---|
static String |
UPDATE_SNAPSHOT_ACTION_NAME |
lifecyclecomponentSettings, logger, settings| Constructor and Description |
|---|
SnapshotsService(Settings settings,
ClusterService clusterService,
RepositoriesService repositoriesService,
ThreadPool threadPool,
IndicesService indicesService,
TransportService transportService) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(SnapshotsService.SnapshotCompletionListener listener)
Adds snapshot completion listener
|
void |
clusterChanged(ClusterChangedEvent event)
Called when cluster state changes.
|
void |
createSnapshot(SnapshotsService.SnapshotRequest request,
SnapshotsService.CreateSnapshotListener listener)
Initializes the snapshotting process.
|
com.google.common.collect.ImmutableList<SnapshotMetaData.Entry> |
currentSnapshots(String repository,
String[] snapshots)
Returns status of the currently running snapshots
|
com.google.common.collect.ImmutableMap<ShardId,IndexShardSnapshotStatus> |
currentSnapshotShards(SnapshotId snapshotId)
Returns status of shards that are snapshotted on the node and belong to the given snapshot
|
void |
deleteSnapshot(SnapshotId snapshotId,
SnapshotsService.DeleteSnapshotListener listener)
Deletes snapshot from repository.
|
protected void |
doClose() |
protected void |
doStart() |
protected void |
doStop() |
static boolean |
isRepositoryInUse(ClusterState clusterState,
String repository)
Checks if a repository is currently in use by one of the snapshots
|
void |
removeListener(SnapshotsService.SnapshotCompletionListener listener)
Removes snapshot completion listener
|
Snapshot |
snapshot(SnapshotId snapshotId)
Retrieves snapshot from repository
|
com.google.common.collect.ImmutableList<Snapshot> |
snapshots(String repositoryName)
Returns a list of snapshots from repository sorted by snapshot creation date
|
com.google.common.collect.ImmutableMap<ShardId,IndexShardSnapshotStatus> |
snapshotShards(SnapshotId snapshotId)
Returns status of shards currently finished snapshots
|
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stopnodeNamepublic static final String UPDATE_SNAPSHOT_ACTION_NAME
@Inject public SnapshotsService(Settings settings, ClusterService clusterService, RepositoriesService repositoriesService, ThreadPool threadPool, IndicesService indicesService, TransportService transportService)
public Snapshot snapshot(SnapshotId snapshotId)
snapshotId - snapshot idSnapshotMissingException - if snapshot is not foundpublic com.google.common.collect.ImmutableList<Snapshot> snapshots(String repositoryName)
repositoryName - repository namepublic void createSnapshot(SnapshotsService.SnapshotRequest request, SnapshotsService.CreateSnapshotListener listener)
request - snapshot requestlistener - snapshot creation listenerpublic com.google.common.collect.ImmutableList<SnapshotMetaData.Entry> currentSnapshots(String repository, String[] snapshots)
This method is executed on master node
repository - repository idsnapshots - optional list of snapshots that will be used as a filterpublic com.google.common.collect.ImmutableMap<ShardId,IndexShardSnapshotStatus> currentSnapshotShards(SnapshotId snapshotId)
This method is executed on data node
snapshotId - snapshot idpublic com.google.common.collect.ImmutableMap<ShardId,IndexShardSnapshotStatus> snapshotShards(SnapshotId snapshotId)
This method is executed on master node and it's complimentary to the currentSnapshotShards(SnapshotId) becuase it
returns simliar information but for already finished snapshots.
snapshotId - snapshot idpublic void clusterChanged(ClusterChangedEvent event)
ClusterStateListenerclusterChanged in interface ClusterStateListenerpublic void deleteSnapshot(SnapshotId snapshotId, SnapshotsService.DeleteSnapshotListener listener)
snapshotId - snapshot idlistener - listenerpublic static boolean isRepositoryInUse(ClusterState clusterState, String repository)
clusterState - cluster staterepository - repository idpublic void addListener(SnapshotsService.SnapshotCompletionListener listener)
listener - listenerpublic void removeListener(SnapshotsService.SnapshotCompletionListener listener)
listener - listenerprotected void doStart()
throws ElasticsearchException
doStart in class AbstractLifecycleComponent<SnapshotsService>ElasticsearchExceptionprotected void doStop()
throws ElasticsearchException
doStop in class AbstractLifecycleComponent<SnapshotsService>ElasticsearchExceptionprotected void doClose()
throws ElasticsearchException
doClose in class AbstractLifecycleComponent<SnapshotsService>ElasticsearchExceptionCopyright © 2009–2016. All rights reserved.