@@ -362,39 +362,39 @@ private void loadRepositoryData(
362362 delegate .onResponse (new SnapshotsStatusResponse (Collections .unmodifiableList (builder )));
363363 } else {
364364 final List <SnapshotStatus > threadSafeBuilder = Collections .synchronizedList (builder );
365- repositoriesService .repository (projectId , repositoryName )
366- .getSnapshotInfo (snapshotIdsToLoad , true , task ::isCancelled , snapshotInfo -> {
367- List <SnapshotIndexShardStatus > shardStatusBuilder = new ArrayList <>();
368- final Map <ShardId , IndexShardSnapshotStatus .Copy > shardStatuses ;
369- shardStatuses = snapshotShards (projectId , repositoryName , repositoryData , task , snapshotInfo );
370- // an exception here stops further fetches of snapshotInfo since context is fail-fast
371- for (final var shardStatus : shardStatuses .entrySet ()) {
372- IndexShardSnapshotStatus .Copy lastSnapshotStatus = shardStatus .getValue ();
373- shardStatusBuilder .add (new SnapshotIndexShardStatus (shardStatus .getKey (), lastSnapshotStatus ));
374- }
375- final SnapshotsInProgress .State state = switch (snapshotInfo .state ()) {
376- case FAILED -> SnapshotsInProgress .State .FAILED ;
377- case SUCCESS , PARTIAL ->
378- // Both of these means the snapshot has completed.
379- SnapshotsInProgress .State .SUCCESS ;
380- default -> throw new IllegalArgumentException ("Unexpected snapshot state " + snapshotInfo .state ());
381- };
382- final long startTime = snapshotInfo .startTime ();
383- final long endTime = snapshotInfo .endTime ();
384- assert endTime >= startTime || (endTime == 0L && snapshotInfo .state ().completed () == false )
385- : "Inconsistent timestamps found in SnapshotInfo [" + snapshotInfo + "]" ;
386- threadSafeBuilder .add (
387- new SnapshotStatus (
388- new Snapshot (projectId , repositoryName , snapshotInfo .snapshotId ()),
389- state ,
390- Collections .unmodifiableList (shardStatusBuilder ),
391- snapshotInfo .includeGlobalState (),
392- startTime ,
393- // Use current time to calculate overall runtime for in-progress snapshots that have endTime == 0
394- (endTime == 0 ? threadPool .absoluteTimeInMillis () : endTime ) - startTime
395- )
396- );
397- }, delegate .map (v -> new SnapshotsStatusResponse (List .copyOf (threadSafeBuilder ))));
365+ final Repository repository = repositoriesService .repository (projectId , repositoryName );
366+ repository .getSnapshotInfo (snapshotIdsToLoad , true , task ::isCancelled , snapshotInfo -> {
367+ List <SnapshotIndexShardStatus > shardStatusBuilder = new ArrayList <>();
368+ final Map <ShardId , IndexShardSnapshotStatus .Copy > shardStatuses ;
369+ shardStatuses = snapshotShards (projectId , repositoryName , repositoryData , task , snapshotInfo );
370+ // an exception here stops further fetches of snapshotInfo since context is fail-fast
371+ for (final var shardStatus : shardStatuses .entrySet ()) {
372+ IndexShardSnapshotStatus .Copy lastSnapshotStatus = shardStatus .getValue ();
373+ shardStatusBuilder .add (new SnapshotIndexShardStatus (shardStatus .getKey (), lastSnapshotStatus ));
374+ }
375+ final SnapshotsInProgress .State state = switch (snapshotInfo .state ()) {
376+ case FAILED -> SnapshotsInProgress .State .FAILED ;
377+ case SUCCESS , PARTIAL ->
378+ // Both of these means the snapshot has completed.
379+ SnapshotsInProgress .State .SUCCESS ;
380+ default -> throw new IllegalArgumentException ("Unexpected snapshot state " + snapshotInfo .state ());
381+ };
382+ final long startTime = snapshotInfo .startTime ();
383+ final long endTime = snapshotInfo .endTime ();
384+ assert endTime >= startTime || (endTime == 0L && snapshotInfo .state ().completed () == false )
385+ : "Inconsistent timestamps found in SnapshotInfo [" + snapshotInfo + "]" ;
386+ threadSafeBuilder .add (
387+ new SnapshotStatus (
388+ new Snapshot (projectId , repositoryName , snapshotInfo .snapshotId ()),
389+ state ,
390+ Collections .unmodifiableList (shardStatusBuilder ),
391+ snapshotInfo .includeGlobalState (),
392+ startTime ,
393+ // Use current time to calculate overall runtime for in-progress snapshots that have endTime == 0
394+ (endTime == 0 ? threadPool .absoluteTimeInMillis () : endTime ) - startTime
395+ )
396+ );
397+ }, delegate .map (v -> new SnapshotsStatusResponse (List .copyOf (threadSafeBuilder ))));
398398 }
399399 }));
400400 }
0 commit comments