From f39d68684bf59bcbfb16c477cf28f8bd496c5d96 Mon Sep 17 00:00:00 2001 From: Shivansh Arora Date: Mon, 10 Jun 2024 18:48:43 +0530 Subject: [PATCH] Address PR comments Signed-off-by: Shivansh Arora --- .../remote/ClusterMetadataManifest.java | 4 - .../remote/ClusterStateDiffManifest.java | 91 +++++++++-------- .../remote/RemoteStateTransferException.java | 9 ++ .../remote/model/RemoteClusterBlocks.java | 20 +--- .../model/RemoteClusterStateCustoms.java | 10 +- .../remote/model/RemoteDiscoveryNodes.java | 15 +-- .../RemoteHashesOfConsistentSettings.java | 15 +-- .../model/ClusterStateDiffManifestTests.java | 59 +++++++++-- .../model/RemoteClusterBlocksTests.java | 79 +++------------ .../model/RemoteDiscoveryNodesTests.java | 99 +++---------------- ...RemoteHashesOfConsistentSettingsTests.java | 33 +++---- 11 files changed, 157 insertions(+), 277 deletions(-) diff --git a/server/src/main/java/org/opensearch/gateway/remote/ClusterMetadataManifest.java b/server/src/main/java/org/opensearch/gateway/remote/ClusterMetadataManifest.java index 961067b691020..b6323279e0cd2 100644 --- a/server/src/main/java/org/opensearch/gateway/remote/ClusterMetadataManifest.java +++ b/server/src/main/java/org/opensearch/gateway/remote/ClusterMetadataManifest.java @@ -424,10 +424,6 @@ public ClusterStateDiffManifest getDiffManifest() { return diffManifest; } - public UploadedMetadataAttribute getDiscoverNodeMetadata() { - return uploadedDiscoveryNodesMetadata; - } - public Map getClusterStateCustomMap() { return uploadedClusterStateCustomMap; } diff --git a/server/src/main/java/org/opensearch/gateway/remote/ClusterStateDiffManifest.java b/server/src/main/java/org/opensearch/gateway/remote/ClusterStateDiffManifest.java index 41849545f67ec..9d950ee67c4a4 100644 --- a/server/src/main/java/org/opensearch/gateway/remote/ClusterStateDiffManifest.java +++ b/server/src/main/java/org/opensearch/gateway/remote/ClusterStateDiffManifest.java @@ -19,7 +19,7 @@ import org.opensearch.core.common.io.stream.StreamOutput; import org.opensearch.core.common.io.stream.Writeable; import org.opensearch.core.xcontent.MediaTypeRegistry; -import org.opensearch.core.xcontent.ToXContentObject; +import org.opensearch.core.xcontent.ToXContentFragment; import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.core.xcontent.XContentParseException; import org.opensearch.core.xcontent.XContentParser; @@ -39,7 +39,7 @@ * * @opensearch.internal */ -public class ClusterStateDiffManifest implements ToXContentObject, Writeable { +public class ClusterStateDiffManifest implements ToXContentFragment, Writeable { private static final String FROM_STATE_UUID_FIELD = "from_state_uuid"; private static final String TO_STATE_UUID_FIELD = "to_state_uuid"; private static final String METADATA_DIFF_FIELD = "metadata_diff"; @@ -183,71 +183,68 @@ public ClusterStateDiffManifest(StreamInput in) throws IOException { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { + builder.field(FROM_STATE_UUID_FIELD, fromStateUUID); + builder.field(TO_STATE_UUID_FIELD, toStateUUID); + builder.startObject(METADATA_DIFF_FIELD); { - builder.field(FROM_STATE_UUID_FIELD, fromStateUUID); - builder.field(TO_STATE_UUID_FIELD, toStateUUID); - builder.startObject(METADATA_DIFF_FIELD); - { - builder.field(COORDINATION_METADATA_UPDATED_FIELD, coordinationMetadataUpdated); - builder.field(SETTINGS_METADATA_UPDATED_FIELD, settingsMetadataUpdated); - builder.field(TRANSIENT_SETTINGS_METADATA_UPDATED_FIELD, transientSettingsMetadataUpdated); - builder.field(TEMPLATES_METADATA_UPDATED_FIELD, templatesMetadataUpdated); - builder.startObject(INDICES_DIFF_FIELD); - builder.startArray(UPSERTS_FIELD); - for (String index : indicesUpdated) { - builder.value(index); - } - builder.endArray(); - builder.startArray(DELETES_FIELD); - for (String index : indicesDeleted) { - builder.value(index); - } - builder.endArray(); - builder.endObject(); - builder.startObject(METADATA_CUSTOM_DIFF_FIELD); - builder.startArray(UPSERTS_FIELD); - for (String custom : customMetadataUpdated) { - builder.value(custom); - } - builder.endArray(); - builder.startArray(DELETES_FIELD); - for (String custom : customMetadataDeleted) { - builder.value(custom); - } - builder.endArray(); - builder.endObject(); - builder.field(HASHES_OF_CONSISTENT_SETTINGS_UPDATED_FIELD, hashesOfConsistentSettingsUpdated); - } - builder.endObject(); - builder.field(CLUSTER_BLOCKS_UPDATED_FIELD, clusterBlocksUpdated); - builder.field(DISCOVERY_NODES_UPDATED_FIELD, discoveryNodesUpdated); - - builder.startObject(ROUTING_TABLE_DIFF); + builder.field(COORDINATION_METADATA_UPDATED_FIELD, coordinationMetadataUpdated); + builder.field(SETTINGS_METADATA_UPDATED_FIELD, settingsMetadataUpdated); + builder.field(TRANSIENT_SETTINGS_METADATA_UPDATED_FIELD, transientSettingsMetadataUpdated); + builder.field(TEMPLATES_METADATA_UPDATED_FIELD, templatesMetadataUpdated); + builder.startObject(INDICES_DIFF_FIELD); builder.startArray(UPSERTS_FIELD); - for (String index : indicesRoutingUpdated) { + for (String index : indicesUpdated) { builder.value(index); } builder.endArray(); builder.startArray(DELETES_FIELD); - for (String index : indicesRoutingDeleted) { + for (String index : indicesDeleted) { builder.value(index); } builder.endArray(); builder.endObject(); - builder.startObject(CLUSTER_STATE_CUSTOM_DIFF_FIELD); + builder.startObject(METADATA_CUSTOM_DIFF_FIELD); builder.startArray(UPSERTS_FIELD); - for (String custom : clusterStateCustomUpdated) { + for (String custom : customMetadataUpdated) { builder.value(custom); } builder.endArray(); builder.startArray(DELETES_FIELD); - for (String custom : clusterStateCustomDeleted) { + for (String custom : customMetadataDeleted) { builder.value(custom); } builder.endArray(); builder.endObject(); - + builder.field(HASHES_OF_CONSISTENT_SETTINGS_UPDATED_FIELD, hashesOfConsistentSettingsUpdated); + } + builder.endObject(); + builder.field(CLUSTER_BLOCKS_UPDATED_FIELD, clusterBlocksUpdated); + builder.field(DISCOVERY_NODES_UPDATED_FIELD, discoveryNodesUpdated); + + builder.startObject(ROUTING_TABLE_DIFF); + builder.startArray(UPSERTS_FIELD); + for (String index : indicesRoutingUpdated) { + builder.value(index); + } + builder.endArray(); + builder.startArray(DELETES_FIELD); + for (String index : indicesRoutingDeleted) { + builder.value(index); + } + builder.endArray(); + builder.endObject(); + builder.startObject(CLUSTER_STATE_CUSTOM_DIFF_FIELD); + builder.startArray(UPSERTS_FIELD); + for (String custom : clusterStateCustomUpdated) { + builder.value(custom); + } + builder.endArray(); + builder.startArray(DELETES_FIELD); + for (String custom : clusterStateCustomDeleted) { + builder.value(custom); } + builder.endArray(); + builder.endObject(); return builder; } diff --git a/server/src/main/java/org/opensearch/gateway/remote/RemoteStateTransferException.java b/server/src/main/java/org/opensearch/gateway/remote/RemoteStateTransferException.java index fef3e734e78eb..5b75b6c18ee5b 100644 --- a/server/src/main/java/org/opensearch/gateway/remote/RemoteStateTransferException.java +++ b/server/src/main/java/org/opensearch/gateway/remote/RemoteStateTransferException.java @@ -33,4 +33,13 @@ public RemoteStateTransferException(String errorDesc, RemoteWriteableEntity e super(errorDesc, cause); this.entity = entity; } + + @Override + public String toString() { + String message = super.toString(); + if (entity != null) { + message += ", failed entity:" + entity; + } + return message; + } } diff --git a/server/src/main/java/org/opensearch/gateway/remote/model/RemoteClusterBlocks.java b/server/src/main/java/org/opensearch/gateway/remote/model/RemoteClusterBlocks.java index 9bb0eac5bd793..937f9dc2c8631 100644 --- a/server/src/main/java/org/opensearch/gateway/remote/model/RemoteClusterBlocks.java +++ b/server/src/main/java/org/opensearch/gateway/remote/model/RemoteClusterBlocks.java @@ -16,7 +16,6 @@ import org.opensearch.core.common.io.stream.BytesStreamInput; import org.opensearch.core.common.io.stream.StreamInput; import org.opensearch.core.compress.Compressor; -import org.opensearch.core.xcontent.NamedXContentRegistry; import org.opensearch.gateway.remote.ClusterMetadataManifest.UploadedMetadata; import org.opensearch.gateway.remote.ClusterMetadataManifest.UploadedMetadataAttribute; import org.opensearch.index.remote.RemoteStoreUtils; @@ -40,25 +39,14 @@ public class RemoteClusterBlocks extends AbstractRemoteWritableBlobEntity indicesToAdd, List indicesToRemove, @@ -159,5 +205,6 @@ private void verifyDiff( assertEquals(updateDiscoveryNodes, manifest.isDiscoveryNodesUpdated()); assertEquals(updateClusterBlocks, manifest.isClusterBlocksUpdated()); assertEquals(updateHashesOfConsistentSettings, manifest.isHashesOfConsistentSettingsUpdated()); + return manifest; } } diff --git a/server/src/test/java/org/opensearch/gateway/remote/model/RemoteClusterBlocksTests.java b/server/src/test/java/org/opensearch/gateway/remote/model/RemoteClusterBlocksTests.java index 85d07ae7f5fe1..a5419a8cc8115 100644 --- a/server/src/test/java/org/opensearch/gateway/remote/model/RemoteClusterBlocksTests.java +++ b/server/src/test/java/org/opensearch/gateway/remote/model/RemoteClusterBlocksTests.java @@ -59,79 +59,40 @@ public void setup() { public void testClusterUUID() { ClusterBlocks clusterBlocks = randomClusterBlocks(); - RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks( - clusterBlocks, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks(clusterBlocks, METADATA_VERSION, clusterUUID, compressor); assertEquals(remoteObjectForUpload.clusterUUID(), clusterUUID); - RemoteClusterBlocks remoteObjectForDownload = new RemoteClusterBlocks( - TEST_BLOB_NAME, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteClusterBlocks remoteObjectForDownload = new RemoteClusterBlocks(TEST_BLOB_NAME, clusterUUID, compressor); assertEquals(remoteObjectForDownload.clusterUUID(), clusterUUID); } public void testFullBlobName() { ClusterBlocks clusterBlocks = randomClusterBlocks(); - RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks( - clusterBlocks, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks(clusterBlocks, METADATA_VERSION, clusterUUID, compressor); assertNull(remoteObjectForUpload.getFullBlobName()); - RemoteClusterBlocks remoteObjectForDownload = new RemoteClusterBlocks( - TEST_BLOB_NAME, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteClusterBlocks remoteObjectForDownload = new RemoteClusterBlocks(TEST_BLOB_NAME, clusterUUID, compressor); assertEquals(remoteObjectForDownload.getFullBlobName(), TEST_BLOB_NAME); } public void testBlobFileName() { ClusterBlocks clusterBlocks = randomClusterBlocks(); - RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks( - clusterBlocks, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks(clusterBlocks, METADATA_VERSION, clusterUUID, compressor); assertNull(remoteObjectForUpload.getBlobFileName()); - RemoteClusterBlocks remoteObjectForDownload = new RemoteClusterBlocks( - TEST_BLOB_NAME, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteClusterBlocks remoteObjectForDownload = new RemoteClusterBlocks(TEST_BLOB_NAME, clusterUUID, compressor); assertEquals(remoteObjectForDownload.getBlobFileName(), TEST_BLOB_FILE_NAME); } public void testBlobPathTokens() { String uploadedFile = "user/local/opensearch/cluster-blocks"; - RemoteClusterBlocks remoteObjectForDownload = new RemoteClusterBlocks(uploadedFile, clusterUUID, compressor, namedXContentRegistry); + RemoteClusterBlocks remoteObjectForDownload = new RemoteClusterBlocks(uploadedFile, clusterUUID, compressor); assertArrayEquals(remoteObjectForDownload.getBlobPathTokens(), new String[] { "user", "local", "opensearch", "cluster-blocks" }); } public void testBlobPathParameters() { ClusterBlocks clusterBlocks = randomClusterBlocks(); - RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks( - clusterBlocks, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks(clusterBlocks, METADATA_VERSION, clusterUUID, compressor); BlobPathParameters params = remoteObjectForUpload.getBlobPathParameters(); assertEquals(params.getPathTokens(), List.of(CLUSTER_STATE_EPHEMERAL_PATH_TOKEN)); assertEquals(params.getFilePrefix(), CLUSTER_BLOCKS); @@ -139,13 +100,7 @@ public void testBlobPathParameters() { public void testGenerateBlobFileName() { ClusterBlocks clusterBlocks = randomClusterBlocks(); - RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks( - clusterBlocks, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks(clusterBlocks, METADATA_VERSION, clusterUUID, compressor); String blobFileName = remoteObjectForUpload.generateBlobFileName(); String[] nameTokens = blobFileName.split(RemoteClusterStateUtils.DELIMITER); assertEquals(nameTokens[0], CLUSTER_BLOCKS); @@ -157,13 +112,7 @@ public void testGenerateBlobFileName() { public void testGetUploadedMetadata() throws IOException { ClusterBlocks clusterBlocks = randomClusterBlocks(); - RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks( - clusterBlocks, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks(clusterBlocks, METADATA_VERSION, clusterUUID, compressor); assertThrows(AssertionError.class, remoteObjectForUpload::getUploadedMetadata); remoteObjectForUpload.setFullBlobName(new BlobPath().add(TEST_BLOB_PATH)); ClusterMetadataManifest.UploadedMetadata uploadedMetadata = remoteObjectForUpload.getUploadedMetadata(); @@ -173,13 +122,7 @@ public void testGetUploadedMetadata() throws IOException { public void testSerDe() throws IOException { ClusterBlocks clusterBlocks = randomClusterBlocks(); - RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks( - clusterBlocks, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteClusterBlocks remoteObjectForUpload = new RemoteClusterBlocks(clusterBlocks, METADATA_VERSION, clusterUUID, compressor); try (InputStream inputStream = remoteObjectForUpload.serialize()) { remoteObjectForUpload.setFullBlobName(BlobPath.cleanPath()); assertTrue(inputStream.available() > 0); diff --git a/server/src/test/java/org/opensearch/gateway/remote/model/RemoteDiscoveryNodesTests.java b/server/src/test/java/org/opensearch/gateway/remote/model/RemoteDiscoveryNodesTests.java index f22d71075e283..0c46960938798 100644 --- a/server/src/test/java/org/opensearch/gateway/remote/model/RemoteDiscoveryNodesTests.java +++ b/server/src/test/java/org/opensearch/gateway/remote/model/RemoteDiscoveryNodesTests.java @@ -67,84 +67,40 @@ public void setup() { public void testClusterUUID() { DiscoveryNodes nodes = getDiscoveryNodes(); - RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes( - nodes, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes(nodes, METADATA_VERSION, clusterUUID, compressor); assertEquals(remoteObjectForUpload.clusterUUID(), clusterUUID); - RemoteDiscoveryNodes remoteObjectForDownload = new RemoteDiscoveryNodes( - TEST_BLOB_NAME, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForDownload = new RemoteDiscoveryNodes(TEST_BLOB_NAME, clusterUUID, compressor); assertEquals(remoteObjectForDownload.clusterUUID(), clusterUUID); } public void testFullBlobName() { DiscoveryNodes nodes = getDiscoveryNodes(); - RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes( - nodes, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes(nodes, METADATA_VERSION, clusterUUID, compressor); assertNull(remoteObjectForUpload.getFullBlobName()); - RemoteDiscoveryNodes remoteObjectForDownload = new RemoteDiscoveryNodes( - TEST_BLOB_NAME, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForDownload = new RemoteDiscoveryNodes(TEST_BLOB_NAME, clusterUUID, compressor); assertEquals(remoteObjectForDownload.getFullBlobName(), TEST_BLOB_NAME); } public void testBlobFileName() { DiscoveryNodes nodes = getDiscoveryNodes(); - RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes( - nodes, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes(nodes, METADATA_VERSION, clusterUUID, compressor); assertNull(remoteObjectForUpload.getBlobFileName()); - RemoteClusterBlocks remoteObjectForDownload = new RemoteClusterBlocks( - TEST_BLOB_NAME, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteClusterBlocks remoteObjectForDownload = new RemoteClusterBlocks(TEST_BLOB_NAME, clusterUUID, compressor); assertEquals(remoteObjectForDownload.getBlobFileName(), TEST_BLOB_FILE_NAME); } public void testBlobPathTokens() { String uploadedFile = "user/local/opensearch/discovery-nodes"; - RemoteDiscoveryNodes remoteObjectForDownload = new RemoteDiscoveryNodes( - uploadedFile, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForDownload = new RemoteDiscoveryNodes(uploadedFile, clusterUUID, compressor); assertArrayEquals(remoteObjectForDownload.getBlobPathTokens(), new String[] { "user", "local", "opensearch", "discovery-nodes" }); } public void testBlobPathParameters() { DiscoveryNodes nodes = getDiscoveryNodes(); - RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes( - nodes, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes(nodes, METADATA_VERSION, clusterUUID, compressor); BlobPathParameters params = remoteObjectForUpload.getBlobPathParameters(); assertEquals(params.getPathTokens(), List.of(CLUSTER_STATE_EPHEMERAL_PATH_TOKEN)); assertEquals(params.getFilePrefix(), DISCOVERY_NODES); @@ -152,13 +108,7 @@ public void testBlobPathParameters() { public void testGenerateBlobFileName() { DiscoveryNodes nodes = getDiscoveryNodes(); - RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes( - nodes, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes(nodes, METADATA_VERSION, clusterUUID, compressor); String blobFileName = remoteObjectForUpload.generateBlobFileName(); String[] nameTokens = blobFileName.split(RemoteClusterStateUtils.DELIMITER); assertEquals(nameTokens[0], DISCOVERY_NODES); @@ -169,13 +119,7 @@ public void testGenerateBlobFileName() { public void testGetUploadedMetadata() throws IOException { DiscoveryNodes nodes = getDiscoveryNodes(); - RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes( - nodes, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes(nodes, METADATA_VERSION, clusterUUID, compressor); assertThrows(AssertionError.class, remoteObjectForUpload::getUploadedMetadata); remoteObjectForUpload.setFullBlobName(new BlobPath().add(TEST_BLOB_PATH)); ClusterMetadataManifest.UploadedMetadata uploadedMetadata = remoteObjectForUpload.getUploadedMetadata(); @@ -185,13 +129,7 @@ public void testGetUploadedMetadata() throws IOException { public void testSerDe() throws IOException { DiscoveryNodes nodes = getDiscoveryNodes(); - RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes( - nodes, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes(nodes, METADATA_VERSION, clusterUUID, compressor); try (InputStream inputStream = remoteObjectForUpload.serialize()) { remoteObjectForUpload.setFullBlobName(BlobPath.cleanPath()); assertTrue(inputStream.available() > 0); @@ -204,13 +142,7 @@ public void testSerDe() throws IOException { public void testExceptionDuringSerialization() throws IOException { DiscoveryNodes nodes = mock(DiscoveryNodes.class); - RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes( - nodes, - METADATA_VERSION, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForUpload = new RemoteDiscoveryNodes(nodes, METADATA_VERSION, clusterUUID, compressor); doThrow(new IOException("mock-exception")).when(nodes).writeTo(any()); IOException iea = assertThrows(IOException.class, remoteObjectForUpload::serialize); assertEquals("Failed to serialize remote discovery nodes", iea.getMessage()); @@ -221,12 +153,7 @@ public void testExceptionDuringDeserialize() throws IOException { InputStream in = mock(InputStream.class); when(in.read(any(byte[].class))).thenThrow(new IOException("mock-exception")); String uploadedFile = "user/local/opensearch/discovery-nodes"; - RemoteDiscoveryNodes remoteObjectForDownload = new RemoteDiscoveryNodes( - uploadedFile, - clusterUUID, - compressor, - namedXContentRegistry - ); + RemoteDiscoveryNodes remoteObjectForDownload = new RemoteDiscoveryNodes(uploadedFile, clusterUUID, compressor); IOException ioe = assertThrows(IOException.class, () -> remoteObjectForDownload.deserialize(in)); assertEquals("Failed to deserialize remote discovery nodes", ioe.getMessage()); } diff --git a/server/src/test/java/org/opensearch/gateway/remote/model/RemoteHashesOfConsistentSettingsTests.java b/server/src/test/java/org/opensearch/gateway/remote/model/RemoteHashesOfConsistentSettingsTests.java index 0bb8b7d5034ce..d883eabf9fbc9 100644 --- a/server/src/test/java/org/opensearch/gateway/remote/model/RemoteHashesOfConsistentSettingsTests.java +++ b/server/src/test/java/org/opensearch/gateway/remote/model/RemoteHashesOfConsistentSettingsTests.java @@ -64,16 +64,14 @@ public void testClusterUUID() { hashesOfConsistentSettings, METADATA_VERSION, clusterUUID, - compressor, - namedXContentRegistry + compressor ); assertEquals(remoteObjectForUpload.clusterUUID(), clusterUUID); RemoteHashesOfConsistentSettings remoteObjectForDownload = new RemoteHashesOfConsistentSettings( TEST_BLOB_NAME, clusterUUID, - compressor, - namedXContentRegistry + compressor ); assertEquals(remoteObjectForDownload.clusterUUID(), clusterUUID); } @@ -84,16 +82,14 @@ public void testFullBlobName() { hashesOfConsistentSettings, METADATA_VERSION, clusterUUID, - compressor, - namedXContentRegistry + compressor ); assertNull(remoteObjectForUpload.getFullBlobName()); RemoteHashesOfConsistentSettings remoteObjectForDownload = new RemoteHashesOfConsistentSettings( TEST_BLOB_NAME, clusterUUID, - compressor, - namedXContentRegistry + compressor ); assertEquals(remoteObjectForDownload.getFullBlobName(), TEST_BLOB_NAME); } @@ -104,16 +100,14 @@ public void testBlobFileName() { hashesOfConsistentSettings, METADATA_VERSION, clusterUUID, - compressor, - namedXContentRegistry + compressor ); assertNull(remoteObjectForUpload.getBlobFileName()); RemoteHashesOfConsistentSettings remoteObjectForDownload = new RemoteHashesOfConsistentSettings( TEST_BLOB_NAME, clusterUUID, - compressor, - namedXContentRegistry + compressor ); assertEquals(remoteObjectForDownload.getBlobFileName(), TEST_BLOB_FILE_NAME); } @@ -123,8 +117,7 @@ public void testBlobPathTokens() { RemoteHashesOfConsistentSettings remoteObjectForDownload = new RemoteHashesOfConsistentSettings( uploadedFile, clusterUUID, - compressor, - namedXContentRegistry + compressor ); assertArrayEquals( remoteObjectForDownload.getBlobPathTokens(), @@ -138,8 +131,7 @@ public void testBlobPathParameters() { hashesOfConsistentSettings, METADATA_VERSION, clusterUUID, - compressor, - namedXContentRegistry + compressor ); BlobPathParameters params = remoteObjectForUpload.getBlobPathParameters(); assertEquals(params.getPathTokens(), List.of(GLOBAL_METADATA_PATH_TOKEN)); @@ -152,8 +144,7 @@ public void testGenerateBlobFileName() { hashesOfConsistentSettings, METADATA_VERSION, clusterUUID, - compressor, - namedXContentRegistry + compressor ); String blobFileName = remoteObjectForUpload.generateBlobFileName(); String[] nameTokens = blobFileName.split(RemoteClusterStateUtils.DELIMITER); @@ -169,8 +160,7 @@ public void testGetUploadedMetadata() throws IOException { hashesOfConsistentSettings, METADATA_VERSION, clusterUUID, - compressor, - namedXContentRegistry + compressor ); assertThrows(AssertionError.class, remoteObjectForUpload::getUploadedMetadata); remoteObjectForUpload.setFullBlobName(new BlobPath().add(TEST_BLOB_PATH)); @@ -185,8 +175,7 @@ public void testSerDe() throws IOException { hashesOfConsistentSettings, METADATA_VERSION, clusterUUID, - compressor, - namedXContentRegistry + compressor ); try (InputStream inputStream = remoteObjectForUpload.serialize()) { remoteObjectForUpload.setFullBlobName(BlobPath.cleanPath());