From b328dbc65b1cbf200cc291e452cfdd71c889b78b Mon Sep 17 00:00:00 2001 From: Harsh Garg Date: Wed, 23 Oct 2024 10:19:48 +0530 Subject: [PATCH 1/3] Avoid making further stats calls if paginationStrategy outputs empty entities Signed-off-by: Harsh Garg --- .../shards/TransportCatShardsAction.java | 19 +++++++++++ .../rest/action/cat/RestIndicesAction.java | 32 +++++++++++++++---- 2 files changed, 44 insertions(+), 7 deletions(-) diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportCatShardsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportCatShardsAction.java index 3dc8c38152a16..1ac4d6068725b 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportCatShardsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportCatShardsAction.java @@ -12,6 +12,7 @@ import org.opensearch.action.admin.cluster.state.ClusterStateResponse; import org.opensearch.action.admin.indices.stats.IndicesStatsRequest; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; +import org.opensearch.action.admin.indices.stats.ShardStats; import org.opensearch.action.pagination.PageParams; import org.opensearch.action.pagination.ShardPaginationStrategy; import org.opensearch.action.support.ActionFilters; @@ -27,6 +28,7 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; +import java.util.Collections; import java.util.Objects; import static org.opensearch.common.breaker.ResponseLimitSettings.LimitEntity.SHARDS; @@ -40,6 +42,13 @@ public class TransportCatShardsAction extends HandledTransportAction next() { }; } + private boolean shouldSkipIndicesStatsRequest(IndexPaginationStrategy paginationStrategy) { + return Objects.nonNull(paginationStrategy) && paginationStrategy.getRequestedEntities().isEmpty(); + } + } From 40cc55a85fe08411d80ed1548f6aac7569440e87 Mon Sep 17 00:00:00 2001 From: Harsh Garg Date: Wed, 23 Oct 2024 15:33:39 +0530 Subject: [PATCH 2/3] Moving empty IndicesStats creation to Response class Signed-off-by: Harsh Garg --- .../cluster/shards/TransportCatShardsAction.java | 11 +---------- .../admin/indices/stats/IndicesStatsResponse.java | 5 +++++ .../opensearch/rest/action/cat/RestIndicesAction.java | 10 +--------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportCatShardsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportCatShardsAction.java index 1ac4d6068725b..7b36b7a10f4f2 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportCatShardsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/shards/TransportCatShardsAction.java @@ -12,7 +12,6 @@ import org.opensearch.action.admin.cluster.state.ClusterStateResponse; import org.opensearch.action.admin.indices.stats.IndicesStatsRequest; import org.opensearch.action.admin.indices.stats.IndicesStatsResponse; -import org.opensearch.action.admin.indices.stats.ShardStats; import org.opensearch.action.pagination.PageParams; import org.opensearch.action.pagination.ShardPaginationStrategy; import org.opensearch.action.support.ActionFilters; @@ -28,7 +27,6 @@ import org.opensearch.tasks.Task; import org.opensearch.transport.TransportService; -import java.util.Collections; import java.util.Objects; import static org.opensearch.common.breaker.ResponseLimitSettings.LimitEntity.SHARDS; @@ -42,13 +40,6 @@ public class TransportCatShardsAction extends HandledTransportAction Date: Wed, 23 Oct 2024 16:11:30 +0530 Subject: [PATCH 3/3] Retry Build Signed-off-by: Harsh Garg