From 2a1e732e390f0de3a3c2bcfe794b52fface4217d Mon Sep 17 00:00:00 2001 From: Marc Handalian Date: Sun, 12 Mar 2023 13:04:33 -0700 Subject: [PATCH] Remove from nodestats api. Signed-off-by: Marc Handalian --- .../http/SegmentReplicationRestIT.java | 96 ------------------- .../admin/cluster/node/stats/NodeStats.java | 23 +---- .../main/java/org/opensearch/node/Node.java | 1 - .../java/org/opensearch/node/NodeService.java | 6 -- .../cluster/node/stats/NodeStatsTests.java | 3 +- .../opensearch/cluster/DiskUsageTests.java | 18 ++-- .../MockInternalClusterInfoService.java | 3 +- 7 files changed, 9 insertions(+), 141 deletions(-) delete mode 100644 qa/smoke-test-http/src/test/java/org/opensearch/http/SegmentReplicationRestIT.java diff --git a/qa/smoke-test-http/src/test/java/org/opensearch/http/SegmentReplicationRestIT.java b/qa/smoke-test-http/src/test/java/org/opensearch/http/SegmentReplicationRestIT.java deleted file mode 100644 index 44bfc56b5d806..0000000000000 --- a/qa/smoke-test-http/src/test/java/org/opensearch/http/SegmentReplicationRestIT.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * 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. - */ - -package org.opensearch.http; - -import org.apache.hc.core5.http.io.entity.EntityUtils; -import org.opensearch.client.Node; -import org.opensearch.client.Request; -import org.opensearch.client.Response; -import org.opensearch.common.settings.Settings; -import org.opensearch.common.util.FeatureFlags; -import org.opensearch.common.xcontent.XContentHelper; -import org.opensearch.common.xcontent.json.JsonXContent; -import org.opensearch.test.OpenSearchIntegTestCase; -import org.opensearch.test.XContentTestUtils; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static org.opensearch.rest.RestStatus.CREATED; -import static org.opensearch.rest.RestStatus.OK; -import static org.opensearch.test.hamcrest.OpenSearchAssertions.assertHitCount; - -@OpenSearchIntegTestCase.ClusterScope(scope = OpenSearchIntegTestCase.Scope.SUITE, supportsDedicatedMasters = false, numDataNodes = 2, - numClientNodes = 0) -public class SegmentReplicationRestIT extends HttpSmokeTestCase { - - @Override - protected Settings featureFlagSettings() { - return Settings.builder().put(super.featureFlagSettings()).put(FeatureFlags.REPLICATION_TYPE, "true").build(); - } - - @Override - protected boolean addMockInternalEngine() { - return false; - } - - @SuppressWarnings("unchecked") - public void testSegmentReplicationStats() throws Exception { - // create index. - Request createRequest = new Request("PUT", "/test_index"); - createRequest.setJsonEntity("{\"settings\": {\"index\": {\"number_of_shards\": 1, \"number_of_replicas\": 1, " + - "\"replication\": {\"type\": \"SEGMENT\"}}}}"); - final Response indexCreatedResponse = getRestClient().performRequest(createRequest); - assertEquals(indexCreatedResponse.getStatusLine().getStatusCode(), OK.getStatus()); - ensureGreen("test_index"); - - //index a doc - Request successfulIndexingRequest = new Request("POST", "/test_index/_doc/"); - successfulIndexingRequest.setJsonEntity("{\"foo\": \"bar\"}"); - final Response indexSuccessFul = getRestClient().performRequest(successfulIndexingRequest); - assertEquals(indexSuccessFul.getStatusLine().getStatusCode(), CREATED.getStatus()); - - assertBusy(() -> { - // wait for SR to run. - for (Node node : getRestClient().getNodes()) { - assertHitCount(client(node.getName()).prepareSearch("test_index").setSize(0).setPreference("_only_local").get(), 1); - } - }); - Request statsRequest = new Request("GET", "/_nodes/stats/segment_replication?pretty"); - final Response response = getRestClient().performRequest(statsRequest); - logger.info("Node stats response\n{}", EntityUtils.toString(response.getEntity())); - Map statsMap = XContentHelper.convertToMap(JsonXContent.jsonXContent, response.getEntity().getContent(), - true); - List nodes = new ArrayList<>(((Map) statsMap.get("nodes")).values()); - assertEquals(2, nodes.size()); - XContentTestUtils.JsonMapView node1 = new XContentTestUtils.JsonMapView((Map) nodes.get(0)); - final Map node1_map = node1.get("segment_replication"); - Map primaryNode_map = node1_map; - if (node1_map.isEmpty()) { - XContentTestUtils.JsonMapView node2 = new XContentTestUtils.JsonMapView((Map) nodes.get(1)); - primaryNode_map = node2.get("segment_replication"); - } - List primary_values = new ArrayList<>(primaryNode_map - .values()); - assertEquals(1, primary_values.size()); - XContentTestUtils.JsonMapView shard1 = new XContentTestUtils.JsonMapView((Map) primary_values.get(0)); - Integer node1TotalLimitsRejections = shard1.get("rejected_requests"); - assertNotNull(node1TotalLimitsRejections); - List shard1_replicas = shard1.get("replicas"); - assertEquals(1, shard1_replicas.size()); - XContentTestUtils.JsonMapView replica = new XContentTestUtils.JsonMapView((Map) shard1_replicas.get(0)); - Integer checkpoints_behind = replica.get("checkpoints_behind"); - assertEquals(0, checkpoints_behind.intValue()); - assertNotNull(replica.get("node_id")); - assertNotNull(replica.get("current_replication_time")); - assertNotNull(replica.get("last_completed_replication_time")); - assertNotNull(replica.get("bytes_behind")); - } -} diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java index 1ab32a9f49ccb..6d151843219bd 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/node/stats/NodeStats.java @@ -46,7 +46,6 @@ import org.opensearch.core.xcontent.XContentBuilder; import org.opensearch.discovery.DiscoveryStats; import org.opensearch.http.HttpStats; -import org.opensearch.index.SegmentReplicationStats; import org.opensearch.index.stats.IndexingPressureStats; import org.opensearch.index.stats.ShardIndexingPressureStats; import org.opensearch.index.store.remote.filecache.FileCacheStats; @@ -124,9 +123,6 @@ public class NodeStats extends BaseNodeResponse implements ToXContentFragment { @Nullable private ShardIndexingPressureStats shardIndexingPressureStats; - @Nullable - private SegmentReplicationStats segmentReplicationStats; - @Nullable private SearchBackpressureStats searchBackpressureStats; @@ -185,11 +181,6 @@ public NodeStats(StreamInput in) throws IOException { } else { fileCacheStats = null; } - if (in.getVersion().onOrAfter(Version.V_2_7_0) && FeatureFlags.isEnabled(FeatureFlags.REPLICATION_TYPE)) { - segmentReplicationStats = in.readOptionalWriteable(SegmentReplicationStats::new); - } else { - segmentReplicationStats = null; - } } public NodeStats( @@ -211,7 +202,6 @@ public NodeStats( @Nullable ScriptCacheStats scriptCacheStats, @Nullable IndexingPressureStats indexingPressureStats, @Nullable ShardIndexingPressureStats shardIndexingPressureStats, - @Nullable SegmentReplicationStats segmentReplicationStats, @Nullable SearchBackpressureStats searchBackpressureStats, @Nullable ClusterManagerThrottlingStats clusterManagerThrottlingStats, @Nullable WeightedRoutingStats weightedRoutingStats, @@ -235,7 +225,6 @@ public NodeStats( this.scriptCacheStats = scriptCacheStats; this.indexingPressureStats = indexingPressureStats; this.shardIndexingPressureStats = shardIndexingPressureStats; - this.segmentReplicationStats = segmentReplicationStats; this.searchBackpressureStats = searchBackpressureStats; this.clusterManagerThrottlingStats = clusterManagerThrottlingStats; this.weightedRoutingStats = weightedRoutingStats; @@ -349,11 +338,6 @@ public ShardIndexingPressureStats getShardIndexingPressureStats() { return shardIndexingPressureStats; } - @Nullable - public SegmentReplicationStats getSegmentReplicationStats() { - return segmentReplicationStats; - } - @Nullable public SearchBackpressureStats getSearchBackpressureStats() { return searchBackpressureStats; @@ -409,9 +393,6 @@ public void writeTo(StreamOutput out) throws IOException { if (out.getVersion().onOrAfter(Version.V_3_0_0) && FeatureFlags.isEnabled(FeatureFlags.SEARCHABLE_SNAPSHOT)) { out.writeOptionalWriteable(fileCacheStats); } - if (out.getVersion().onOrAfter(Version.V_2_7_0) && FeatureFlags.isEnabled(FeatureFlags.REPLICATION_TYPE)) { - out.writeOptionalWriteable(segmentReplicationStats); - } } @Override @@ -496,9 +477,7 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (getFileCacheStats() != null && FeatureFlags.isEnabled(FeatureFlags.SEARCHABLE_SNAPSHOT)) { getFileCacheStats().toXContent(builder, params); } - if (getSegmentReplicationStats() != null && FeatureFlags.isEnabled(FeatureFlags.REPLICATION_TYPE)) { - getSegmentReplicationStats().toXContent(builder, params); - } + return builder; } } diff --git a/server/src/main/java/org/opensearch/node/Node.java b/server/src/main/java/org/opensearch/node/Node.java index 2e806eed6c760..183eb0b4d6c84 100644 --- a/server/src/main/java/org/opensearch/node/Node.java +++ b/server/src/main/java/org/opensearch/node/Node.java @@ -973,7 +973,6 @@ protected Node( responseCollectorService, searchTransportService, indexingPressureService, - segmentReplicationPressureService, searchModule.getValuesSourceRegistry().getUsageService(), searchBackpressureService, nodeEnvironment diff --git a/server/src/main/java/org/opensearch/node/NodeService.java b/server/src/main/java/org/opensearch/node/NodeService.java index e5be5276e1ab5..b4446085243df 100644 --- a/server/src/main/java/org/opensearch/node/NodeService.java +++ b/server/src/main/java/org/opensearch/node/NodeService.java @@ -48,7 +48,6 @@ import org.opensearch.env.NodeEnvironment; import org.opensearch.http.HttpServerTransport; import org.opensearch.index.IndexingPressureService; -import org.opensearch.index.SegmentReplicationPressureService; import org.opensearch.indices.IndicesService; import org.opensearch.indices.breaker.CircuitBreakerService; import org.opensearch.ingest.IngestService; @@ -84,7 +83,6 @@ public class NodeService implements Closeable { private final ResponseCollectorService responseCollectorService; private final SearchTransportService searchTransportService; private final IndexingPressureService indexingPressureService; - private final SegmentReplicationPressureService segmentReplicationPressureService; private final AggregationUsageService aggregationUsageService; private final SearchBackpressureService searchBackpressureService; private final ClusterService clusterService; @@ -108,7 +106,6 @@ public class NodeService implements Closeable { ResponseCollectorService responseCollectorService, SearchTransportService searchTransportService, IndexingPressureService indexingPressureService, - SegmentReplicationPressureService segmentReplicationPressureService, AggregationUsageService aggregationUsageService, SearchBackpressureService searchBackpressureService, NodeEnvironment nodeEnvironment @@ -128,7 +125,6 @@ public class NodeService implements Closeable { this.responseCollectorService = responseCollectorService; this.searchTransportService = searchTransportService; this.indexingPressureService = indexingPressureService; - this.segmentReplicationPressureService = segmentReplicationPressureService; this.aggregationUsageService = aggregationUsageService; this.searchBackpressureService = searchBackpressureService; this.clusterService = clusterService; @@ -184,7 +180,6 @@ public NodeStats stats( boolean scriptCache, boolean indexingPressure, boolean shardIndexingPressure, - boolean segmentReplicationPressure, boolean searchBackpressure, boolean clusterManagerThrottling, boolean weightedRoutingStats, @@ -211,7 +206,6 @@ public NodeStats stats( scriptCache ? scriptService.cacheStats() : null, indexingPressure ? this.indexingPressureService.nodeStats() : null, shardIndexingPressure ? this.indexingPressureService.shardStats(indices) : null, - segmentReplicationPressure ? this.segmentReplicationPressureService.nodeStats() : null, searchBackpressure ? this.searchBackpressureService.nodeStats() : null, clusterManagerThrottling ? this.clusterService.getClusterManagerService().getThrottlingStats() : null, weightedRoutingStats ? WeightedRoutingStats.getInstance() : null, diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/node/stats/NodeStatsTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/node/stats/NodeStatsTests.java index a0245aa5abe15..5a9fa29e9df21 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/node/stats/NodeStatsTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/node/stats/NodeStatsTests.java @@ -746,8 +746,7 @@ public static NodeStats createNodeStats() { scriptCacheStats, null, null, - null, - null, + null, clusterManagerThrottlingStats, weightedRoutingStats, null diff --git a/server/src/test/java/org/opensearch/cluster/DiskUsageTests.java b/server/src/test/java/org/opensearch/cluster/DiskUsageTests.java index fbc9010dba7c7..5c725cb241de9 100644 --- a/server/src/test/java/org/opensearch/cluster/DiskUsageTests.java +++ b/server/src/test/java/org/opensearch/cluster/DiskUsageTests.java @@ -186,8 +186,7 @@ public void testFillDiskUsage() { null, null, null, - null, - null, + null, null, null, null @@ -211,8 +210,7 @@ public void testFillDiskUsage() { null, null, null, - null, - null, + null, null, null, null @@ -236,8 +234,7 @@ public void testFillDiskUsage() { null, null, null, - null, - null, + null, null, null, null @@ -292,8 +289,7 @@ public void testFillDiskUsageSomeInvalidValues() { null, null, null, - null, - null, + null, null, null, null @@ -317,8 +313,7 @@ public void testFillDiskUsageSomeInvalidValues() { null, null, null, - null, - null, + null, null, null, null @@ -342,8 +337,7 @@ public void testFillDiskUsageSomeInvalidValues() { null, null, null, - null, - null, + null, null, null, null diff --git a/test/framework/src/main/java/org/opensearch/cluster/MockInternalClusterInfoService.java b/test/framework/src/main/java/org/opensearch/cluster/MockInternalClusterInfoService.java index fbfcf66856d09..5f099d735a22a 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/MockInternalClusterInfoService.java +++ b/test/framework/src/main/java/org/opensearch/cluster/MockInternalClusterInfoService.java @@ -115,8 +115,7 @@ List adjustNodesStats(List nodesStats) { nodeStats.getScriptCacheStats(), nodeStats.getIndexingPressureStats(), nodeStats.getShardIndexingPressureStats(), - nodeStats.getSegmentReplicationStats(), - nodeStats.getSearchBackpressureStats(), + nodeStats.getSearchBackpressureStats(), nodeStats.getClusterManagerThrottlingStats(), nodeStats.getWeightedRoutingStats(), nodeStats.getFileCacheStats()