199
199
import static org .opensearch .index .remote .RemoteStoreEnums .PathHashAlgorithm .FNV_1A_COMPOSITE_1 ;
200
200
import static org .opensearch .index .snapshots .blobstore .BlobStoreIndexShardSnapshot .FileInfo .canonicalName ;
201
201
import static org .opensearch .repositories .blobstore .ChecksumBlobStoreFormat .SNAPSHOT_ONLY_FORMAT_PARAMS ;
202
+ import static org .opensearch .snapshots .SnapshotShardPaths .getIndexId ;
202
203
203
204
/**
204
205
* BlobStore - based implementation of Snapshot Repository
@@ -2293,7 +2294,10 @@ private void remoteTranslogCleanupAsync(
2293
2294
* @return List of matching shard paths
2294
2295
*/
2295
2296
private List <String > findMatchingShardPaths (String indexId , Map <String , BlobMetadata > snapshotShardPaths ) {
2296
- return snapshotShardPaths .keySet ().stream ().filter (s -> s .startsWith (indexId )).collect (Collectors .toList ());
2297
+ return snapshotShardPaths .keySet ()
2298
+ .stream ()
2299
+ .filter (s -> (s .startsWith (indexId ) || s .startsWith (SnapshotShardPaths .FILE_PREFIX + indexId )))
2300
+ .collect (Collectors .toList ());
2297
2301
}
2298
2302
2299
2303
/**
@@ -2546,11 +2550,11 @@ public void finalizeSnapshot(
2546
2550
*/
2547
2551
private void cleanupRedundantSnapshotShardPaths (Set <String > updatedShardPathsIndexIds ) {
2548
2552
Set <String > updatedIndexIds = updatedShardPathsIndexIds .stream ()
2549
- .map (s -> s .split ("\\ " + SnapshotShardPaths .DELIMITER )[0 ])
2553
+ .map (s -> getIndexId ( s .split ("\\ " + SnapshotShardPaths .DELIMITER )[0 ]) )
2550
2554
.collect (Collectors .toSet ());
2551
2555
Set <String > indexIdShardPaths = getSnapshotShardPaths ().keySet ();
2552
2556
List <String > staleShardPaths = indexIdShardPaths .stream ().filter (s -> updatedShardPathsIndexIds .contains (s ) == false ).filter (s -> {
2553
- String indexId = s .split ("\\ " + SnapshotShardPaths .DELIMITER )[0 ];
2557
+ String indexId = getIndexId ( s .split ("\\ " + SnapshotShardPaths .DELIMITER )[0 ]) ;
2554
2558
return updatedIndexIds .contains (indexId );
2555
2559
}).collect (Collectors .toList ());
2556
2560
try {
@@ -2595,7 +2599,7 @@ String writeIndexShardPaths(IndexId indexId, SnapshotId snapshotId, int shardCou
2595
2599
List <String > paths = getShardPaths (indexId , shardCount );
2596
2600
int pathType = indexId .getShardPathType ();
2597
2601
int pathHashAlgorithm = FNV_1A_COMPOSITE_1 .getCode ();
2598
- String blobName = String .join (
2602
+ String name = String .join (
2599
2603
SnapshotShardPaths .DELIMITER ,
2600
2604
indexId .getId (),
2601
2605
indexId .getName (),
@@ -2611,9 +2615,9 @@ String writeIndexShardPaths(IndexId indexId, SnapshotId snapshotId, int shardCou
2611
2615
PathType .fromCode (pathType ),
2612
2616
PathHashAlgorithm .fromCode (pathHashAlgorithm )
2613
2617
);
2614
- SNAPSHOT_SHARD_PATHS_FORMAT .write (shardPaths , snapshotShardPathBlobContainer (), blobName );
2618
+ SNAPSHOT_SHARD_PATHS_FORMAT .write (shardPaths , snapshotShardPathBlobContainer (), name );
2615
2619
logShardPathsOperationSuccess (indexId , snapshotId );
2616
- return blobName ;
2620
+ return SnapshotShardPaths . FILE_PREFIX + name ;
2617
2621
} catch (IOException e ) {
2618
2622
logShardPathsOperationWarning (indexId , snapshotId , e );
2619
2623
}
0 commit comments