diff --git a/docs/changelog/83832.yaml b/docs/changelog/83832.yaml deleted file mode 100644 index 5d50b0cf7a2d3..0000000000000 --- a/docs/changelog/83832.yaml +++ /dev/null @@ -1,6 +0,0 @@ -pr: 83832 -summary: Push back excessive stats requests -area: Stats -type: enhancement -issues: - - 51992 diff --git a/docs/reference/cluster/nodes-stats.asciidoc b/docs/reference/cluster/nodes-stats.asciidoc index 194f70e2c0929..16509b721461c 100644 --- a/docs/reference/cluster/nodes-stats.asciidoc +++ b/docs/reference/cluster/nodes-stats.asciidoc @@ -91,10 +91,6 @@ using metrics. `transport`:: Transport statistics about sent and received bytes in cluster communication. - - `stats_requests`:: - Statistics about stats requests such as indices stats, nodes stats, - recovery stats etc. -- ``:: @@ -2647,37 +2643,6 @@ search requests on the keyed node. The rank of this node; used for shard selection when routing search requests. ====== -====== - -[[cluster-nodes-stats-api-response-body-stats-requests]] -`stats_requests`:: -(object) -Contains statistics about the stats requests the node has received. -+ -.Properties of `stats_requests` -[%collapsible%open] -====== -``:: -(object) -Contains statistics about a specific type of a stats request the node has received. -+ -.Properties of `` -[%collapsible%open] -======= -`current`:: -(integer) -Number of stats requests currently in progress. - -`completed`:: -(integer) -Number of stats requests that have been completed by the node (successfully or -not). - -`rejected`:: -(integer) -Number of stats requests that were rejected by the node because it had reached -the limit of concurrent stats requests (`node.stats.max_concurrent_requests`). -======= ===== ==== diff --git a/docs/reference/modules/cluster/misc.asciidoc b/docs/reference/modules/cluster/misc.asciidoc index 4590f6870205b..83adaef9ec1a0 100644 --- a/docs/reference/modules/cluster/misc.asciidoc +++ b/docs/reference/modules/cluster/misc.asciidoc @@ -101,24 +101,6 @@ number of shards for each node, use the setting. -- -[[stats-requests-limit]] -===== Stats request limit - -A stats request might require information from all nodes to be aggregated before it returns to the user. -These requests can be heavy and they put extra pressure on the coordinating node (the node collecting the -responses from all the nodes), for this reason there is a limit on the concurrent requests that a node can coordinate. - --- - -[[node-stats-max-concurrent-requests]] -`node.stats.max_concurrent_requests`:: -+ --- -(<>) -Limits the stats requests a coordinating node can concurrently handle. Defaults to `100`. - - - [[user-defined-data]] ===== User-defined cluster metadata diff --git a/server/src/internalClusterTest/java/org/elasticsearch/indices/stats/IndexStatsIT.java b/server/src/internalClusterTest/java/org/elasticsearch/indices/stats/IndexStatsIT.java index 82850fd67b7df..96f3f0d1495f0 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/indices/stats/IndexStatsIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/indices/stats/IndexStatsIT.java @@ -79,7 +79,6 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicReference; -import static org.elasticsearch.action.support.StatsRequestLimiter.MAX_CONCURRENT_STATS_REQUESTS_PER_NODE; import static org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAllSuccessful; @@ -1387,57 +1386,52 @@ public void testConcurrentIndexingAndStatsRequests() throws BrokenBarrierExcepti } // start threads that will get stats concurrently with indexing - try { - updateClusterSettings(Settings.builder().put(MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey(), numberOfStatsThreads + 1)); - for (int i = 0; i < numberOfStatsThreads; i++) { - final Thread thread = new Thread(() -> { + for (int i = 0; i < numberOfStatsThreads; i++) { + final Thread thread = new Thread(() -> { + try { + barrier.await(); + } catch (final BrokenBarrierException | InterruptedException e) { + failed.set(true); + executionFailures.get().add(e); + latch.countDown(); + } + final IndicesStatsRequest request = new IndicesStatsRequest(); + request.all(); + request.indices(new String[0]); + while (stop.get() == false) { try { - barrier.await(); - } catch (final BrokenBarrierException | InterruptedException e) { - failed.set(true); - executionFailures.get().add(e); - latch.countDown(); - } - final IndicesStatsRequest request = new IndicesStatsRequest(); - request.all(); - request.indices(new String[0]); - while (stop.get() == false) { - try { - final IndicesStatsResponse response = client().admin().indices().stats(request).get(); - if (response.getFailedShards() > 0) { - failed.set(true); - shardFailures.get().addAll(Arrays.asList(response.getShardFailures())); - latch.countDown(); - } - } catch (final ExecutionException | InterruptedException e) { + final IndicesStatsResponse response = client().admin().indices().stats(request).get(); + if (response.getFailedShards() > 0) { failed.set(true); - executionFailures.get().add(e); + shardFailures.get().addAll(Arrays.asList(response.getShardFailures())); latch.countDown(); } + } catch (final ExecutionException | InterruptedException e) { + failed.set(true); + executionFailures.get().add(e); + latch.countDown(); } - }); - thread.setName("stats-" + i); - threads.add(thread); - thread.start(); - } - - // release the hounds - barrier.await(); + } + }); + thread.setName("stats-" + i); + threads.add(thread); + thread.start(); + } - // wait for a failure, or for fifteen seconds to elapse - latch.await(15, TimeUnit.SECONDS); + // release the hounds + barrier.await(); - // stop all threads and wait for them to complete - stop.set(true); - for (final Thread thread : threads) { - thread.join(); - } + // wait for a failure, or for fifteen seconds to elapse + latch.await(15, TimeUnit.SECONDS); - assertThat(shardFailures.get(), emptyCollectionOf(DefaultShardOperationFailedException.class)); - assertThat(executionFailures.get(), emptyCollectionOf(Exception.class)); - } finally { - updateClusterSettings(Settings.builder().putNull(MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey())); + // stop all threads and wait for them to complete + stop.set(true); + for (final Thread thread : threads) { + thread.join(); } + + assertThat(shardFailures.get(), emptyCollectionOf(DefaultShardOperationFailedException.class)); + assertThat(executionFailures.get(), emptyCollectionOf(Exception.class)); } /** diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/TransportNodesInfoAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/TransportNodesInfoAction.java index 40372dd6e974a..85364d5879895 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/TransportNodesInfoAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/info/TransportNodesInfoAction.java @@ -8,10 +8,8 @@ package org.elasticsearch.action.admin.cluster.node.info; -import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.StatsRequestLimiter; import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.service.ClusterService; @@ -35,7 +33,6 @@ public class TransportNodesInfoAction extends TransportNodesAction< NodeInfo> { private final NodeService nodeService; - private final StatsRequestLimiter statsRequestLimiter; @Inject public TransportNodesInfoAction( @@ -43,8 +40,7 @@ public TransportNodesInfoAction( ClusterService clusterService, TransportService transportService, NodeService nodeService, - ActionFilters actionFilters, - StatsRequestLimiter statsRequestLimiter + ActionFilters actionFilters ) { super( NodesInfoAction.NAME, @@ -58,7 +54,6 @@ public TransportNodesInfoAction( NodeInfo.class ); this.nodeService = nodeService; - this.statsRequestLimiter = statsRequestLimiter; } @Override @@ -99,11 +94,6 @@ protected NodeInfo nodeOperation(NodeInfoRequest nodeRequest, Task task) { ); } - @Override - protected void doExecute(Task task, NodesInfoRequest request, ActionListener listener) { - statsRequestLimiter.tryToExecute(task, request, listener, super::doExecute); - } - public static class NodeInfoRequest extends TransportRequest { NodesInfoRequest request; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java index 46bb54306826d..0af4ddefd5bda 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStats.java @@ -8,8 +8,6 @@ package org.elasticsearch.action.admin.cluster.node.stats; -import org.elasticsearch.Version; -import org.elasticsearch.action.support.StatsRequestStats; import org.elasticsearch.action.support.nodes.BaseNodeResponse; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.node.DiscoveryNodeRole; @@ -89,9 +87,6 @@ public class NodeStats extends BaseNodeResponse implements ToXContentFragment { @Nullable private IndexingPressureStats indexingPressureStats; - @Nullable - private StatsRequestStats statsRequestStats; - public NodeStats(StreamInput in) throws IOException { super(in); timestamp = in.readVLong(); @@ -112,9 +107,6 @@ public NodeStats(StreamInput in) throws IOException { ingestStats = in.readOptionalWriteable(IngestStats::new); adaptiveSelectionStats = in.readOptionalWriteable(AdaptiveSelectionStats::new); indexingPressureStats = in.readOptionalWriteable(IndexingPressureStats::new); - if (in.getVersion().onOrAfter(Version.V_8_3_0)) { - statsRequestStats = in.readOptionalWriteable(StatsRequestStats::new); - } } public NodeStats( @@ -134,8 +126,7 @@ public NodeStats( @Nullable IngestStats ingestStats, @Nullable AdaptiveSelectionStats adaptiveSelectionStats, @Nullable ScriptCacheStats scriptCacheStats, - @Nullable IndexingPressureStats indexingPressureStats, - @Nullable StatsRequestStats statsRequestStats + @Nullable IndexingPressureStats indexingPressureStats ) { super(node); this.timestamp = timestamp; @@ -154,7 +145,6 @@ public NodeStats( this.adaptiveSelectionStats = adaptiveSelectionStats; this.scriptCacheStats = scriptCacheStats; this.indexingPressureStats = indexingPressureStats; - this.statsRequestStats = statsRequestStats; } public long getTimestamp() { @@ -259,11 +249,6 @@ public IndexingPressureStats getIndexingPressureStats() { return indexingPressureStats; } - @Nullable - public StatsRequestStats getStatsRequestStats() { - return statsRequestStats; - } - @Override public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); @@ -287,9 +272,6 @@ public void writeTo(StreamOutput out) throws IOException { out.writeOptionalWriteable(ingestStats); out.writeOptionalWriteable(adaptiveSelectionStats); out.writeOptionalWriteable(indexingPressureStats); - if (out.getVersion().onOrAfter(Version.V_8_3_0)) { - out.writeOptionalWriteable(statsRequestStats); - } } @Override @@ -359,9 +341,6 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws if (getIndexingPressureStats() != null) { getIndexingPressureStats().toXContent(builder, params); } - if (getStatsRequestStats() != null) { - getStatsRequestStats().toXContent(builder, params); - } return builder; } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java index 1eb55b0a897f9..004a83e130f56 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/NodesStatsRequest.java @@ -189,8 +189,7 @@ public enum Metric { INGEST("ingest"), ADAPTIVE_SELECTION("adaptive_selection"), SCRIPT_CACHE("script_cache"), - INDEXING_PRESSURE("indexing_pressure"), - STATS_REQUESTS("stats_requests"),; + INDEXING_PRESSURE("indexing_pressure"),; private String metricName; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java index e0b38bc23cff6..16701e1ad01fe 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/stats/TransportNodesStatsAction.java @@ -8,10 +8,8 @@ package org.elasticsearch.action.admin.cluster.node.stats; -import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.StatsRequestLimiter; import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.service.ClusterService; @@ -38,7 +36,6 @@ public class TransportNodesStatsAction extends TransportNodesAction< NodeStats> { private final NodeService nodeService; - private final StatsRequestLimiter statsRequestLimiter; @Inject public TransportNodesStatsAction( @@ -46,8 +43,7 @@ public TransportNodesStatsAction( ClusterService clusterService, TransportService transportService, NodeService nodeService, - ActionFilters actionFilters, - StatsRequestLimiter statsRequestLimiter + ActionFilters actionFilters ) { super( NodesStatsAction.NAME, @@ -61,7 +57,6 @@ public TransportNodesStatsAction( NodeStats.class ); this.nodeService = nodeService; - this.statsRequestLimiter = statsRequestLimiter; } @Override @@ -100,16 +95,10 @@ protected NodeStats nodeOperation(NodeStatsRequest nodeStatsRequest, Task task) NodesStatsRequest.Metric.INGEST.containedIn(metrics), NodesStatsRequest.Metric.ADAPTIVE_SELECTION.containedIn(metrics), NodesStatsRequest.Metric.SCRIPT_CACHE.containedIn(metrics), - NodesStatsRequest.Metric.INDEXING_PRESSURE.containedIn(metrics), - NodesStatsRequest.Metric.STATS_REQUESTS.containedIn(metrics) + NodesStatsRequest.Metric.INDEXING_PRESSURE.containedIn(metrics) ); } - @Override - protected void doExecute(Task task, NodesStatsRequest request, ActionListener listener) { - statsRequestLimiter.tryToExecute(task, request, listener, super::doExecute); - } - public static class NodeStatsRequest extends TransportRequest { NodesStatsRequest request; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/TransportNodesUsageAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/TransportNodesUsageAction.java index f0fd76b2f02f9..83bf017bd4280 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/TransportNodesUsageAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/node/usage/TransportNodesUsageAction.java @@ -8,10 +8,8 @@ package org.elasticsearch.action.admin.cluster.node.usage; -import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.FailedNodeException; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.StatsRequestLimiter; import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.cluster.node.DiscoveryNode; import org.elasticsearch.cluster.service.ClusterService; @@ -38,7 +36,6 @@ public class TransportNodesUsageAction extends TransportNodesAction< private final UsageService restUsageService; private final AggregationUsageService aggregationUsageService; private final long sinceTime; - private final StatsRequestLimiter statsRequestLimiter; @Inject public TransportNodesUsageAction( @@ -47,8 +44,7 @@ public TransportNodesUsageAction( TransportService transportService, ActionFilters actionFilters, UsageService restUsageService, - AggregationUsageService aggregationUsageService, - StatsRequestLimiter statsRequestLimiter + AggregationUsageService aggregationUsageService ) { super( NodesUsageAction.NAME, @@ -63,7 +59,6 @@ public TransportNodesUsageAction( ); this.restUsageService = restUsageService; this.aggregationUsageService = aggregationUsageService; - this.statsRequestLimiter = statsRequestLimiter; this.sinceTime = System.currentTimeMillis(); } @@ -90,11 +85,6 @@ protected NodeUsage nodeOperation(NodeUsageRequest nodeUsageRequest, Task task) return new NodeUsage(clusterService.localNode(), System.currentTimeMillis(), sinceTime, restUsage, aggsUsage); } - @Override - protected void doExecute(Task task, NodesUsageRequest request, ActionListener listener) { - statsRequestLimiter.tryToExecute(task, request, listener, super::doExecute); - } - public static class NodeUsageRequest extends TransportRequest { NodesUsageRequest request; diff --git a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java index cbc3219194a4d..dc4673b2ea561 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/cluster/stats/TransportClusterStatsAction.java @@ -18,7 +18,6 @@ import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; import org.elasticsearch.action.admin.indices.stats.ShardStats; import org.elasticsearch.action.support.ActionFilters; -import org.elasticsearch.action.support.StatsRequestLimiter; import org.elasticsearch.action.support.nodes.TransportNodesAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.health.ClusterHealthStatus; @@ -73,7 +72,6 @@ public class TransportClusterStatsAction extends TransportNodesAction< private final MetadataStatsCache mappingStatsCache; private final MetadataStatsCache analysisStatsCache; - private final StatsRequestLimiter statsRequestLimiter; @Inject public TransportClusterStatsAction( @@ -82,8 +80,7 @@ public TransportClusterStatsAction( TransportService transportService, NodeService nodeService, IndicesService indicesService, - ActionFilters actionFilters, - StatsRequestLimiter statsRequestLimiter + ActionFilters actionFilters ) { super( ClusterStatsAction.NAME, @@ -101,7 +98,6 @@ public TransportClusterStatsAction( this.indicesService = indicesService; this.mappingStatsCache = new MetadataStatsCache<>(threadPool.getThreadContext(), MappingStats::of); this.analysisStatsCache = new MetadataStatsCache<>(threadPool.getThreadContext(), AnalysisStats::of); - this.statsRequestLimiter = statsRequestLimiter; } @Override @@ -187,7 +183,6 @@ protected ClusterStatsNodeResponse nodeOperation(ClusterStatsNodeRequest nodeReq true, false, false, - false, false ); List shardsStats = new ArrayList<>(); @@ -238,11 +233,6 @@ protected ClusterStatsNodeResponse nodeOperation(ClusterStatsNodeRequest nodeReq } - @Override - protected void doExecute(Task task, ClusterStatsRequest request, ActionListener listener) { - statsRequestLimiter.tryToExecute(task, request, listener, super::doExecute); - } - public static class ClusterStatsNodeRequest extends TransportRequest { ClusterStatsRequest request; diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java index 18e062609405d..c5d39cdb5c192 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/recovery/TransportRecoveryAction.java @@ -11,7 +11,6 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.DefaultShardOperationFailedException; -import org.elasticsearch.action.support.StatsRequestLimiter; import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlockException; @@ -45,7 +44,6 @@ public class TransportRecoveryAction extends TransportBroadcastByNodeAction { private final IndicesService indicesService; - private final StatsRequestLimiter statsRequestLimiter; @Inject public TransportRecoveryAction( @@ -53,8 +51,7 @@ public TransportRecoveryAction( TransportService transportService, IndicesService indicesService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver, - StatsRequestLimiter statsRequestLimiter + IndexNameExpressionResolver indexNameExpressionResolver ) { super( RecoveryAction.NAME, @@ -66,7 +63,6 @@ public TransportRecoveryAction( ThreadPool.Names.MANAGEMENT ); this.indicesService = indicesService; - this.statsRequestLimiter = statsRequestLimiter; } @Override @@ -135,11 +131,6 @@ protected ClusterBlockException checkRequestBlock(ClusterState state, RecoveryRe return state.blocks().indicesBlockedException(ClusterBlockLevel.METADATA_READ, concreteIndices); } - @Override - protected void doExecute(Task task, RecoveryRequest request, ActionListener listener) { - statsRequestLimiter.tryToExecute(task, request, listener, super::doExecute); - } - @Nullable // unless running tests that inject extra behaviour private volatile Runnable onShardOperation; diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java index 5947d556e2a2d..470aedb2895f3 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/segments/TransportIndicesSegmentsAction.java @@ -11,7 +11,6 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.DefaultShardOperationFailedException; -import org.elasticsearch.action.support.StatsRequestLimiter; import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlockException; @@ -39,7 +38,6 @@ public class TransportIndicesSegmentsAction extends TransportBroadcastByNodeActi ShardSegments> { private final IndicesService indicesService; - private final StatsRequestLimiter statsRequestLimiter; @Inject public TransportIndicesSegmentsAction( @@ -47,8 +45,7 @@ public TransportIndicesSegmentsAction( TransportService transportService, IndicesService indicesService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver, - StatsRequestLimiter statsRequestLimiter + IndexNameExpressionResolver indexNameExpressionResolver ) { super( IndicesSegmentsAction.NAME, @@ -60,7 +57,6 @@ public TransportIndicesSegmentsAction( ThreadPool.Names.MANAGEMENT ); this.indicesService = indicesService; - this.statsRequestLimiter = statsRequestLimiter; } /** @@ -124,9 +120,4 @@ protected void shardOperation( return new ShardSegments(indexShard.routingEntry(), indexShard.segments()); }); } - - @Override - protected void doExecute(Task task, IndicesSegmentsRequest request, ActionListener listener) { - statsRequestLimiter.tryToExecute(task, request, listener, super::doExecute); - } } diff --git a/server/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java b/server/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java index ef70043fa2c78..44bb62cd0f04e 100644 --- a/server/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java +++ b/server/src/main/java/org/elasticsearch/action/admin/indices/stats/TransportIndicesStatsAction.java @@ -12,7 +12,6 @@ import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.support.ActionFilters; import org.elasticsearch.action.support.DefaultShardOperationFailedException; -import org.elasticsearch.action.support.StatsRequestLimiter; import org.elasticsearch.action.support.broadcast.node.TransportBroadcastByNodeAction; import org.elasticsearch.cluster.ClusterState; import org.elasticsearch.cluster.block.ClusterBlockException; @@ -41,7 +40,6 @@ public class TransportIndicesStatsAction extends TransportBroadcastByNodeAction { private final IndicesService indicesService; - private final StatsRequestLimiter statsRequestLimiter; @Inject public TransportIndicesStatsAction( @@ -49,8 +47,7 @@ public TransportIndicesStatsAction( TransportService transportService, IndicesService indicesService, ActionFilters actionFilters, - IndexNameExpressionResolver indexNameExpressionResolver, - StatsRequestLimiter statsRequestLimiter + IndexNameExpressionResolver indexNameExpressionResolver ) { super( IndicesStatsAction.NAME, @@ -62,7 +59,6 @@ public TransportIndicesStatsAction( ThreadPool.Names.MANAGEMENT ); this.indicesService = indicesService; - this.statsRequestLimiter = statsRequestLimiter; } /** @@ -148,9 +144,4 @@ protected void shardOperation(IndicesStatsRequest request, ShardRouting shardRou ); }); } - - @Override - protected void doExecute(Task task, IndicesStatsRequest request, ActionListener listener) { - statsRequestLimiter.tryToExecute(task, request, listener, super::doExecute); - } } diff --git a/server/src/main/java/org/elasticsearch/action/support/StatsRequestLimiter.java b/server/src/main/java/org/elasticsearch/action/support/StatsRequestLimiter.java deleted file mode 100644 index 1bdb414584b08..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/support/StatsRequestLimiter.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.support; - -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.common.TriConsumer; -import org.elasticsearch.common.metrics.CounterMetric; -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.Setting; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.AdjustableSemaphore; -import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; -import org.elasticsearch.common.util.concurrent.RunOnce; -import org.elasticsearch.tasks.Task; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * This class guards the amount of stats requests a node can concurrently coordinate. - */ -public class StatsRequestLimiter { - - public static final Setting MAX_CONCURRENT_STATS_REQUESTS_PER_NODE = Setting.intSetting( - "node.stats.max_concurrent_requests", - 100, - 1, - Setting.Property.NodeScope, - Setting.Property.Dynamic - ); - - private final AdjustableSemaphore maxConcurrentStatsRequestsPerNodeSemaphore; - private volatile int maxConcurrentStatsRequestsPerNode; - private final Map stats = new ConcurrentHashMap<>(); - - public StatsRequestLimiter(Settings settings, ClusterSettings clusterSettings) { - maxConcurrentStatsRequestsPerNode = MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.get(settings); - this.maxConcurrentStatsRequestsPerNodeSemaphore = new AdjustableSemaphore(maxConcurrentStatsRequestsPerNode, false); - clusterSettings.addSettingsUpdateConsumer(MAX_CONCURRENT_STATS_REQUESTS_PER_NODE, this::setMaxConcurrentStatsRequestsPerNode); - } - - private void setMaxConcurrentStatsRequestsPerNode(int maxConcurrentStatsRequestsPerNode) { - this.maxConcurrentStatsRequestsPerNode = maxConcurrentStatsRequestsPerNode; - this.maxConcurrentStatsRequestsPerNodeSemaphore.setMaxPermits(maxConcurrentStatsRequestsPerNode); - } - - /** - * Checks if executing the action will remain within the limits of the max concurrent requests the node can handle. If the limit is - * respected the action will be executed otherwise it will throw an EsRejectedExecutionException. The method keeps track of current, - * completed and rejected requests per action type. - */ - public void tryToExecute( - Task task, - Request request, - ActionListener listener, - TriConsumer> executeAction - ) { - StatsHolder statsHolder = stats.computeIfAbsent(task.getAction(), ignored -> new StatsHolder(task.getAction())); - if (tryAcquire()) { - statsHolder.current.inc(); - final Runnable release = new RunOnce(() -> { - release(); - statsHolder.current.dec(); - statsHolder.completed.inc(); - }); - boolean success = false; - try { - executeAction.apply(task, request, ActionListener.runBefore(listener, release::run)); - success = true; - } finally { - if (success == false) { - release.run(); - } - } - } else { - listener.onFailure( - new EsRejectedExecutionException( - "this node is already coordinating [" - + maxConcurrentStatsRequestsPerNode - + "] stats requests and has reached the limit set by [" - + MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey() - + "]" - ) - ); - statsHolder.rejected.inc(); - } - } - - public StatsRequestStats stats() { - return new StatsRequestStats(stats.values().stream().map(StatsHolder::stats).sorted().toList()); - } - - // visible for testing - boolean tryAcquire() { - return maxConcurrentStatsRequestsPerNodeSemaphore.tryAcquire(); - } - - // visible for testing - void release() { - maxConcurrentStatsRequestsPerNodeSemaphore.release(); - } - - static final class StatsHolder { - String request; - final CounterMetric current = new CounterMetric(); - final CounterMetric completed = new CounterMetric(); - final CounterMetric rejected = new CounterMetric(); - - StatsHolder(String request) { - this.request = request; - } - - StatsRequestStats.Stats stats() { - return new StatsRequestStats.Stats(request, current.count(), completed.count(), rejected.count()); - } - } -} diff --git a/server/src/main/java/org/elasticsearch/action/support/StatsRequestStats.java b/server/src/main/java/org/elasticsearch/action/support/StatsRequestStats.java deleted file mode 100644 index 2ac638242a45b..0000000000000 --- a/server/src/main/java/org/elasticsearch/action/support/StatsRequestStats.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.support; - -import org.elasticsearch.common.io.stream.StreamInput; -import org.elasticsearch.common.io.stream.StreamOutput; -import org.elasticsearch.common.io.stream.Writeable; -import org.elasticsearch.xcontent.ToXContentFragment; -import org.elasticsearch.xcontent.XContentBuilder; - -import java.io.IOException; -import java.util.Iterator; -import java.util.List; - -public class StatsRequestStats implements Writeable, ToXContentFragment, Iterable { - - public static class Stats implements Writeable, ToXContentFragment, Comparable { - - private final String request; - private final long current; - private final long completed; - private final long rejected; - - public Stats(String request, long current, long completed, long rejected) { - this.request = request; - this.current = current; - this.completed = completed; - this.rejected = rejected; - } - - public Stats(StreamInput in) throws IOException { - request = in.readString(); - current = in.readLong(); - completed = in.readLong(); - rejected = in.readLong(); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - out.writeString(request); - out.writeLong(current); - out.writeLong(completed); - out.writeLong(rejected); - } - - public String getRequest() { - return this.request; - } - - public long getCurrent() { - return this.current; - } - - public long getCompleted() { - return this.completed; - } - - public long getRejected() { - return rejected; - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject(request); - if (current != -1) { - builder.field(Fields.CURRENT, current); - } - if (completed != -1) { - builder.field(Fields.COMPLETED, completed); - } - if (rejected != -1) { - builder.field(Fields.REJECTED, rejected); - } - builder.endObject(); - return builder; - } - - @Override - public int compareTo(Stats other) { - if ((getRequest() == null) && (other.getRequest() == null)) { - return 0; - } else if ((getRequest() != null) && (other.getRequest() == null)) { - return 1; - } else if (getRequest() == null) { - return -1; - } else { - int compare = getRequest().compareTo(other.getRequest()); - if (compare == 0) { - compare = Long.compare(getCompleted(), other.getCompleted()); - } - return compare; - } - } - } - - private final List stats; - - public StatsRequestStats(List stats) { - this.stats = stats; - } - - public StatsRequestStats(StreamInput in) throws IOException { - stats = in.readList(Stats::new); - } - - @Override - public void writeTo(StreamOutput out) throws IOException { - out.writeList(stats); - } - - @Override - public Iterator iterator() { - return stats.iterator(); - } - - static final class Fields { - static final String CURRENT = "current"; - static final String COMPLETED = "completed"; - static final String REJECTED = "rejected"; - } - - @Override - public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.startObject("stats_requests"); - for (Stats stat : stats) { - stat.toXContent(builder, params); - } - builder.endObject(); - return builder; - } -} diff --git a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java index 85f5c283af638..0ed272d454729 100644 --- a/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java +++ b/server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java @@ -13,7 +13,6 @@ import org.elasticsearch.action.search.TransportSearchAction; import org.elasticsearch.action.support.AutoCreateIndex; import org.elasticsearch.action.support.DestructiveOperations; -import org.elasticsearch.action.support.StatsRequestLimiter; import org.elasticsearch.action.support.replication.TransportReplicationAction; import org.elasticsearch.bootstrap.BootstrapSettings; import org.elasticsearch.client.internal.Client; @@ -512,7 +511,6 @@ public void apply(Settings value, Settings current, Settings previous) { IndexingPressure.MAX_INDEXING_BYTES, ShardLimitValidator.SETTING_CLUSTER_MAX_SHARDS_PER_NODE_FROZEN, DataTier.ENFORCE_DEFAULT_TIER_PREFERENCE_SETTING, - StatsRequestLimiter.MAX_CONCURRENT_STATS_REQUESTS_PER_NODE, ReadinessService.PORT ); diff --git a/server/src/main/java/org/elasticsearch/node/Node.java b/server/src/main/java/org/elasticsearch/node/Node.java index d8b5ba5a4ee88..8203d6ef6dee0 100644 --- a/server/src/main/java/org/elasticsearch/node/Node.java +++ b/server/src/main/java/org/elasticsearch/node/Node.java @@ -25,7 +25,6 @@ import org.elasticsearch.action.search.SearchExecutionStatsCollector; import org.elasticsearch.action.search.SearchPhaseController; import org.elasticsearch.action.search.SearchTransportService; -import org.elasticsearch.action.support.StatsRequestLimiter; import org.elasticsearch.action.support.TransportAction; import org.elasticsearch.action.update.UpdateHelper; import org.elasticsearch.bootstrap.BootstrapCheck; @@ -794,8 +793,6 @@ protected Node( ); clusterInfoService.addListener(diskThresholdMonitor::onNewInfo); - final StatsRequestLimiter statsRequestLimiter = new StatsRequestLimiter(settings, settingsModule.getClusterSettings()); - final DiscoveryModule discoveryModule = new DiscoveryModule( settings, transportService, @@ -829,8 +826,7 @@ protected Node( responseCollectorService, searchTransportService, indexingLimits, - searchModule.getValuesSourceRegistry().getUsageService(), - statsRequestLimiter + searchModule.getValuesSourceRegistry().getUsageService() ); final SearchService searchService = newSearchService( @@ -973,7 +969,6 @@ protected Node( b.bind(DesiredNodesSettingsValidator.class).toInstance(desiredNodesSettingsValidator); b.bind(HealthService.class).toInstance(healthService); b.bind(MasterHistoryService.class).toInstance(masterHistoryService); - b.bind(StatsRequestLimiter.class).toInstance(statsRequestLimiter); }); if (ReadinessService.enabled(environment)) { diff --git a/server/src/main/java/org/elasticsearch/node/NodeService.java b/server/src/main/java/org/elasticsearch/node/NodeService.java index f1949c84f9627..2df841f1b9d98 100644 --- a/server/src/main/java/org/elasticsearch/node/NodeService.java +++ b/server/src/main/java/org/elasticsearch/node/NodeService.java @@ -14,7 +14,6 @@ import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.indices.stats.CommonStatsFlags; import org.elasticsearch.action.search.SearchTransportService; -import org.elasticsearch.action.support.StatsRequestLimiter; import org.elasticsearch.cluster.coordination.Coordinator; import org.elasticsearch.cluster.service.ClusterService; import org.elasticsearch.common.settings.Settings; @@ -53,7 +52,6 @@ public class NodeService implements Closeable { private final SearchTransportService searchTransportService; private final IndexingPressure indexingPressure; private final AggregationUsageService aggregationUsageService; - private final StatsRequestLimiter statsRequestLimiter; private final Coordinator coordinator; @@ -74,8 +72,7 @@ public class NodeService implements Closeable { ResponseCollectorService responseCollectorService, SearchTransportService searchTransportService, IndexingPressure indexingPressure, - AggregationUsageService aggregationUsageService, - StatsRequestLimiter statsRequestLimiter + AggregationUsageService aggregationUsageService ) { this.settings = settings; this.threadPool = threadPool; @@ -93,7 +90,6 @@ public class NodeService implements Closeable { this.searchTransportService = searchTransportService; this.indexingPressure = indexingPressure; this.aggregationUsageService = aggregationUsageService; - this.statsRequestLimiter = statsRequestLimiter; clusterService.addStateApplier(ingestService); } @@ -143,8 +139,7 @@ public NodeStats stats( boolean ingest, boolean adaptiveSelection, boolean scriptCache, - boolean indexingPressure, - boolean statsRequests + boolean indexingPressure ) { // for indices stats we want to include previous allocated shards stats as well (it will // only be applied to the sensible ones to use, like refresh/merge/flush/indexing stats) @@ -165,8 +160,7 @@ public NodeStats stats( ingest ? ingestService.stats() : null, adaptiveSelection ? responseCollectorService.getAdaptiveStats(searchTransportService.getPendingSearchRequests()) : null, scriptCache ? scriptService.cacheStats() : null, - indexingPressure ? this.indexingPressure.stats() : null, - statsRequests ? this.statsRequestLimiter.stats() : null + indexingPressure ? this.indexingPressure.stats() : null ); } diff --git a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java index e1ee616a0c772..e2ccccf3a8236 100644 --- a/server/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java +++ b/server/src/test/java/org/elasticsearch/action/admin/cluster/node/stats/NodeStatsTests.java @@ -8,7 +8,6 @@ package org.elasticsearch.action.admin.cluster.node.stats; -import org.elasticsearch.action.support.StatsRequestStats; import org.elasticsearch.cluster.coordination.ClusterStateSerializationStats; import org.elasticsearch.cluster.coordination.PendingClusterStateStats; import org.elasticsearch.cluster.coordination.PublishClusterStateStats; @@ -509,21 +508,6 @@ public void testSerialization() throws IOException { assertEquals(limited, sum.getCompilationLimitTriggered()); assertEquals(compilations, sum.getCompilations()); } - if (nodeStats.getStatsRequestStats() == null) { - assertNull(deserializedNodeStats.getStatsRequestStats()); - } else { - Iterator statsRequestsStatsIterator = nodeStats.getStatsRequestStats().iterator(); - Iterator deserializedStatsRequestsStatsIterator = deserializedNodeStats.getStatsRequestStats() - .iterator(); - while (statsRequestsStatsIterator.hasNext()) { - StatsRequestStats.Stats stats = statsRequestsStatsIterator.next(); - StatsRequestStats.Stats deserializedStats = deserializedStatsRequestsStatsIterator.next(); - assertEquals(stats.getRequest(), deserializedStats.getRequest()); - assertEquals(stats.getCurrent(), deserializedStats.getCurrent()); - assertEquals(stats.getCompleted(), deserializedStats.getCompleted()); - assertEquals(stats.getRejected(), deserializedStats.getRejected()); - } - } } } } @@ -900,22 +884,6 @@ public static NodeStats createNodeStats() { randomLongBetween(0, maxStatValue) ); } - StatsRequestStats statsRequestStats = null; - if (frequently()) { - int numStatsRequestsStats = randomIntBetween(0, 10); - List statsRequestsStatsList = new ArrayList<>(); - for (int i = 0; i < numStatsRequestsStats; i++) { - statsRequestsStatsList.add( - new StatsRequestStats.Stats( - randomAlphaOfLengthBetween(3, 10), - randomIntBetween(1, 10), - randomIntBetween(1, 1000), - randomIntBetween(1, 1000) - ) - ); - } - statsRequestStats = new StatsRequestStats(statsRequestsStatsList); - } // TODO NodeIndicesStats are not tested here, way too complicated to create, also they need to be migrated to Writeable yet return new NodeStats( node, @@ -934,8 +902,7 @@ public static NodeStats createNodeStats() { ingestStats, adaptiveSelectionStats, scriptCacheStats, - indexingPressureStats, - statsRequestStats + indexingPressureStats ); } diff --git a/server/src/test/java/org/elasticsearch/action/support/StatsRequestLimiterTests.java b/server/src/test/java/org/elasticsearch/action/support/StatsRequestLimiterTests.java deleted file mode 100644 index 9b987e993752a..0000000000000 --- a/server/src/test/java/org/elasticsearch/action/support/StatsRequestLimiterTests.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0 and the Server Side Public License, v 1; you may not use this file except - * in compliance with, at your election, the Elastic License 2.0 or the Server - * Side Public License, v 1. - */ - -package org.elasticsearch.action.support; - -import org.elasticsearch.action.ActionListener; -import org.elasticsearch.common.TriConsumer; -import org.elasticsearch.common.settings.ClusterSettings; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.EsRejectedExecutionException; -import org.elasticsearch.tasks.Task; -import org.elasticsearch.tasks.TaskId; -import org.elasticsearch.test.ESTestCase; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.BrokenBarrierException; -import java.util.concurrent.CyclicBarrier; - -import static java.util.Collections.emptyMap; -import static org.elasticsearch.action.support.StatsRequestLimiter.MAX_CONCURRENT_STATS_REQUESTS_PER_NODE; - -public class StatsRequestLimiterTests extends ESTestCase { - - public void testGrantsPermitsUpToMaxPermits() throws Exception { - final int maxPermits = randomIntBetween(1, 5); - final List threads = new ArrayList<>(maxPermits); - final CyclicBarrier barrier = new CyclicBarrier(1 + maxPermits); - TriConsumer> execute = (task, i, actionListener) -> { - final Thread thread = new Thread(() -> { - try { - barrier.await(); - } catch (final BrokenBarrierException | InterruptedException e) { - fail("Exception occurred while waiting for the barrier to be lifted"); - } - actionListener.onResponse(i); - }); - thread.setName("thread-" + i); - threads.add(thread); - thread.start(); - }; - ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - Settings settings = Settings.builder().put(MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey(), maxPermits).build(); - StatsRequestLimiter statsRequestLimiter = new StatsRequestLimiter(settings, clusterSettings); - - for (int i = 0; i < maxPermits; i++) { - PlainActionFuture listener = new PlainActionFuture<>(); - statsRequestLimiter.tryToExecute(createTask(), i, listener, execute); - } - PlainActionFuture listener = new PlainActionFuture<>(); - statsRequestLimiter.tryToExecute(createTask(), maxPermits, listener, execute); - String expectedExceptionMessage = "this node is already coordinating [" - + MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.get(settings) - + "] stats requests and has reached the limit set by [" - + MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey() - + "]"; - expectThrows(EsRejectedExecutionException.class, expectedExceptionMessage, listener::actionGet); - StatsRequestStats.Stats stats = getStats(statsRequestLimiter); - assertEquals(maxPermits, stats.getCurrent()); - - barrier.await(); - for (Thread thread : threads) { - thread.join(); - } - assertBusy(() -> assertTrue(statsRequestLimiter.tryAcquire())); - stats = getStats(statsRequestLimiter); - assertEquals(0, stats.getCurrent()); - assertEquals(maxPermits, stats.getCompleted()); - assertEquals(1, stats.getRejected()); - } - - public void testStatsRequestPermitCanBeDynamicallyUpdated() { - ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - StatsRequestLimiter statsRequestLimiter = new StatsRequestLimiter( - Settings.builder().put(MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey(), 1).build(), - clusterSettings - ); - - assertTrue(statsRequestLimiter.tryAcquire()); - assertFalse(statsRequestLimiter.tryAcquire()); - - clusterSettings.applySettings(Settings.builder().put(MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey(), 2).build()); - - assertTrue(statsRequestLimiter.tryAcquire()); - - clusterSettings.applySettings(Settings.builder().put(MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey(), 1).build()); - - assertFalse(statsRequestLimiter.tryAcquire()); - statsRequestLimiter.release(); - statsRequestLimiter.release(); - - assertTrue(statsRequestLimiter.tryAcquire()); - assertFalse(statsRequestLimiter.tryAcquire()); - } - - public void testMaxConcurrentStatsRequestsPerNodeIsValidated() { - ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - Settings invalidSetting = Settings.builder().put(MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey(), 0).build(); - expectThrows(IllegalArgumentException.class, () -> new StatsRequestLimiter(invalidSetting, clusterSettings)); - new StatsRequestLimiter(Settings.builder().put(MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey(), 1).build(), clusterSettings); - expectThrows( - IllegalArgumentException.class, - () -> clusterSettings.applySettings(Settings.builder().put(MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey(), 0).build()) - ); - } - - public void testReleasingAfterException() { - ClusterSettings clusterSettings = new ClusterSettings(Settings.EMPTY, ClusterSettings.BUILT_IN_CLUSTER_SETTINGS); - StatsRequestLimiter statsRequestLimiter = new StatsRequestLimiter( - Settings.builder().put(MAX_CONCURRENT_STATS_REQUESTS_PER_NODE.getKey(), 1).build(), - clusterSettings - ); - PlainActionFuture listener = new PlainActionFuture<>(); - TriConsumer> execute = (task, input, actionListener) -> { - // Verify that we hold the last permit - assertFalse(statsRequestLimiter.tryAcquire()); - throw new RuntimeException("simulated"); - }; - expectThrows(RuntimeException.class, () -> statsRequestLimiter.tryToExecute(createTask(), 10, listener, execute)); - StatsRequestStats.Stats stats = getStats(statsRequestLimiter); - assertEquals(0, stats.getCurrent()); - assertEquals(1, stats.getCompleted()); - assertTrue(statsRequestLimiter.tryAcquire()); - } - - private StatsRequestStats.Stats getStats(StatsRequestLimiter statsRequestLimiter) { - return statsRequestLimiter.stats().iterator().next(); - } - - private Task createTask() { - return new Task( - randomLong(), - "transport", - "stats_action", - "description", - new TaskId(randomLong() + ":" + randomLong()), - emptyMap() - ); - } -} diff --git a/server/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java b/server/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java index fe2de2a3341f9..939788fc2e370 100644 --- a/server/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/DiskUsageTests.java @@ -170,7 +170,6 @@ public void testFillDiskUsage() { null, null, null, - null, null ), new NodeStats( @@ -190,7 +189,6 @@ public void testFillDiskUsage() { null, null, null, - null, null ), new NodeStats( @@ -210,7 +208,6 @@ public void testFillDiskUsage() { null, null, null, - null, null ) ); @@ -261,7 +258,6 @@ public void testFillDiskUsageSomeInvalidValues() { null, null, null, - null, null ), new NodeStats( @@ -281,7 +277,6 @@ public void testFillDiskUsageSomeInvalidValues() { null, null, null, - null, null ), new NodeStats( @@ -301,7 +296,6 @@ public void testFillDiskUsageSomeInvalidValues() { null, null, null, - null, null ) ); diff --git a/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java b/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java index 0b4d6b421b151..b47ea46a2be34 100644 --- a/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java +++ b/test/framework/src/main/java/org/elasticsearch/cluster/MockInternalClusterInfoService.java @@ -89,8 +89,7 @@ List adjustNodesStats(List nodesStats) { nodeStats.getIngestStats(), nodeStats.getAdaptiveSelectionStats(), nodeStats.getScriptCacheStats(), - nodeStats.getIndexingPressureStats(), - nodeStats.getStatsRequestStats() + nodeStats.getIndexingPressureStats() ); }).collect(Collectors.toList()); } diff --git a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java index 5aa32805967fa..942346a2b7dd6 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/elasticsearch/test/InternalTestCluster.java @@ -2456,7 +2456,6 @@ public void ensureEstimatedStats() { false, false, false, - false, false ); assertThat( diff --git a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoServiceTests.java b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoServiceTests.java index 9abdb1077aba9..d24d9dd03d16f 100644 --- a/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoServiceTests.java +++ b/x-pack/plugin/autoscaling/src/test/java/org/elasticsearch/xpack/autoscaling/capacity/memory/AutoscalingMemoryInfoServiceTests.java @@ -368,7 +368,6 @@ private static NodeStats statsForNode(DiscoveryNode node, long memory) { null, null, null, - null, null ); } diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportGetTrainedModelsStatsActionTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportGetTrainedModelsStatsActionTests.java index 49973f9d9f7af..8708f0506c4b9 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportGetTrainedModelsStatsActionTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/action/TransportGetTrainedModelsStatsActionTests.java @@ -358,7 +358,6 @@ private static NodeStats buildNodeStats( ingestStats, null, null, - null, null ); diff --git a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDocTests.java b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDocTests.java index d0fbe7603ecf5..4b22722e323fb 100644 --- a/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDocTests.java +++ b/x-pack/plugin/monitoring/src/test/java/org/elasticsearch/xpack/monitoring/collector/node/NodeStatsMonitoringDocTests.java @@ -445,7 +445,6 @@ private static NodeStats mockNodeStats() { null, null, null, - null, null ); }