23
23
import org .opensearch .cluster .routing .RecoverySource ;
24
24
import org .opensearch .cluster .routing .allocation .command .MoveAllocationCommand ;
25
25
import org .opensearch .common .Priority ;
26
+ import org .opensearch .common .blobstore .BlobPath ;
26
27
import org .opensearch .common .settings .Settings ;
27
28
import org .opensearch .common .unit .TimeValue ;
28
29
import org .opensearch .common .util .concurrent .BufferedAsyncIOProcessor ;
57
58
58
59
import static org .opensearch .cluster .metadata .IndexMetadata .SETTING_NUMBER_OF_REPLICAS ;
59
60
import static org .opensearch .cluster .metadata .IndexMetadata .SETTING_NUMBER_OF_SHARDS ;
61
+ import static org .opensearch .index .remote .RemoteStoreEnums .DataCategory .SEGMENTS ;
62
+ import static org .opensearch .index .remote .RemoteStoreEnums .DataType .DATA ;
63
+ import static org .opensearch .index .remote .RemoteStoreEnums .DataType .METADATA ;
60
64
import static org .opensearch .indices .RemoteStoreSettings .CLUSTER_REMOTE_TRANSLOG_BUFFER_INTERVAL_SETTING ;
65
+ import static org .opensearch .test .OpenSearchTestCase .getShardLevelBlobPath ;
61
66
import static org .opensearch .test .hamcrest .OpenSearchAssertions .assertAcked ;
62
67
import static org .opensearch .test .hamcrest .OpenSearchAssertions .assertHitCount ;
63
68
import static org .hamcrest .Matchers .comparesEqualTo ;
@@ -182,13 +187,9 @@ public void testStaleCommitDeletionWithInvokeFlush() throws Exception {
182
187
createIndex (INDEX_NAME , remoteStoreIndexSettings (1 , 10000l , -1 ));
183
188
int numberOfIterations = randomIntBetween (5 , 15 );
184
189
indexData (numberOfIterations , true , INDEX_NAME );
185
- String indexUUID = client ().admin ()
186
- .indices ()
187
- .prepareGetSettings (INDEX_NAME )
188
- .get ()
189
- .getSetting (INDEX_NAME , IndexMetadata .SETTING_INDEX_UUID );
190
- Path indexPath = Path .of (String .valueOf (segmentRepoPath ), indexUUID , "/0/segments/metadata" );
191
-
190
+ String shardPath = getShardLevelBlobPath (client (), INDEX_NAME , BlobPath .cleanPath (), "0" , SEGMENTS , METADATA ).buildAsString ();
191
+ Path indexPath = Path .of (segmentRepoPath + "/" + shardPath );
192
+ ;
192
193
IndexShard indexShard = getIndexShard (dataNode , INDEX_NAME );
193
194
int lastNMetadataFilesToKeep = indexShard .getRemoteStoreSettings ().getMinRemoteSegmentMetadataFiles ();
194
195
// Delete is async.
@@ -212,12 +213,8 @@ public void testStaleCommitDeletionWithoutInvokeFlush() throws Exception {
212
213
createIndex (INDEX_NAME , remoteStoreIndexSettings (1 , 10000l , -1 ));
213
214
int numberOfIterations = randomIntBetween (5 , 15 );
214
215
indexData (numberOfIterations , false , INDEX_NAME );
215
- String indexUUID = client ().admin ()
216
- .indices ()
217
- .prepareGetSettings (INDEX_NAME )
218
- .get ()
219
- .getSetting (INDEX_NAME , IndexMetadata .SETTING_INDEX_UUID );
220
- Path indexPath = Path .of (String .valueOf (segmentRepoPath ), indexUUID , "/0/segments/metadata" );
216
+ String shardPath = getShardLevelBlobPath (client (), INDEX_NAME , BlobPath .cleanPath (), "0" , SEGMENTS , METADATA ).buildAsString ();
217
+ Path indexPath = Path .of (segmentRepoPath + "/" + shardPath );
221
218
int actualFileCount = getFileCount (indexPath );
222
219
// We also allow (numberOfIterations + 1) as index creation also triggers refresh.
223
220
MatcherAssert .assertThat (actualFileCount , is (oneOf (numberOfIterations - 1 , numberOfIterations , numberOfIterations + 1 )));
@@ -231,12 +228,8 @@ public void testStaleCommitDeletionWithMinSegmentFiles_3() throws Exception {
231
228
createIndex (INDEX_NAME , remoteStoreIndexSettings (1 , 10000l , -1 ));
232
229
int numberOfIterations = randomIntBetween (5 , 15 );
233
230
indexData (numberOfIterations , true , INDEX_NAME );
234
- String indexUUID = client ().admin ()
235
- .indices ()
236
- .prepareGetSettings (INDEX_NAME )
237
- .get ()
238
- .getSetting (INDEX_NAME , IndexMetadata .SETTING_INDEX_UUID );
239
- Path indexPath = Path .of (String .valueOf (segmentRepoPath ), indexUUID , "/0/segments/metadata" );
231
+ String shardPath = getShardLevelBlobPath (client (), INDEX_NAME , BlobPath .cleanPath (), "0" , SEGMENTS , METADATA ).buildAsString ();
232
+ Path indexPath = Path .of (segmentRepoPath + "/" + shardPath );
240
233
int actualFileCount = getFileCount (indexPath );
241
234
// We also allow (numberOfIterations + 1) as index creation also triggers refresh.
242
235
MatcherAssert .assertThat (actualFileCount , is (oneOf (4 )));
@@ -250,12 +243,9 @@ public void testStaleCommitDeletionWithMinSegmentFiles_Disabled() throws Excepti
250
243
createIndex (INDEX_NAME , remoteStoreIndexSettings (1 , 10000l , -1 ));
251
244
int numberOfIterations = randomIntBetween (12 , 18 );
252
245
indexData (numberOfIterations , true , INDEX_NAME );
253
- String indexUUID = client ().admin ()
254
- .indices ()
255
- .prepareGetSettings (INDEX_NAME )
256
- .get ()
257
- .getSetting (INDEX_NAME , IndexMetadata .SETTING_INDEX_UUID );
258
- Path indexPath = Path .of (String .valueOf (segmentRepoPath ), indexUUID , "/0/segments/metadata" );
246
+ String shardPath = getShardLevelBlobPath (client (), INDEX_NAME , BlobPath .cleanPath (), "0" , SEGMENTS , METADATA ).buildAsString ();
247
+ Path indexPath = Path .of (segmentRepoPath + "/" + shardPath );
248
+ ;
259
249
int actualFileCount = getFileCount (indexPath );
260
250
// We also allow (numberOfIterations + 1) as index creation also triggers refresh.
261
251
MatcherAssert .assertThat (actualFileCount , is (oneOf (numberOfIterations + 1 )));
@@ -589,12 +579,8 @@ public void testFallbackToNodeToNodeSegmentCopy() throws Exception {
589
579
flushAndRefresh (INDEX_NAME );
590
580
591
581
// 3. Delete data from remote segment store
592
- String indexUUID = client ().admin ()
593
- .indices ()
594
- .prepareGetSettings (INDEX_NAME )
595
- .get ()
596
- .getSetting (INDEX_NAME , IndexMetadata .SETTING_INDEX_UUID );
597
- Path segmentDataPath = Path .of (String .valueOf (segmentRepoPath ), indexUUID , "/0/segments/data" );
582
+ String shardPath = getShardLevelBlobPath (client (), INDEX_NAME , BlobPath .cleanPath (), "0" , SEGMENTS , DATA ).buildAsString ();
583
+ Path segmentDataPath = Path .of (segmentRepoPath + "/" + shardPath );
598
584
599
585
try (Stream <Path > files = Files .list (segmentDataPath )) {
600
586
files .forEach (p -> {
0 commit comments