From ed5792afde46734796d7d07c4c3d02941deb10ea Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Tue, 12 Apr 2022 12:54:42 -0700 Subject: [PATCH] Remove hppc from cat allocation api The cat allocation endpoint uses an hppc int map for counting the number of allocations for each node. There are not that many nodes, and this is short lived anyways. This commit switches to a HashMap. relates #84735 --- .../rest/action/cat/RestAllocationAction.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java b/server/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java index 8c87e4cdf003e..cffdcdc5f7a53 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/cat/RestAllocationAction.java @@ -8,8 +8,6 @@ package org.elasticsearch.rest.action.cat; -import com.carrotsearch.hppc.ObjectIntScatterMap; - import org.elasticsearch.action.admin.cluster.node.stats.NodeStats; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsRequest; import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; @@ -27,7 +25,9 @@ import org.elasticsearch.rest.action.RestActionListener; import org.elasticsearch.rest.action.RestResponseListener; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static org.elasticsearch.rest.RestRequest.Method.GET; @@ -94,7 +94,7 @@ protected Table getTableWithHeader(final RestRequest request) { } private Table buildTable(RestRequest request, final ClusterStateResponse state, final NodesStatsResponse stats) { - final ObjectIntScatterMap allocs = new ObjectIntScatterMap<>(); + final Map allocs = new HashMap<>(); for (ShardRouting shard : state.getState().routingTable().allShards()) { String nodeId = "UNASSIGNED"; @@ -103,7 +103,7 @@ private Table buildTable(RestRequest request, final ClusterStateResponse state, nodeId = shard.currentNodeId(); } - allocs.addTo(nodeId, 1); + allocs.merge(nodeId, 1, Integer::sum); } Table table = getTableWithHeader(request);