@@ -263,7 +263,7 @@ public ClusterState execute(ClusterState currentState) {
263263 null );
264264 snapshots = new SnapshotsInProgress (newSnapshot );
265265 } else {
266- throw new ConcurrentSnapshotExecutionException (repositoryName , snapshotName , "a snapshot is already running" );
266+ throw new ConcurrentSnapshotExecutionException (repositoryName , snapshotName , " a snapshot is already running" );
267267 }
268268 return ClusterState .builder (currentState ).putCustom (SnapshotsInProgress .TYPE , snapshots ).build ();
269269 }
@@ -363,6 +363,8 @@ private void beginSnapshot(final ClusterState clusterState,
363363
364364 repository .initializeSnapshot (snapshot .snapshot ().getSnapshotId (), snapshot .indices (), metaData );
365365 snapshotCreated = true ;
366+
367+ logger .info ("snapshot [{}] started" , snapshot .snapshot ());
366368 if (snapshot .indices ().isEmpty ()) {
367369 // No indices in this snapshot - we are done
368370 userCreateSnapshotListener .onResponse ();
@@ -947,35 +949,33 @@ void endSnapshot(SnapshotsInProgress.Entry entry) {
947949 * @param failure failure reason or null if snapshot was successful
948950 */
949951 private void endSnapshot (final SnapshotsInProgress .Entry entry , final String failure ) {
950- threadPool .executor (ThreadPool .Names .SNAPSHOT ).execute (new Runnable () {
951- @ Override
952- public void run () {
953- final Snapshot snapshot = entry .snapshot ();
954- try {
955- final Repository repository = repositoriesService .repository (snapshot .getRepository ());
956- logger .trace ("[{}] finalizing snapshot in repository, state: [{}], failure[{}]" , snapshot , entry .state (), failure );
957- ArrayList <SnapshotShardFailure > shardFailures = new ArrayList <>();
958- for (ObjectObjectCursor <ShardId , ShardSnapshotStatus > shardStatus : entry .shards ()) {
959- ShardId shardId = shardStatus .key ;
960- ShardSnapshotStatus status = shardStatus .value ;
961- if (status .state ().failed ()) {
962- shardFailures .add (new SnapshotShardFailure (status .nodeId (), shardId , status .reason ()));
963- }
952+ threadPool .executor (ThreadPool .Names .SNAPSHOT ).execute (() -> {
953+ final Snapshot snapshot = entry .snapshot ();
954+ try {
955+ final Repository repository = repositoriesService .repository (snapshot .getRepository ());
956+ logger .trace ("[{}] finalizing snapshot in repository, state: [{}], failure[{}]" , snapshot , entry .state (), failure );
957+ ArrayList <SnapshotShardFailure > shardFailures = new ArrayList <>();
958+ for (ObjectObjectCursor <ShardId , ShardSnapshotStatus > shardStatus : entry .shards ()) {
959+ ShardId shardId = shardStatus .key ;
960+ ShardSnapshotStatus status = shardStatus .value ;
961+ if (status .state ().failed ()) {
962+ shardFailures .add (new SnapshotShardFailure (status .nodeId (), shardId , status .reason ()));
964963 }
965- SnapshotInfo snapshotInfo = repository .finalizeSnapshot (
966- snapshot .getSnapshotId (),
967- entry .indices (),
968- entry .startTime (),
969- failure ,
970- entry .shards ().size (),
971- Collections .unmodifiableList (shardFailures ),
972- entry .getRepositoryStateId (),
973- entry .includeGlobalState ());
974- removeSnapshotFromClusterState (snapshot , snapshotInfo , null );
975- } catch (Exception e ) {
976- logger .warn ((Supplier <?>) () -> new ParameterizedMessage ("[{}] failed to finalize snapshot" , snapshot ), e );
977- removeSnapshotFromClusterState (snapshot , null , e );
978964 }
965+ SnapshotInfo snapshotInfo = repository .finalizeSnapshot (
966+ snapshot .getSnapshotId (),
967+ entry .indices (),
968+ entry .startTime (),
969+ failure ,
970+ entry .shards ().size (),
971+ Collections .unmodifiableList (shardFailures ),
972+ entry .getRepositoryStateId (),
973+ entry .includeGlobalState ());
974+ removeSnapshotFromClusterState (snapshot , snapshotInfo , null );
975+ logger .info ("snapshot [{}] completed with state [{}]" , snapshot , snapshotInfo .state ());
976+ } catch (Exception e ) {
977+ logger .warn ((Supplier <?>) () -> new ParameterizedMessage ("[{}] failed to finalize snapshot" , snapshot ), e );
978+ removeSnapshotFromClusterState (snapshot , null , e );
979979 }
980980 });
981981 }
0 commit comments