diff --git a/server/src/main/java/org/opensearch/cluster/routing/remote/InternalRemoteRoutingTableService.java b/server/src/main/java/org/opensearch/cluster/routing/remote/InternalRemoteRoutingTableService.java index dcf106914c571..01cd5c0b89a7d 100644 --- a/server/src/main/java/org/opensearch/cluster/routing/remote/InternalRemoteRoutingTableService.java +++ b/server/src/main/java/org/opensearch/cluster/routing/remote/InternalRemoteRoutingTableService.java @@ -158,7 +158,7 @@ public CheckedRunnable getIndexRoutingAsyncAction( BlobPath indexRoutingPath = clusterBasePath.add(INDEX_ROUTING_PATH_TOKEN); BlobPath path = pathType.path( - RemoteStorePathStrategy.PathInput.builder().basePath(indexRoutingPath).indexUUID(indexRouting.getIndex().getUUID()).build(), + RemoteStorePathStrategy.BasePathInput.builder().basePath(indexRoutingPath).indexUUID(indexRouting.getIndex().getUUID()).build(), pathHashAlgo ); final BlobContainer blobContainer = blobStoreRepository.blobStore().blobContainer(path); diff --git a/server/src/main/java/org/opensearch/index/remote/RemoteIndexPath.java b/server/src/main/java/org/opensearch/index/remote/RemoteIndexPath.java index 899ff16c9d607..dfa5b7afc9c25 100644 --- a/server/src/main/java/org/opensearch/index/remote/RemoteIndexPath.java +++ b/server/src/main/java/org/opensearch/index/remote/RemoteIndexPath.java @@ -18,8 +18,8 @@ import org.opensearch.index.remote.RemoteStoreEnums.DataType; import org.opensearch.index.remote.RemoteStoreEnums.PathHashAlgorithm; import org.opensearch.index.remote.RemoteStoreEnums.PathType; +import org.opensearch.index.remote.RemoteStorePathStrategy.BasePathInput; import org.opensearch.index.remote.RemoteStorePathStrategy.PathInput; -import org.opensearch.index.remote.RemoteStorePathStrategy.ShardDataPathInput; import java.io.IOException; import java.util.Collections; @@ -142,7 +142,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws DataCategory dataCategory = entry.getKey(); for (DataType type : entry.getValue()) { for (int shardNo = 0; shardNo < shardCount; shardNo++) { - PathInput pathInput = ShardDataPathInput.builder() + BasePathInput pathInput = PathInput.builder() .basePath(new BlobPath().add(basePath)) .indexUUID(indexUUID) .shardId(Integer.toString(shardNo)) diff --git a/server/src/main/java/org/opensearch/index/remote/RemoteStoreEnums.java b/server/src/main/java/org/opensearch/index/remote/RemoteStoreEnums.java index b0376c97e6994..6118650f1924d 100644 --- a/server/src/main/java/org/opensearch/index/remote/RemoteStoreEnums.java +++ b/server/src/main/java/org/opensearch/index/remote/RemoteStoreEnums.java @@ -13,7 +13,7 @@ import org.opensearch.common.annotation.PublicApi; import org.opensearch.common.blobstore.BlobPath; import org.opensearch.common.hash.FNV1a; -import org.opensearch.index.remote.RemoteStorePathStrategy.PathInput; +import org.opensearch.index.remote.RemoteStorePathStrategy.BasePathInput; import java.util.HashMap; import java.util.Locale; @@ -92,7 +92,7 @@ public String getName() { public enum PathType { FIXED(0) { @Override - public BlobPath generatePath(PathInput pathInput, PathHashAlgorithm hashAlgorithm) { + public BlobPath generatePath(BasePathInput pathInput, PathHashAlgorithm hashAlgorithm) { assert Objects.isNull(hashAlgorithm) : "hashAlgorithm is expected to be null with fixed remote store path type"; // Hash algorithm is not used in FIXED path type return pathInput.basePath().add(pathInput.fixedSubPath()); @@ -105,7 +105,7 @@ boolean requiresHashAlgorithm() { }, HASHED_PREFIX(1) { @Override - public BlobPath generatePath(PathInput pathInput, PathHashAlgorithm hashAlgorithm) { + public BlobPath generatePath(BasePathInput pathInput, PathHashAlgorithm hashAlgorithm) { assert Objects.nonNull(hashAlgorithm) : "hashAlgorithm is expected to be non-null"; return BlobPath.cleanPath().add(hashAlgorithm.hash(pathInput)).add(pathInput.basePath()).add(pathInput.fixedSubPath()); } @@ -117,7 +117,7 @@ boolean requiresHashAlgorithm() { }, HASHED_INFIX(2) { @Override - public BlobPath generatePath(PathInput pathInput, PathHashAlgorithm hashAlgorithm) { + public BlobPath generatePath(BasePathInput pathInput, PathHashAlgorithm hashAlgorithm) { assert Objects.nonNull(hashAlgorithm) : "hashAlgorithm is expected to be non-null"; return pathInput.basePath().add(hashAlgorithm.hash(pathInput)).add(pathInput.fixedSubPath()); } @@ -170,12 +170,18 @@ public static PathType fromCode(int code) { * @param hashAlgorithm hashing algorithm. * @return the blob path for the path input. */ - public BlobPath path(PathInput pathInput, PathHashAlgorithm hashAlgorithm) { + public BlobPath path(BasePathInput pathInput, PathHashAlgorithm hashAlgorithm) { pathInput.assertIsValid(); return generatePath(pathInput, hashAlgorithm); } - protected abstract BlobPath generatePath(PathInput pathInput, PathHashAlgorithm hashAlgorithm); + // Added for BWC + public BlobPath path(RemoteStorePathStrategy.PathInput pathInput, PathHashAlgorithm hashAlgorithm) { + pathInput.assertIsValid(); + return generatePath(pathInput, hashAlgorithm); + } + + protected abstract BlobPath generatePath(BasePathInput pathInput, PathHashAlgorithm hashAlgorithm); abstract boolean requiresHashAlgorithm(); @@ -205,7 +211,7 @@ public enum PathHashAlgorithm { FNV_1A_BASE64(0) { @Override - String hash(PathInput pathInput) { + String hash(BasePathInput pathInput) { StringBuilder input = new StringBuilder(); for (String path : pathInput.fixedSubPath().toArray()) { input.append(path); @@ -220,7 +226,7 @@ String hash(PathInput pathInput) { */ FNV_1A_COMPOSITE_1(1) { @Override - String hash(PathInput pathInput) { + String hash(BasePathInput pathInput) { StringBuilder input = new StringBuilder(); for (String path : pathInput.fixedSubPath().toArray()) { input.append(path); @@ -264,7 +270,7 @@ public static PathHashAlgorithm fromCode(int code) { return CODE_TO_ENUM.get(code); } - abstract String hash(PathInput pathInput); + abstract String hash(BasePathInput pathInput); public static PathHashAlgorithm parseString(String pathHashAlgorithm) { try { diff --git a/server/src/main/java/org/opensearch/index/remote/RemoteStorePathStrategy.java b/server/src/main/java/org/opensearch/index/remote/RemoteStorePathStrategy.java index d0250790068f7..258d74d249f8d 100644 --- a/server/src/main/java/org/opensearch/index/remote/RemoteStorePathStrategy.java +++ b/server/src/main/java/org/opensearch/index/remote/RemoteStorePathStrategy.java @@ -67,10 +67,16 @@ public String toString() { return "RemoteStorePathStrategy{" + "type=" + type + ", hashAlgorithm=" + hashAlgorithm + '}'; } + public BlobPath generatePath(BasePathInput pathInput) { + return type.path(pathInput, hashAlgorithm); + } + + // Added for BWC public BlobPath generatePath(PathInput pathInput) { return type.path(pathInput, hashAlgorithm); } + /** * Wrapper class for the path input required to generate path for remote store uploads. This input is composed of * basePath and indexUUID. @@ -79,11 +85,17 @@ public BlobPath generatePath(PathInput pathInput) { */ @PublicApi(since = "2.14.0") @ExperimentalApi - public static class PathInput { + public static class BasePathInput { private final BlobPath basePath; private final String indexUUID; - public PathInput(Builder builder) { + //Adding for BWC + public BasePathInput(BlobPath basePath, String indexUUID) { + this.basePath = basePath; + this.indexUUID = indexUUID; + } + + public BasePathInput(Builder builder) { this.basePath = Objects.requireNonNull(builder.basePath); this.indexUUID = Objects.requireNonNull(builder.indexUUID); } @@ -101,7 +113,7 @@ BlobPath fixedSubPath() { } /** - * Returns a new builder for {@link PathInput}. + * Returns a new builder for {@link BasePathInput}. */ public static Builder builder() { return new Builder<>(); @@ -112,7 +124,7 @@ public void assertIsValid() { } /** - * Builder for {@link PathInput}. + * Builder for {@link BasePathInput}. * * @opensearch.internal */ @@ -136,8 +148,8 @@ protected T self() { return (T) this; } - public PathInput build() { - return new PathInput(this); + public BasePathInput build() { + return new BasePathInput(this); } } } @@ -150,12 +162,20 @@ public PathInput build() { */ @PublicApi(since = "2.14.0") @ExperimentalApi - public static class ShardDataPathInput extends PathInput { + public static class PathInput extends BasePathInput { private final String shardId; private final DataCategory dataCategory; private final DataType dataType; - public ShardDataPathInput(Builder builder) { + //Adding for BWC + public PathInput(BlobPath basePath, String indexUUID, String shardId, DataCategory dataCategory, DataType dataType) { + super(basePath, indexUUID); + this.shardId = shardId; + this.dataCategory = dataCategory; + this.dataType = dataType; + } + + public PathInput(Builder builder) { super(builder); this.shardId = Objects.requireNonNull(builder.shardId); this.dataCategory = Objects.requireNonNull(builder.dataCategory); @@ -186,20 +206,20 @@ BlobPath fixedSubPath() { } /** - * Returns a new builder for {@link ShardDataPathInput}. + * Returns a new builder for {@link PathInput}. */ public static Builder builder() { return new Builder(); } /** - * Builder for {@link ShardDataPathInput}. + * Builder for {@link PathInput}. * * @opensearch.internal */ @PublicApi(since = "2.14.0") @ExperimentalApi - public static class Builder extends PathInput.Builder { + public static class Builder extends BasePathInput.Builder { private String shardId; private DataCategory dataCategory; private DataType dataType; @@ -234,8 +254,8 @@ protected Builder self() { return this; } - public ShardDataPathInput build() { - return new ShardDataPathInput(this); + public PathInput build() { + return new PathInput(this); } } } diff --git a/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryFactory.java b/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryFactory.java index b965d7ce73ae6..e462f6d4ac011 100644 --- a/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryFactory.java +++ b/server/src/main/java/org/opensearch/index/store/RemoteSegmentStoreDirectoryFactory.java @@ -65,7 +65,7 @@ public Directory newDirectory(String repositoryName, String indexUUID, ShardId s BlobPath repositoryBasePath = blobStoreRepository.basePath(); String shardIdStr = String.valueOf(shardId.id()); - RemoteStorePathStrategy.ShardDataPathInput dataPathInput = RemoteStorePathStrategy.ShardDataPathInput.builder() + RemoteStorePathStrategy.PathInput dataPathInput = RemoteStorePathStrategy.PathInput.builder() .basePath(repositoryBasePath) .indexUUID(indexUUID) .shardId(shardIdStr) @@ -80,7 +80,7 @@ public Directory newDirectory(String repositoryName, String indexUUID, ShardId s blobStoreRepository::maybeRateLimitRemoteDownloadTransfers ); - RemoteStorePathStrategy.ShardDataPathInput mdPathInput = RemoteStorePathStrategy.ShardDataPathInput.builder() + RemoteStorePathStrategy.PathInput mdPathInput = RemoteStorePathStrategy.PathInput.builder() .basePath(repositoryBasePath) .indexUUID(indexUUID) .shardId(shardIdStr) diff --git a/server/src/main/java/org/opensearch/index/store/lockmanager/RemoteStoreLockManagerFactory.java b/server/src/main/java/org/opensearch/index/store/lockmanager/RemoteStoreLockManagerFactory.java index 993c1bbdf033f..45d466d3a8ce8 100644 --- a/server/src/main/java/org/opensearch/index/store/lockmanager/RemoteStoreLockManagerFactory.java +++ b/server/src/main/java/org/opensearch/index/store/lockmanager/RemoteStoreLockManagerFactory.java @@ -56,7 +56,7 @@ public static RemoteStoreMetadataLockManager newLockManager( assert repository instanceof BlobStoreRepository : "repository should be instance of BlobStoreRepository"; BlobPath repositoryBasePath = ((BlobStoreRepository) repository).basePath(); - RemoteStorePathStrategy.ShardDataPathInput lockFilesPathInput = RemoteStorePathStrategy.ShardDataPathInput.builder() + RemoteStorePathStrategy.PathInput lockFilesPathInput = RemoteStorePathStrategy.PathInput.builder() .basePath(repositoryBasePath) .indexUUID(indexUUID) .shardId(shardId) diff --git a/server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java b/server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java index c533a31c310c7..f29b6fba6537f 100644 --- a/server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java +++ b/server/src/main/java/org/opensearch/index/translog/RemoteFsTranslog.java @@ -304,7 +304,7 @@ public static TranslogTransferManager buildTranslogTransferManager( assert Objects.nonNull(pathStrategy); String indexUUID = shardId.getIndex().getUUID(); String shardIdStr = String.valueOf(shardId.id()); - RemoteStorePathStrategy.ShardDataPathInput dataPathInput = RemoteStorePathStrategy.ShardDataPathInput.builder() + RemoteStorePathStrategy.PathInput dataPathInput = RemoteStorePathStrategy.PathInput.builder() .basePath(blobStoreRepository.basePath()) .indexUUID(indexUUID) .shardId(shardIdStr) @@ -312,7 +312,7 @@ public static TranslogTransferManager buildTranslogTransferManager( .dataType(DATA) .build(); BlobPath dataPath = pathStrategy.generatePath(dataPathInput); - RemoteStorePathStrategy.ShardDataPathInput mdPathInput = RemoteStorePathStrategy.ShardDataPathInput.builder() + RemoteStorePathStrategy.PathInput mdPathInput = RemoteStorePathStrategy.PathInput.builder() .basePath(blobStoreRepository.basePath()) .indexUUID(indexUUID) .shardId(shardIdStr) diff --git a/server/src/test/java/org/opensearch/cluster/routing/remote/RemoteRoutingTableServiceTests.java b/server/src/test/java/org/opensearch/cluster/routing/remote/RemoteRoutingTableServiceTests.java index 8fd410e774332..1c4b97de8b7fd 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/remote/RemoteRoutingTableServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/remote/RemoteRoutingTableServiceTests.java @@ -548,7 +548,7 @@ private ClusterState createClusterState(String indexName) { private BlobPath getPath() { BlobPath indexRoutingPath = basePath.add(INDEX_ROUTING_PATH_TOKEN); return RemoteStoreEnums.PathType.HASHED_PREFIX.path( - RemoteStorePathStrategy.PathInput.builder().basePath(indexRoutingPath).indexUUID("uuid").build(), + RemoteStorePathStrategy.BasePathInput.builder().basePath(indexRoutingPath).indexUUID("uuid").build(), RemoteStoreEnums.PathHashAlgorithm.FNV_1A_BASE64 ); } diff --git a/server/src/test/java/org/opensearch/index/remote/RemoteStoreEnumsTests.java b/server/src/test/java/org/opensearch/index/remote/RemoteStoreEnumsTests.java index 481a0568ff0a7..c3f52f3976414 100644 --- a/server/src/test/java/org/opensearch/index/remote/RemoteStoreEnumsTests.java +++ b/server/src/test/java/org/opensearch/index/remote/RemoteStoreEnumsTests.java @@ -13,7 +13,7 @@ import org.opensearch.index.remote.RemoteStoreEnums.DataCategory; import org.opensearch.index.remote.RemoteStoreEnums.DataType; import org.opensearch.index.remote.RemoteStoreEnums.PathType; -import org.opensearch.index.remote.RemoteStorePathStrategy.ShardDataPathInput; +import org.opensearch.index.remote.RemoteStorePathStrategy.PathInput; import org.opensearch.test.OpenSearchTestCase; import java.util.ArrayList; @@ -70,7 +70,7 @@ public void testGeneratePathForFixedType() { String basePath = getPath(pathList) + indexUUID + SEPARATOR + shardId + SEPARATOR; // Translog Data - ShardDataPathInput pathInput = ShardDataPathInput.builder() + PathInput pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -82,7 +82,7 @@ public void testGeneratePathForFixedType() { // Translog Metadata dataType = METADATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -95,7 +95,7 @@ public void testGeneratePathForFixedType() { // Segment Data dataCategory = SEGMENTS; dataType = DATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -107,7 +107,7 @@ public void testGeneratePathForFixedType() { // Segment Metadata dataType = METADATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -119,7 +119,7 @@ public void testGeneratePathForFixedType() { // Segment Metadata dataType = LOCK_FILES; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -144,7 +144,7 @@ public void testGeneratePathForHashedPrefixType() { String basePath = getPath(pathList) + indexUUID + SEPARATOR + shardId; // Translog Data - ShardDataPathInput pathInput = ShardDataPathInput.builder() + PathInput pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -161,7 +161,7 @@ public void testGeneratePathForHashedPrefixType() { BlobPath fixedBlobPath = BlobPath.cleanPath().add("xjsdhj").add("ddjsha").add("yudy7sd").add("32hdhua7").add("89jdij"); String fixedIndexUUID = "k2ijhe877d7yuhx7"; String fixedShardId = "10"; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -173,7 +173,7 @@ public void testGeneratePathForHashedPrefixType() { // Translog Metadata dataType = METADATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -187,7 +187,7 @@ public void testGeneratePathForHashedPrefixType() { ); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -200,7 +200,7 @@ public void testGeneratePathForHashedPrefixType() { // Segment Data dataCategory = SEGMENTS; dataType = DATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -214,7 +214,7 @@ public void testGeneratePathForHashedPrefixType() { ); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -226,7 +226,7 @@ public void testGeneratePathForHashedPrefixType() { // Segment Metadata dataType = METADATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -240,7 +240,7 @@ public void testGeneratePathForHashedPrefixType() { ); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -252,7 +252,7 @@ public void testGeneratePathForHashedPrefixType() { // Segment Lockfiles dataType = LOCK_FILES; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -266,7 +266,7 @@ public void testGeneratePathForHashedPrefixType() { ); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -291,7 +291,7 @@ public void testGeneratePathForHashedPrefixTypeAndFNVCompositeHashAlgorithm() { String basePath = getPath(pathList) + indexUUID + SEPARATOR + shardId; // Translog Data - ShardDataPathInput pathInput = ShardDataPathInput.builder() + PathInput pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -310,7 +310,7 @@ public void testGeneratePathForHashedPrefixTypeAndFNVCompositeHashAlgorithm() { BlobPath fixedBlobPath = BlobPath.cleanPath().add("xjsdhj").add("ddjsha").add("yudy7sd").add("32hdhua7").add("89jdij"); String fixedIndexUUID = "k2ijhe877d7yuhx7"; String fixedShardId = "10"; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -322,7 +322,7 @@ public void testGeneratePathForHashedPrefixTypeAndFNVCompositeHashAlgorithm() { // Translog Metadata dataType = METADATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -338,7 +338,7 @@ public void testGeneratePathForHashedPrefixTypeAndFNVCompositeHashAlgorithm() { ); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -354,7 +354,7 @@ public void testGeneratePathForHashedPrefixTypeAndFNVCompositeHashAlgorithm() { // Segment Data dataCategory = SEGMENTS; dataType = DATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -370,7 +370,7 @@ public void testGeneratePathForHashedPrefixTypeAndFNVCompositeHashAlgorithm() { ); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -382,7 +382,7 @@ public void testGeneratePathForHashedPrefixTypeAndFNVCompositeHashAlgorithm() { // Segment Metadata dataType = METADATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -398,7 +398,7 @@ public void testGeneratePathForHashedPrefixTypeAndFNVCompositeHashAlgorithm() { ); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -413,7 +413,7 @@ public void testGeneratePathForHashedPrefixTypeAndFNVCompositeHashAlgorithm() { // Segment Lockfiles dataType = LOCK_FILES; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -429,7 +429,7 @@ public void testGeneratePathForHashedPrefixTypeAndFNVCompositeHashAlgorithm() { ); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -458,7 +458,7 @@ public void testGeneratePathForHashedInfixType() { String basePath = getPath(pathList); basePath = basePath.isEmpty() ? basePath : basePath.substring(0, basePath.length() - 1); // Translog Data - ShardDataPathInput pathInput = ShardDataPathInput.builder() + PathInput pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -474,7 +474,7 @@ public void testGeneratePathForHashedInfixType() { BlobPath fixedBlobPath = BlobPath.cleanPath().add("xjsdhj").add("ddjsha").add("yudy7sd").add("32hdhua7").add("89jdij"); String fixedIndexUUID = "k2ijhe877d7yuhx7"; String fixedShardId = "10"; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -488,7 +488,7 @@ public void testGeneratePathForHashedInfixType() { // Translog Metadata dataType = METADATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -502,7 +502,7 @@ public void testGeneratePathForHashedInfixType() { assertTrue(new ParameterizedMessage("expected={} actual={}", expected, actual).getFormattedMessage(), actual.startsWith(expected)); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -517,7 +517,7 @@ public void testGeneratePathForHashedInfixType() { // Segment Data dataCategory = SEGMENTS; dataType = DATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -530,7 +530,7 @@ public void testGeneratePathForHashedInfixType() { assertTrue(new ParameterizedMessage("expected={} actual={}", expected, actual).getFormattedMessage(), actual.startsWith(expected)); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -544,7 +544,7 @@ public void testGeneratePathForHashedInfixType() { // Segment Metadata dataType = METADATA; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -557,7 +557,7 @@ public void testGeneratePathForHashedInfixType() { assertTrue(new ParameterizedMessage("expected={} actual={}", expected, actual).getFormattedMessage(), actual.startsWith(expected)); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -571,7 +571,7 @@ public void testGeneratePathForHashedInfixType() { // Segment Lockfiles dataType = LOCK_FILES; - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(blobPath) .indexUUID(indexUUID) .shardId(shardId) @@ -584,7 +584,7 @@ public void testGeneratePathForHashedInfixType() { assertTrue(new ParameterizedMessage("expected={} actual={}", expected, actual).getFormattedMessage(), actual.startsWith(expected)); // assert with exact value for known base path - pathInput = ShardDataPathInput.builder() + pathInput = PathInput.builder() .basePath(fixedBlobPath) .indexUUID(fixedIndexUUID) .shardId(fixedShardId) @@ -597,7 +597,7 @@ public void testGeneratePathForHashedInfixType() { assertTrue(new ParameterizedMessage("expected={} actual={}", expected, actual).getFormattedMessage(), actual.startsWith(expected)); } - private String derivePath(String basePath, ShardDataPathInput pathInput) { + private String derivePath(String basePath, PathInput pathInput) { return "".equals(basePath) ? String.join( SEPARATOR, diff --git a/server/src/test/java/org/opensearch/index/remote/RemoteStorePathStrategyTests.java b/server/src/test/java/org/opensearch/index/remote/RemoteStorePathStrategyTests.java index cf5876cb5caf1..217ffe804573e 100644 --- a/server/src/test/java/org/opensearch/index/remote/RemoteStorePathStrategyTests.java +++ b/server/src/test/java/org/opensearch/index/remote/RemoteStorePathStrategyTests.java @@ -22,10 +22,10 @@ public class RemoteStorePathStrategyTests extends OpenSearchTestCase { private static final String SHARD_ID = "shardId"; public void testBasePathInput() { - assertThrows(NullPointerException.class, () -> RemoteStorePathStrategy.PathInput.builder().build()); - assertThrows(NullPointerException.class, () -> RemoteStorePathStrategy.PathInput.builder().basePath(BASE_PATH).build()); - assertThrows(NullPointerException.class, () -> RemoteStorePathStrategy.PathInput.builder().indexUUID(INDEX_UUID).build()); - RemoteStorePathStrategy.PathInput input = RemoteStorePathStrategy.PathInput.builder() + assertThrows(NullPointerException.class, () -> RemoteStorePathStrategy.BasePathInput.builder().build()); + assertThrows(NullPointerException.class, () -> RemoteStorePathStrategy.BasePathInput.builder().basePath(BASE_PATH).build()); + assertThrows(NullPointerException.class, () -> RemoteStorePathStrategy.BasePathInput.builder().indexUUID(INDEX_UUID).build()); + RemoteStorePathStrategy.BasePathInput input = RemoteStorePathStrategy.BasePathInput.builder() .basePath(BASE_PATH) .indexUUID(INDEX_UUID) .build(); @@ -34,17 +34,17 @@ public void testBasePathInput() { } public void testPathInput() { - assertThrows(NullPointerException.class, () -> RemoteStorePathStrategy.ShardDataPathInput.builder().build()); - assertThrows(NullPointerException.class, () -> RemoteStorePathStrategy.ShardDataPathInput.builder().shardId(SHARD_ID).build()); + assertThrows(NullPointerException.class, () -> RemoteStorePathStrategy.PathInput.builder().build()); + assertThrows(NullPointerException.class, () -> RemoteStorePathStrategy.PathInput.builder().shardId(SHARD_ID).build()); assertThrows( NullPointerException.class, - () -> RemoteStorePathStrategy.ShardDataPathInput.builder().shardId(SHARD_ID).dataCategory(TRANSLOG).build() + () -> RemoteStorePathStrategy.PathInput.builder().shardId(SHARD_ID).dataCategory(TRANSLOG).build() ); // Translog Lock files - This is a negative case where the assertion will trip. assertThrows( AssertionError.class, - () -> RemoteStorePathStrategy.ShardDataPathInput.builder() + () -> RemoteStorePathStrategy.PathInput.builder() .basePath(BASE_PATH) .indexUUID(INDEX_UUID) .shardId(SHARD_ID) @@ -53,7 +53,7 @@ public void testPathInput() { .build() ); - RemoteStorePathStrategy.ShardDataPathInput input = RemoteStorePathStrategy.ShardDataPathInput.builder() + RemoteStorePathStrategy.PathInput input = RemoteStorePathStrategy.PathInput.builder() .basePath(BASE_PATH) .indexUUID(INDEX_UUID) .shardId(SHARD_ID) @@ -68,13 +68,13 @@ public void testPathInput() { } public void testFixedSubPath() { - RemoteStorePathStrategy.PathInput input = RemoteStorePathStrategy.PathInput.builder() + RemoteStorePathStrategy.BasePathInput input = RemoteStorePathStrategy.BasePathInput.builder() .basePath(BASE_PATH) .indexUUID(INDEX_UUID) .build(); assertEquals(BlobPath.cleanPath().add(INDEX_UUID), input.fixedSubPath()); - RemoteStorePathStrategy.ShardDataPathInput input2 = RemoteStorePathStrategy.ShardDataPathInput.builder() + RemoteStorePathStrategy.PathInput input2 = RemoteStorePathStrategy.PathInput.builder() .basePath(BASE_PATH) .indexUUID(INDEX_UUID) .shardId(SHARD_ID) diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java index 6afc7c23d9e66..5ee65e7ea1a1c 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchTestCase.java @@ -1828,7 +1828,7 @@ public static BlobPath getShardLevelBlobPath( ? RemoteStoreEnums.PathHashAlgorithm.valueOf(remoteCustomData.get(RemoteStoreEnums.PathHashAlgorithm.NAME)) : null : null; - RemoteStorePathStrategy.ShardDataPathInput pathInput = RemoteStorePathStrategy.ShardDataPathInput.builder() + RemoteStorePathStrategy.PathInput pathInput = RemoteStorePathStrategy.PathInput.builder() .basePath(basePath) .indexUUID(indexUUID) .shardId(shardId)