diff --git a/CHANGELOG.md b/CHANGELOG.md index 18a688070b..e3bb2f33a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased 2.x] ### Added +- Add search role type for nodes in cluster stats ([#848](https://github.com/opensearch-project/opensearch-java/pull/848)) ### Dependencies @@ -13,6 +14,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Removed ### Fixed +- Fix ClusterStatsResponse field deserialization ([#848](https://github.com/opensearch-project/opensearch-java/pull/848)) ### Security diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/cluster/stats/ClusterNodeCount.java b/java-client/src/main/java/org/opensearch/client/opensearch/cluster/stats/ClusterNodeCount.java index 17f9a8d370..47e1b7688d 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/cluster/stats/ClusterNodeCount.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/cluster/stats/ClusterNodeCount.java @@ -55,28 +55,17 @@ public class ClusterNodeCount implements JsonpSerializable { private final int ingest; - private final int clusterManager; + @Deprecated + private final Integer master; - private final int total; - - private final int votingOnly; - - private final int dataCold; - - @Nullable - private final Integer dataFrozen; - - private final int dataContent; - - private final int dataWarm; + private final Integer clusterManager; - private final int dataHot; - - private final int ml; + private final int total; private final int remoteClusterClient; - private final int transform; + @Nullable + private final Integer search; // --------------------------------------------------------------------------------------------- @@ -85,18 +74,11 @@ private ClusterNodeCount(Builder builder) { this.coordinatingOnly = ApiTypeHelper.requireNonNull(builder.coordinatingOnly, this, "coordinatingOnly"); this.data = ApiTypeHelper.requireNonNull(builder.data, this, "data"); this.ingest = ApiTypeHelper.requireNonNull(builder.ingest, this, "ingest"); - this.clusterManager = ApiTypeHelper.requireNonNull(builder.clusterManager, this, "clusterManager"); + this.master = builder.master; + this.clusterManager = builder.clusterManager; this.total = ApiTypeHelper.requireNonNull(builder.total, this, "total"); - this.votingOnly = ApiTypeHelper.requireNonNull(builder.votingOnly, this, "votingOnly"); - this.dataCold = ApiTypeHelper.requireNonNull(builder.dataCold, this, "dataCold"); - this.dataFrozen = builder.dataFrozen; - this.dataContent = ApiTypeHelper.requireNonNull(builder.dataContent, this, "dataContent"); - this.dataWarm = ApiTypeHelper.requireNonNull(builder.dataWarm, this, "dataWarm"); - this.dataHot = ApiTypeHelper.requireNonNull(builder.dataHot, this, "dataHot"); - this.ml = ApiTypeHelper.requireNonNull(builder.ml, this, "ml"); this.remoteClusterClient = ApiTypeHelper.requireNonNull(builder.remoteClusterClient, this, "remoteClusterClient"); - this.transform = ApiTypeHelper.requireNonNull(builder.transform, this, "transform"); - + this.search = builder.search; } public static ClusterNodeCount of(Function> fn) { @@ -125,7 +107,15 @@ public final int ingest() { } /** - * Required - API name: {@code clusterManager} + * API name: {@code master} + */ + @Deprecated + public final int master() { + return this.master; + } + + /** + * API name: {@code clusterManager} */ public final int clusterManager() { return this.clusterManager; @@ -138,56 +128,6 @@ public final int total() { return this.total; } - /** - * Required - API name: {@code voting_only} - */ - public final int votingOnly() { - return this.votingOnly; - } - - /** - * Required - API name: {@code data_cold} - */ - public final int dataCold() { - return this.dataCold; - } - - /** - * API name: {@code data_frozen} - */ - @Nullable - public final Integer dataFrozen() { - return this.dataFrozen; - } - - /** - * Required - API name: {@code data_content} - */ - public final int dataContent() { - return this.dataContent; - } - - /** - * Required - API name: {@code data_warm} - */ - public final int dataWarm() { - return this.dataWarm; - } - - /** - * Required - API name: {@code data_hot} - */ - public final int dataHot() { - return this.dataHot; - } - - /** - * Required - API name: {@code ml} - */ - public final int ml() { - return this.ml; - } - /** * Required - API name: {@code remote_cluster_client} */ @@ -196,10 +136,11 @@ public final int remoteClusterClient() { } /** - * Required - API name: {@code transform} + * API name: {@code search} */ - public final int transform() { - return this.transform; + @Nullable + public final Integer search() { + return this.search; } /** @@ -222,40 +163,26 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { generator.writeKey("ingest"); generator.write(this.ingest); - generator.writeKey("cluster_manager"); - generator.write(this.clusterManager); - - generator.writeKey("total"); - generator.write(this.total); - - generator.writeKey("voting_only"); - generator.write(this.votingOnly); - - generator.writeKey("data_cold"); - generator.write(this.dataCold); - - if (this.dataFrozen != null) { - generator.writeKey("data_frozen"); - generator.write(this.dataFrozen); - + if (this.master != null) { + generator.writeKey("master"); + generator.write(this.master); } - generator.writeKey("data_content"); - generator.write(this.dataContent); - - generator.writeKey("data_warm"); - generator.write(this.dataWarm); - generator.writeKey("data_hot"); - generator.write(this.dataHot); + if (this.clusterManager != null) { + generator.writeKey("cluster_manager"); + generator.write(this.clusterManager); + } - generator.writeKey("ml"); - generator.write(this.ml); + generator.writeKey("total"); + generator.write(this.total); generator.writeKey("remote_cluster_client"); generator.write(this.remoteClusterClient); - generator.writeKey("transform"); - generator.write(this.transform); + if (this.search != null) { + generator.writeKey("search"); + generator.write(this.search); + } } @@ -272,28 +199,15 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder { private Integer count; - private String flavor; - private String type; /** @@ -132,14 +117,6 @@ public final Builder count(int value) { return this; } - /** - * Required - API name: {@code flavor} - */ - public final Builder flavor(String value) { - this.flavor = value; - return this; - } - /** * Required - API name: {@code type} */ @@ -174,7 +151,6 @@ public NodePackagingType build() { protected static void setupNodePackagingTypeDeserializer(ObjectDeserializer op) { op.add(Builder::count, JsonpDeserializer.integerDeserializer(), "count"); - op.add(Builder::flavor, JsonpDeserializer.stringDeserializer(), "flavor"); op.add(Builder::type, JsonpDeserializer.stringDeserializer(), "type"); } diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractClusterClientIT.java b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractClusterClientIT.java index b28836bc03..96cbdc856c 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractClusterClientIT.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/integTest/AbstractClusterClientIT.java @@ -21,6 +21,8 @@ import org.opensearch.client.opensearch._types.HealthStatus; import org.opensearch.client.opensearch._types.Level; import org.opensearch.client.opensearch._types.OpenSearchException; +import org.opensearch.client.opensearch.cluster.ClusterStatsRequest; +import org.opensearch.client.opensearch.cluster.ClusterStatsResponse; import org.opensearch.client.opensearch.cluster.GetClusterSettingsRequest; import org.opensearch.client.opensearch.cluster.GetClusterSettingsResponse; import org.opensearch.client.opensearch.cluster.HealthRequest; @@ -299,4 +301,15 @@ public void testClusterHealthNotFoundIndex() throws IOException { assertNotNull(e); } } + + public void testClusterStats() throws IOException { + OpenSearchClient openSearchClient = javaClient(); + javaClient().indices().create(b -> b.index("index")); + ClusterStatsRequest request = new ClusterStatsRequest.Builder().build(); + ClusterStatsResponse response = openSearchClient.cluster().stats(request); + assertNotNull(response); + assertNotNull(response.clusterName()); + assertNotEquals(response.nodes().count().total(), 0); + assertNotEquals(response.indices().count(), 0); + } }