From 67e5ad2f532442fc1dd57cf92f9e4cd995082672 Mon Sep 17 00:00:00 2001 From: Tanguy Leroux Date: Mon, 22 Jul 2019 17:09:25 +0200 Subject: [PATCH] Remove AllocationService.reroute(ClusterState, String, boolean) (#44629) This commit removes the method AllocationService.reroute(ClusterState, String, boolean) in favor of AllocationService.reroute(ClusterState, String). Motivations are: there are already 3 other reroute methods in this class this method is always called with the debug parameter set to false almost all tests use the method reroute(ClusterState, String) --- .../cluster/routing/allocation/AllocationService.java | 11 ----------- .../allocation/MaxRetryAllocationDeciderTests.java | 4 ++-- .../allocation/ResizeAllocationDeciderTests.java | 2 +- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java index 26aeff6d2da16..eb139589724ae 100644 --- a/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java +++ b/server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java @@ -354,22 +354,12 @@ public CommandsResult reroute(final ClusterState clusterState, AllocationCommand return new CommandsResult(explanations, buildResultAndLogHealthChange(clusterState, allocation, "reroute commands")); } - /** * Reroutes the routing table based on the live nodes. *

* If the same instance of ClusterState is returned, then no change has been made. */ public ClusterState reroute(ClusterState clusterState, String reason) { - return reroute(clusterState, reason, false); - } - - /** - * Reroutes the routing table based on the live nodes. - *

- * If the same instance of ClusterState is returned, then no change has been made. - */ - protected ClusterState reroute(ClusterState clusterState, String reason, boolean debug) { ClusterState fixedClusterState = adaptAutoExpandReplicas(clusterState); RoutingNodes routingNodes = getMutableRoutingNodes(fixedClusterState); @@ -377,7 +367,6 @@ protected ClusterState reroute(ClusterState clusterState, String reason, boolean routingNodes.unassigned().shuffle(); RoutingAllocation allocation = new RoutingAllocation(allocationDeciders, routingNodes, fixedClusterState, clusterInfoService.getClusterInfo(), currentNanoTime()); - allocation.debugDecision(debug); reroute(allocation); if (fixedClusterState == clusterState && allocation.routingNodesChanged() == false) { return clusterState; diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/MaxRetryAllocationDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/MaxRetryAllocationDeciderTests.java index f465d401ff206..19af72d18db4a 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/MaxRetryAllocationDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/MaxRetryAllocationDeciderTests.java @@ -72,7 +72,7 @@ private ClusterState createInitialClusterState() { clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2"))) .build(); RoutingTable prevRoutingTable = routingTable; - routingTable = strategy.reroute(clusterState, "reroute", false).routingTable(); + routingTable = strategy.reroute(clusterState, "reroute").routingTable(); clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build(); assertEquals(prevRoutingTable.index("idx").shards().size(), 1); @@ -204,7 +204,7 @@ public void testFailedAllocation() { Settings.builder().put(clusterState.metaData().index("idx").getSettings()).put("index.allocation.max_retries", retries+1).build() ).build(), true).build()).build(); - ClusterState newState = strategy.reroute(clusterState, "settings changed", false); + ClusterState newState = strategy.reroute(clusterState, "settings changed"); assertThat(newState, not(equalTo(clusterState))); clusterState = newState; routingTable = newState.routingTable(); diff --git a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ResizeAllocationDeciderTests.java b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ResizeAllocationDeciderTests.java index aa2fb0a3831ab..d6da7ec0a533f 100644 --- a/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ResizeAllocationDeciderTests.java +++ b/server/src/test/java/org/elasticsearch/cluster/routing/allocation/ResizeAllocationDeciderTests.java @@ -74,7 +74,7 @@ private ClusterState createInitialClusterState(boolean startShards) { ("node2", Version.CURRENT))) .build(); RoutingTable prevRoutingTable = routingTable; - routingTable = strategy.reroute(clusterState, "reroute", false).routingTable(); + routingTable = strategy.reroute(clusterState, "reroute").routingTable(); clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build(); assertEquals(prevRoutingTable.index("source").shards().size(), 2);