From 9a73e4d5b8ceac48cc25b6a2417527676ce7ba13 Mon Sep 17 00:00:00 2001 From: Liam Macpherson Date: Mon, 2 Sep 2024 11:20:13 +0100 Subject: [PATCH 1/6] fix: remove required check on indices.stats.ShardStats.shards Signed-off-by: Liam Macpherson Signed-off-by: Liam Macpherson --- CHANGELOG.md | 4 +- .../opensearch/indices/stats/ShardStats.java | 45 +++++++------------ 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1489b7d53c..5004c7fefd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ## [Unreleased 3.0] ### Dependencies -- Bumps `org.owasp.dependencycheck` from 10.0.2 to 10.0.4 +- Bumps `org.junit:junit-bom` from 5.10.2 to 5.11.0 +- Bumps `org.owasp.dependencycheck` from 10.0.2 to 10.0.3 - Bumps `org.eclipse.parsson:parsson` from 1.1.6 to 1.1.7 - Bumps `org.hamcrest:hamcrest` from 2.2 to 3.0 - Bumps `com.github.jk1.dependency-license-report` from 2.8 to 2.9 @@ -48,6 +49,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Fixed - Fix queries not preserving boost and name when converted to builders ([#1181](https://github.com/opensearch-project/opensearch-java/pull/1181)) +- Remove required check on ShardStats.shards ([#XXX](https://github.com/opensearch-project/opensearch-java/pull/XXX)) ### Security diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java index 9cc34fa4d5..84506caa74 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java @@ -33,34 +33,15 @@ package org.opensearch.client.opensearch.indices.stats; import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.json.JsonpDeserializable; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.opensearch._types.BulkStats; -import org.opensearch.client.opensearch._types.CompletionStats; -import org.opensearch.client.opensearch._types.DocStats; -import org.opensearch.client.opensearch._types.FielddataStats; -import org.opensearch.client.opensearch._types.FlushStats; -import org.opensearch.client.opensearch._types.GetStats; -import org.opensearch.client.opensearch._types.IndexingStats; -import org.opensearch.client.opensearch._types.MergesStats; -import org.opensearch.client.opensearch._types.RecoveryStats; -import org.opensearch.client.opensearch._types.RefreshStats; -import org.opensearch.client.opensearch._types.RequestCacheStats; -import org.opensearch.client.opensearch._types.SearchStats; -import org.opensearch.client.opensearch._types.SegmentsStats; -import org.opensearch.client.opensearch._types.StoreStats; -import org.opensearch.client.opensearch._types.TranslogStats; -import org.opensearch.client.opensearch._types.WarmerStats; +import org.opensearch.client.json.*; +import org.opensearch.client.opensearch._types.*; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import javax.annotation.Nullable; +import java.util.function.Function; + // typedef: indices.stats.ShardStats @JsonpDeserializable @@ -110,6 +91,7 @@ public class ShardStats implements PlainJsonSerializable { @Nullable private final BulkStats bulk; + @Nullable private final ShardsTotalStats shards; // --------------------------------------------------------------------------------------------- @@ -302,8 +284,9 @@ public final BulkStats bulk() { } /** - * Required - API name: {@code shards} + * API name: {@code shards} */ + @Nullable public final ShardsTotalStats shards() { return this.shards; } @@ -387,9 +370,10 @@ protected void serializeInternal(JsonGenerator generator, JsonpMapper mapper) { this.bulk.serialize(generator, mapper); } - generator.writeKey("shards"); - this.shards.serialize(generator, mapper); - + if (this.shards != null) { + generator.writeKey("shards"); + this.shards.serialize(generator, mapper); + } } // --------------------------------------------------------------------------------------------- @@ -444,6 +428,7 @@ public static class Builder extends ObjectBuilderBase implements ObjectBuilder> } /** - * Required - API name: {@code shards} + * API name: {@code shards} */ public final Builder shards(ShardsTotalStats value) { this.shards = value; @@ -785,7 +770,7 @@ public final Builder shards(ShardsTotalStats value) { } /** - * Required - API name: {@code shards} + * API name: {@code shards} */ public final Builder shards(Function> fn) { return this.shards(fn.apply(new ShardsTotalStats.Builder()).build()); From d627cce4a2af09fb0c92b488dfe040781292a625 Mon Sep 17 00:00:00 2001 From: Liam Macpherson Date: Tue, 3 Sep 2024 17:28:03 +0100 Subject: [PATCH 2/6] address review comments re: imports and changelog Signed-off-by: Liam Macpherson --- .../opensearch/indices/stats/ShardStats.java | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java index 84506caa74..00d8d0f308 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java @@ -33,15 +33,34 @@ package org.opensearch.client.opensearch.indices.stats; import jakarta.json.stream.JsonGenerator; -import org.opensearch.client.json.*; -import org.opensearch.client.opensearch._types.*; +import java.util.function.Function; +import javax.annotation.Nullable; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch._types.BulkStats; +import org.opensearch.client.opensearch._types.CompletionStats; +import org.opensearch.client.opensearch._types.DocStats; +import org.opensearch.client.opensearch._types.FielddataStats; +import org.opensearch.client.opensearch._types.FlushStats; +import org.opensearch.client.opensearch._types.GetStats; +import org.opensearch.client.opensearch._types.IndexingStats; +import org.opensearch.client.opensearch._types.MergesStats; +import org.opensearch.client.opensearch._types.RecoveryStats; +import org.opensearch.client.opensearch._types.RefreshStats; +import org.opensearch.client.opensearch._types.RequestCacheStats; +import org.opensearch.client.opensearch._types.SearchStats; +import org.opensearch.client.opensearch._types.SegmentsStats; +import org.opensearch.client.opensearch._types.StoreStats; +import org.opensearch.client.opensearch._types.TranslogStats; +import org.opensearch.client.opensearch._types.WarmerStats; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import javax.annotation.Nullable; -import java.util.function.Function; - // typedef: indices.stats.ShardStats @JsonpDeserializable From 7c764e14876fceac5f0c326b962d1e8101e3a9c3 Mon Sep 17 00:00:00 2001 From: Liam Macpherson Date: Thu, 12 Sep 2024 14:05:56 +0100 Subject: [PATCH 3/6] add test and remove check in constructor Signed-off-by: Liam Macpherson Signed-off-by: Liam Macpherson --- .../opensearch/indices/stats/ShardStats.java | 32 +---- .../opensearch/model/ShardStatsTest.java | 109 ++++++++++++++++++ 2 files changed, 115 insertions(+), 26 deletions(-) create mode 100644 java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java index 00d8d0f308..e65bb314f0 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java @@ -33,34 +33,15 @@ package org.opensearch.client.opensearch.indices.stats; import jakarta.json.stream.JsonGenerator; -import java.util.function.Function; -import javax.annotation.Nullable; -import org.opensearch.client.json.JsonpDeserializable; -import org.opensearch.client.json.JsonpDeserializer; -import org.opensearch.client.json.JsonpMapper; -import org.opensearch.client.json.ObjectBuilderDeserializer; -import org.opensearch.client.json.ObjectDeserializer; -import org.opensearch.client.json.PlainJsonSerializable; -import org.opensearch.client.opensearch._types.BulkStats; -import org.opensearch.client.opensearch._types.CompletionStats; -import org.opensearch.client.opensearch._types.DocStats; -import org.opensearch.client.opensearch._types.FielddataStats; -import org.opensearch.client.opensearch._types.FlushStats; -import org.opensearch.client.opensearch._types.GetStats; -import org.opensearch.client.opensearch._types.IndexingStats; -import org.opensearch.client.opensearch._types.MergesStats; -import org.opensearch.client.opensearch._types.RecoveryStats; -import org.opensearch.client.opensearch._types.RefreshStats; -import org.opensearch.client.opensearch._types.RequestCacheStats; -import org.opensearch.client.opensearch._types.SearchStats; -import org.opensearch.client.opensearch._types.SegmentsStats; -import org.opensearch.client.opensearch._types.StoreStats; -import org.opensearch.client.opensearch._types.TranslogStats; -import org.opensearch.client.opensearch._types.WarmerStats; +import org.opensearch.client.json.*; +import org.opensearch.client.opensearch._types.*; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; +import javax.annotation.Nullable; +import java.util.function.Function; + // typedef: indices.stats.ShardStats @JsonpDeserializable @@ -139,8 +120,7 @@ private ShardStats(Builder builder) { this.translog = ApiTypeHelper.requireNonNull(builder.translog, this, "translog"); this.warmer = ApiTypeHelper.requireNonNull(builder.warmer, this, "warmer"); this.bulk = builder.bulk; - this.shards = ApiTypeHelper.requireNonNull(builder.shards, this, "shards"); - + this.shards = builder.shards; } public static ShardStats of(Function> fn) { diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java new file mode 100644 index 0000000000..2f69168cab --- /dev/null +++ b/java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java @@ -0,0 +1,109 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* + * Modifications Copyright OpenSearch Contributors. See + * GitHub history for details. + */ + +package org.opensearch.client.opensearch.model; + + +import org.junit.Assert; +import org.junit.Test; +import org.opensearch.client.opensearch._types.*; +import org.opensearch.client.opensearch.indices.stats.*; +import org.opensearch.client.util.MissingRequiredPropertyException; + +import java.util.HashMap; + +import static java.util.Collections.emptyList; + +public class ShardStatsTest extends Assert { + + @Test + public void testShardStatsBulkAndShardsPropertiesNotRequired() { + + ShardStats.Builder builder = createShardsStatsBuilderWithRequiredFields(); + + try { + builder.build(); + } catch (MissingRequiredPropertyException e){ + fail(e.getClass().getSimpleName() + " was thrown: " + e.getMessage()); + } + } + + private ShardStats.Builder createShardsStatsBuilderWithRequiredFields() { + ShardCommit commit = new ShardCommit.Builder().id("").generation(0).numDocs(0).userData(new HashMap<>()).build(); + CompletionStats completion = new CompletionStats.Builder().sizeInBytes(0).build(); + DocStats docs = new DocStats.Builder().count(0).deleted(0).build(); + FielddataStats fielddata = new FielddataStats.Builder().memorySizeInBytes(0).build(); + FlushStats flush = new FlushStats.Builder().periodic(0).total(0).totalTimeInMillis(0).build(); + GetStats get = new GetStats.Builder().current(0).existsTimeInMillis(0).existsTotal(0).missingTimeInMillis(0).missingTotal(0).timeInMillis(0).total(0).build(); + IndexingStats indexing = new IndexingStats.Builder().indexCurrent(0).deleteCurrent(0).deleteTimeInMillis(0).deleteTotal(0).isThrottled(false).noopUpdateTotal(0).throttleTimeInMillis(0).indexTimeInMillis(0).indexTotal(0).indexFailed(0).types(new HashMap<>()).build(); + MergesStats merges = new MergesStats.Builder().current(0).currentDocs(0).currentSizeInBytes(0).total(0).totalAutoThrottleInBytes(0).totalDocs(0).totalSizeInBytes(0).totalStoppedTimeInMillis(0).totalThrottledTimeInMillis(0).totalTimeInMillis(0).build(); + ShardPath shardPath = new ShardPath.Builder().dataPath("").isCustomDataPath(false).statePath("").build(); + ShardQueryCache queryCache = new ShardQueryCache.Builder().cacheCount(0).cacheSize(0).evictions(0).hitCount(0).memorySizeInBytes(0).missCount(0).totalCount(0).build(); + RecoveryStats recovery = new RecoveryStats.Builder().currentAsSource(0).currentAsTarget(0).throttleTimeInMillis(0).build(); + RefreshStats refresh = new RefreshStats.Builder().externalTotal(0).externalTotalTimeInMillis(0).listeners(0).total(0).totalTimeInMillis(0).build(); + RequestCacheStats requestCache = new RequestCacheStats.Builder().evictions(0).hitCount(0).memorySizeInBytes(0).missCount(0).build(); + ShardRetentionLeases retentionLeases = new ShardRetentionLeases.Builder().primaryTerm(0).version(0).leases(emptyList()).build(); + ShardRouting routing = new ShardRouting.Builder().node("").primary(false).state(ShardRoutingState.Unassigned).build(); + SearchStats search = new SearchStats.Builder().fetchCurrent(0).fetchTimeInMillis(0).fetchTotal(0).queryCurrent(0).queryTimeInMillis(0).queryTotal(0).scrollCurrent(0).scrollTimeInMillis(0).scrollTotal(0).suggestCurrent(0).suggestTimeInMillis(0).suggestTotal(0).build(); + SegmentsStats segments = new SegmentsStats.Builder().count(0).docValuesMemoryInBytes(0).fileSizes(new HashMap<>()).fixedBitSetMemoryInBytes(0).indexWriterMemoryInBytes(0).maxUnsafeAutoIdTimestamp(0).memoryInBytes(0).normsMemoryInBytes(0).pointsMemoryInBytes(0).storedFieldsMemoryInBytes(0).termsMemoryInBytes(0).termVectorsMemoryInBytes(0).versionMapMemoryInBytes(0).build(); + ShardSequenceNumber seqNo = new ShardSequenceNumber.Builder().globalCheckpoint(0).localCheckpoint(0).maxSeqNo(0).build(); + StoreStats store = new StoreStats.Builder().sizeInBytes(0).reservedInBytes(0).build(); + TranslogStats translog = new TranslogStats.Builder().earliestLastModifiedAge(0).operations(0).sizeInBytes(0).uncommittedOperations(0).uncommittedSizeInBytes(0).build(); + WarmerStats warmer = new WarmerStats.Builder().current(0).total(0).totalTimeInMillis(0).build(); + + ShardStats.Builder builder = new ShardStats.Builder(); + + builder.commit(commit) + .completion(completion) + .docs(docs) + .fielddata(fielddata) + .flush(flush) + .get(get) + .indexing(indexing) + .merges(merges) + .shardPath(shardPath) + .queryCache(queryCache) + .recovery(recovery) + .refresh(refresh) + .requestCache(requestCache) + .retentionLeases(retentionLeases) + .routing(routing) + .search(search) + .segments(segments) + .seqNo(seqNo) + .store(store) + .translog(translog) + .warmer(warmer); + + return builder; + } +} From d42044490cb5502e76da8bc3e1fb8b812eb29a7b Mon Sep 17 00:00:00 2001 From: Liam Macpherson Date: Thu, 12 Sep 2024 14:35:58 +0100 Subject: [PATCH 4/6] re-remove auto import organisation Signed-off-by: Liam Macpherson Signed-off-by: Liam Macpherson --- .../opensearch/indices/stats/ShardStats.java | 29 +++++++++++++++---- .../opensearch/model/ShardStatsTest.java | 25 ++++++++++++++-- 2 files changed, 47 insertions(+), 7 deletions(-) diff --git a/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java b/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java index e65bb314f0..7f7fca54b1 100644 --- a/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java +++ b/java-client/src/main/java/org/opensearch/client/opensearch/indices/stats/ShardStats.java @@ -33,15 +33,34 @@ package org.opensearch.client.opensearch.indices.stats; import jakarta.json.stream.JsonGenerator; -import org.opensearch.client.json.*; -import org.opensearch.client.opensearch._types.*; +import java.util.function.Function; +import javax.annotation.Nullable; +import org.opensearch.client.json.JsonpDeserializable; +import org.opensearch.client.json.JsonpDeserializer; +import org.opensearch.client.json.JsonpMapper; +import org.opensearch.client.json.ObjectBuilderDeserializer; +import org.opensearch.client.json.ObjectDeserializer; +import org.opensearch.client.json.PlainJsonSerializable; +import org.opensearch.client.opensearch._types.BulkStats; +import org.opensearch.client.opensearch._types.CompletionStats; +import org.opensearch.client.opensearch._types.DocStats; +import org.opensearch.client.opensearch._types.FielddataStats; +import org.opensearch.client.opensearch._types.FlushStats; +import org.opensearch.client.opensearch._types.GetStats; +import org.opensearch.client.opensearch._types.IndexingStats; +import org.opensearch.client.opensearch._types.MergesStats; +import org.opensearch.client.opensearch._types.RecoveryStats; +import org.opensearch.client.opensearch._types.RefreshStats; +import org.opensearch.client.opensearch._types.RequestCacheStats; +import org.opensearch.client.opensearch._types.SearchStats; +import org.opensearch.client.opensearch._types.SegmentsStats; +import org.opensearch.client.opensearch._types.StoreStats; +import org.opensearch.client.opensearch._types.TranslogStats; +import org.opensearch.client.opensearch._types.WarmerStats; import org.opensearch.client.util.ApiTypeHelper; import org.opensearch.client.util.ObjectBuilder; import org.opensearch.client.util.ObjectBuilderBase; -import javax.annotation.Nullable; -import java.util.function.Function; - // typedef: indices.stats.ShardStats @JsonpDeserializable diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java index 2f69168cab..877922eecd 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java @@ -35,8 +35,29 @@ import org.junit.Assert; import org.junit.Test; -import org.opensearch.client.opensearch._types.*; -import org.opensearch.client.opensearch.indices.stats.*; +import org.opensearch.client.opensearch._types.CompletionStats; +import org.opensearch.client.opensearch._types.DocStats; +import org.opensearch.client.opensearch._types.FielddataStats; +import org.opensearch.client.opensearch._types.FlushStats; +import org.opensearch.client.opensearch._types.GetStats; +import org.opensearch.client.opensearch._types.IndexingStats; +import org.opensearch.client.opensearch._types.MergesStats; +import org.opensearch.client.opensearch._types.RecoveryStats; +import org.opensearch.client.opensearch._types.RefreshStats; +import org.opensearch.client.opensearch._types.RequestCacheStats; +import org.opensearch.client.opensearch._types.SearchStats; +import org.opensearch.client.opensearch._types.SegmentsStats; +import org.opensearch.client.opensearch._types.StoreStats; +import org.opensearch.client.opensearch._types.TranslogStats; +import org.opensearch.client.opensearch._types.WarmerStats; +import org.opensearch.client.opensearch.indices.stats.ShardCommit; +import org.opensearch.client.opensearch.indices.stats.ShardPath; +import org.opensearch.client.opensearch.indices.stats.ShardQueryCache; +import org.opensearch.client.opensearch.indices.stats.ShardRetentionLeases; +import org.opensearch.client.opensearch.indices.stats.ShardRouting; +import org.opensearch.client.opensearch.indices.stats.ShardRoutingState; +import org.opensearch.client.opensearch.indices.stats.ShardSequenceNumber; +import org.opensearch.client.opensearch.indices.stats.ShardStats; import org.opensearch.client.util.MissingRequiredPropertyException; import java.util.HashMap; From 1678ef2f4d381b28da88ecea38cbecc8ec653ad4 Mon Sep 17 00:00:00 2001 From: Liam Macpherson Date: Mon, 16 Sep 2024 10:15:30 +0100 Subject: [PATCH 5/6] chore: correct changelog link Signed-off-by: Liam Macpherson --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5004c7fefd..7c088b7e59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,7 +49,7 @@ This section is for maintaining a changelog for all breaking changes for the cli ### Fixed - Fix queries not preserving boost and name when converted to builders ([#1181](https://github.com/opensearch-project/opensearch-java/pull/1181)) -- Remove required check on ShardStats.shards ([#XXX](https://github.com/opensearch-project/opensearch-java/pull/XXX)) +- Remove required check on ShardStats.shards ([#1177](https://github.com/opensearch-project/opensearch-java/pull/1177)) ### Security @@ -549,4 +549,4 @@ This section is for maintaining a changelog for all breaking changes for the cli [2.5.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.4.0...v2.5.0 [2.4.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.3.0...v2.4.0 [2.3.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.2.0...v2.3.0 -[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0 \ No newline at end of file +[2.2.0]: https://github.com/opensearch-project/opensearch-java/compare/v2.1.0...v2.2.0 From 82a78feaa5b5d7ea90bf535268a75f1e3ad1992f Mon Sep 17 00:00:00 2001 From: Liam Macpherson Date: Tue, 17 Sep 2024 09:49:34 +0100 Subject: [PATCH 6/6] spotlessApply tidyup Signed-off-by: Liam Macpherson Signed-off-by: Liam Macpherson --- .../opensearch/model/ShardStatsTest.java | 134 +++++++++++++----- 1 file changed, 101 insertions(+), 33 deletions(-) diff --git a/java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java b/java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java index 877922eecd..e86d347514 100644 --- a/java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java +++ b/java-client/src/test/java/org/opensearch/client/opensearch/model/ShardStatsTest.java @@ -32,7 +32,9 @@ package org.opensearch.client.opensearch.model; +import static java.util.Collections.emptyList; +import java.util.HashMap; import org.junit.Assert; import org.junit.Test; import org.opensearch.client.opensearch._types.CompletionStats; @@ -60,10 +62,6 @@ import org.opensearch.client.opensearch.indices.stats.ShardStats; import org.opensearch.client.util.MissingRequiredPropertyException; -import java.util.HashMap; - -import static java.util.Collections.emptyList; - public class ShardStatsTest extends Assert { @Test @@ -73,7 +71,7 @@ public void testShardStatsBulkAndShardsPropertiesNotRequired() { try { builder.build(); - } catch (MissingRequiredPropertyException e){ + } catch (MissingRequiredPropertyException e) { fail(e.getClass().getSimpleName() + " was thrown: " + e.getMessage()); } } @@ -84,46 +82,116 @@ private ShardStats.Builder createShardsStatsBuilderWithRequiredFields() { DocStats docs = new DocStats.Builder().count(0).deleted(0).build(); FielddataStats fielddata = new FielddataStats.Builder().memorySizeInBytes(0).build(); FlushStats flush = new FlushStats.Builder().periodic(0).total(0).totalTimeInMillis(0).build(); - GetStats get = new GetStats.Builder().current(0).existsTimeInMillis(0).existsTotal(0).missingTimeInMillis(0).missingTotal(0).timeInMillis(0).total(0).build(); - IndexingStats indexing = new IndexingStats.Builder().indexCurrent(0).deleteCurrent(0).deleteTimeInMillis(0).deleteTotal(0).isThrottled(false).noopUpdateTotal(0).throttleTimeInMillis(0).indexTimeInMillis(0).indexTotal(0).indexFailed(0).types(new HashMap<>()).build(); - MergesStats merges = new MergesStats.Builder().current(0).currentDocs(0).currentSizeInBytes(0).total(0).totalAutoThrottleInBytes(0).totalDocs(0).totalSizeInBytes(0).totalStoppedTimeInMillis(0).totalThrottledTimeInMillis(0).totalTimeInMillis(0).build(); + GetStats get = new GetStats.Builder().current(0) + .existsTimeInMillis(0) + .existsTotal(0) + .missingTimeInMillis(0) + .missingTotal(0) + .timeInMillis(0) + .total(0) + .build(); + IndexingStats indexing = new IndexingStats.Builder().indexCurrent(0) + .deleteCurrent(0) + .deleteTimeInMillis(0) + .deleteTotal(0) + .isThrottled(false) + .noopUpdateTotal(0) + .throttleTimeInMillis(0) + .indexTimeInMillis(0) + .indexTotal(0) + .indexFailed(0) + .types(new HashMap<>()) + .build(); + MergesStats merges = new MergesStats.Builder().current(0) + .currentDocs(0) + .currentSizeInBytes(0) + .total(0) + .totalAutoThrottleInBytes(0) + .totalDocs(0) + .totalSizeInBytes(0) + .totalStoppedTimeInMillis(0) + .totalThrottledTimeInMillis(0) + .totalTimeInMillis(0) + .build(); ShardPath shardPath = new ShardPath.Builder().dataPath("").isCustomDataPath(false).statePath("").build(); - ShardQueryCache queryCache = new ShardQueryCache.Builder().cacheCount(0).cacheSize(0).evictions(0).hitCount(0).memorySizeInBytes(0).missCount(0).totalCount(0).build(); + ShardQueryCache queryCache = new ShardQueryCache.Builder().cacheCount(0) + .cacheSize(0) + .evictions(0) + .hitCount(0) + .memorySizeInBytes(0) + .missCount(0) + .totalCount(0) + .build(); RecoveryStats recovery = new RecoveryStats.Builder().currentAsSource(0).currentAsTarget(0).throttleTimeInMillis(0).build(); - RefreshStats refresh = new RefreshStats.Builder().externalTotal(0).externalTotalTimeInMillis(0).listeners(0).total(0).totalTimeInMillis(0).build(); + RefreshStats refresh = new RefreshStats.Builder().externalTotal(0) + .externalTotalTimeInMillis(0) + .listeners(0) + .total(0) + .totalTimeInMillis(0) + .build(); RequestCacheStats requestCache = new RequestCacheStats.Builder().evictions(0).hitCount(0).memorySizeInBytes(0).missCount(0).build(); ShardRetentionLeases retentionLeases = new ShardRetentionLeases.Builder().primaryTerm(0).version(0).leases(emptyList()).build(); ShardRouting routing = new ShardRouting.Builder().node("").primary(false).state(ShardRoutingState.Unassigned).build(); - SearchStats search = new SearchStats.Builder().fetchCurrent(0).fetchTimeInMillis(0).fetchTotal(0).queryCurrent(0).queryTimeInMillis(0).queryTotal(0).scrollCurrent(0).scrollTimeInMillis(0).scrollTotal(0).suggestCurrent(0).suggestTimeInMillis(0).suggestTotal(0).build(); - SegmentsStats segments = new SegmentsStats.Builder().count(0).docValuesMemoryInBytes(0).fileSizes(new HashMap<>()).fixedBitSetMemoryInBytes(0).indexWriterMemoryInBytes(0).maxUnsafeAutoIdTimestamp(0).memoryInBytes(0).normsMemoryInBytes(0).pointsMemoryInBytes(0).storedFieldsMemoryInBytes(0).termsMemoryInBytes(0).termVectorsMemoryInBytes(0).versionMapMemoryInBytes(0).build(); + SearchStats search = new SearchStats.Builder().fetchCurrent(0) + .fetchTimeInMillis(0) + .fetchTotal(0) + .queryCurrent(0) + .queryTimeInMillis(0) + .queryTotal(0) + .scrollCurrent(0) + .scrollTimeInMillis(0) + .scrollTotal(0) + .suggestCurrent(0) + .suggestTimeInMillis(0) + .suggestTotal(0) + .build(); + SegmentsStats segments = new SegmentsStats.Builder().count(0) + .docValuesMemoryInBytes(0) + .fileSizes(new HashMap<>()) + .fixedBitSetMemoryInBytes(0) + .indexWriterMemoryInBytes(0) + .maxUnsafeAutoIdTimestamp(0) + .memoryInBytes(0) + .normsMemoryInBytes(0) + .pointsMemoryInBytes(0) + .storedFieldsMemoryInBytes(0) + .termsMemoryInBytes(0) + .termVectorsMemoryInBytes(0) + .versionMapMemoryInBytes(0) + .build(); ShardSequenceNumber seqNo = new ShardSequenceNumber.Builder().globalCheckpoint(0).localCheckpoint(0).maxSeqNo(0).build(); StoreStats store = new StoreStats.Builder().sizeInBytes(0).reservedInBytes(0).build(); - TranslogStats translog = new TranslogStats.Builder().earliestLastModifiedAge(0).operations(0).sizeInBytes(0).uncommittedOperations(0).uncommittedSizeInBytes(0).build(); + TranslogStats translog = new TranslogStats.Builder().earliestLastModifiedAge(0) + .operations(0) + .sizeInBytes(0) + .uncommittedOperations(0) + .uncommittedSizeInBytes(0) + .build(); WarmerStats warmer = new WarmerStats.Builder().current(0).total(0).totalTimeInMillis(0).build(); ShardStats.Builder builder = new ShardStats.Builder(); builder.commit(commit) - .completion(completion) - .docs(docs) - .fielddata(fielddata) - .flush(flush) - .get(get) - .indexing(indexing) - .merges(merges) - .shardPath(shardPath) - .queryCache(queryCache) - .recovery(recovery) - .refresh(refresh) - .requestCache(requestCache) - .retentionLeases(retentionLeases) - .routing(routing) - .search(search) - .segments(segments) - .seqNo(seqNo) - .store(store) - .translog(translog) - .warmer(warmer); + .completion(completion) + .docs(docs) + .fielddata(fielddata) + .flush(flush) + .get(get) + .indexing(indexing) + .merges(merges) + .shardPath(shardPath) + .queryCache(queryCache) + .recovery(recovery) + .refresh(refresh) + .requestCache(requestCache) + .retentionLeases(retentionLeases) + .routing(routing) + .search(search) + .segments(segments) + .seqNo(seqNo) + .store(store) + .translog(translog) + .warmer(warmer); return builder; }