From 0240ff05f77a2680aace54c7a5c0fdb6707434ae Mon Sep 17 00:00:00 2001 From: Anshu Agarwal Date: Mon, 26 Sep 2022 12:58:38 +0530 Subject: [PATCH] Refactor code Signed-off-by: Anshu Agarwal --- .../src/main/java/org/opensearch/action/ActionModule.java | 4 ++-- ...ngAction.java => ClusterAddWeightedRoutingAction.java} | 6 +++--- .../put/ClusterPutWeightedRoutingRequestBuilder.java | 2 +- .../weighted/put/TransportAddWeightedRoutingAction.java | 2 +- .../org/opensearch/client/support/AbstractClient.java | 8 ++++---- .../cluster/routing/WeightedRoutingServiceTests.java | 6 +++--- ...java => RestClusterAddWeightedRoutingActionTests.java} | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) rename server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/{ClusterPutWeightedRoutingAction.java => ClusterAddWeightedRoutingAction.java} (74%) rename server/src/test/java/org/opensearch/rest/action/admin/cluster/{RestClusterPutWeightedRoutingActionTests.java => RestClusterAddWeightedRoutingActionTests.java} (98%) diff --git a/server/src/main/java/org/opensearch/action/ActionModule.java b/server/src/main/java/org/opensearch/action/ActionModule.java index 34960d611b63f..23b2c9a78021e 100644 --- a/server/src/main/java/org/opensearch/action/ActionModule.java +++ b/server/src/main/java/org/opensearch/action/ActionModule.java @@ -79,7 +79,7 @@ import org.opensearch.action.admin.cluster.settings.TransportClusterUpdateSettingsAction; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsAction; import org.opensearch.action.admin.cluster.shards.TransportClusterSearchShardsAction; -import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterPutWeightedRoutingAction; +import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterAddWeightedRoutingAction; import org.opensearch.action.admin.cluster.shards.routing.weighted.put.TransportAddWeightedRoutingAction; import org.opensearch.action.admin.cluster.snapshots.clone.CloneSnapshotAction; import org.opensearch.action.admin.cluster.snapshots.clone.TransportCloneSnapshotAction; @@ -566,7 +566,7 @@ public void reg actions.register(RestoreSnapshotAction.INSTANCE, TransportRestoreSnapshotAction.class); actions.register(SnapshotsStatusAction.INSTANCE, TransportSnapshotsStatusAction.class); - actions.register(ClusterPutWeightedRoutingAction.INSTANCE, TransportAddWeightedRoutingAction.class); + actions.register(ClusterAddWeightedRoutingAction.INSTANCE, TransportAddWeightedRoutingAction.class); actions.register(IndicesStatsAction.INSTANCE, TransportIndicesStatsAction.class); actions.register(IndicesSegmentsAction.INSTANCE, TransportIndicesSegmentsAction.class); actions.register(IndicesShardStoresAction.INSTANCE, TransportIndicesShardStoresAction.class); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterPutWeightedRoutingAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterAddWeightedRoutingAction.java similarity index 74% rename from server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterPutWeightedRoutingAction.java rename to server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterAddWeightedRoutingAction.java index 9931c3dc5782b..65c5ccca71461 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterPutWeightedRoutingAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterAddWeightedRoutingAction.java @@ -15,12 +15,12 @@ * * @opensearch.internal */ -public final class ClusterPutWeightedRoutingAction extends ActionType { +public final class ClusterAddWeightedRoutingAction extends ActionType { - public static final ClusterPutWeightedRoutingAction INSTANCE = new ClusterPutWeightedRoutingAction(); + public static final ClusterAddWeightedRoutingAction INSTANCE = new ClusterAddWeightedRoutingAction(); public static final String NAME = "cluster:admin/routing/awareness/weights/put"; - private ClusterPutWeightedRoutingAction() { + private ClusterAddWeightedRoutingAction() { super(NAME, ClusterPutWeightedRoutingResponse::new); } } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterPutWeightedRoutingRequestBuilder.java b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterPutWeightedRoutingRequestBuilder.java index 83d37e781b02b..b437f4c54d8d6 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterPutWeightedRoutingRequestBuilder.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/ClusterPutWeightedRoutingRequestBuilder.java @@ -21,7 +21,7 @@ public class ClusterPutWeightedRoutingRequestBuilder extends ClusterManagerNodeO ClusterPutWeightedRoutingRequest, ClusterPutWeightedRoutingResponse, ClusterPutWeightedRoutingRequestBuilder> { - public ClusterPutWeightedRoutingRequestBuilder(OpenSearchClient client, ClusterPutWeightedRoutingAction action) { + public ClusterPutWeightedRoutingRequestBuilder(OpenSearchClient client, ClusterAddWeightedRoutingAction action) { super(client, action, new ClusterPutWeightedRoutingRequest()); } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/TransportAddWeightedRoutingAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/TransportAddWeightedRoutingAction.java index ab333efe0e0ab..461f1c6cc232c 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/TransportAddWeightedRoutingAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/shards/routing/weighted/put/TransportAddWeightedRoutingAction.java @@ -55,7 +55,7 @@ public TransportAddWeightedRoutingAction( IndexNameExpressionResolver indexNameExpressionResolver ) { super( - ClusterPutWeightedRoutingAction.NAME, + ClusterAddWeightedRoutingAction.NAME, transportService, clusterService, threadPool, diff --git a/server/src/main/java/org/opensearch/client/support/AbstractClient.java b/server/src/main/java/org/opensearch/client/support/AbstractClient.java index 0737b109b1c07..655135a229e93 100644 --- a/server/src/main/java/org/opensearch/client/support/AbstractClient.java +++ b/server/src/main/java/org/opensearch/client/support/AbstractClient.java @@ -110,7 +110,7 @@ import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsRequest; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsRequestBuilder; import org.opensearch.action.admin.cluster.shards.ClusterSearchShardsResponse; -import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterPutWeightedRoutingAction; +import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterAddWeightedRoutingAction; import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterPutWeightedRoutingRequest; import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterPutWeightedRoutingRequestBuilder; import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterPutWeightedRoutingResponse; @@ -1270,7 +1270,7 @@ public ActionFuture deleteDanglingIndex(DeleteDanglingInde @Override public ActionFuture putWeightedRouting(ClusterPutWeightedRoutingRequest request) { - return execute(ClusterPutWeightedRoutingAction.INSTANCE, request); + return execute(ClusterAddWeightedRoutingAction.INSTANCE, request); } @Override @@ -1278,12 +1278,12 @@ public void putWeightedRouting( ClusterPutWeightedRoutingRequest request, ActionListener listener ) { - execute(ClusterPutWeightedRoutingAction.INSTANCE, request, listener); + execute(ClusterAddWeightedRoutingAction.INSTANCE, request, listener); } @Override public ClusterPutWeightedRoutingRequestBuilder prepareWeightedRouting() { - return new ClusterPutWeightedRoutingRequestBuilder(this, ClusterPutWeightedRoutingAction.INSTANCE); + return new ClusterPutWeightedRoutingRequestBuilder(this, ClusterAddWeightedRoutingAction.INSTANCE); } @Override diff --git a/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java b/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java index 17e0cf5613f8c..e5cca998d3f06 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/WeightedRoutingServiceTests.java @@ -12,7 +12,7 @@ import org.junit.Before; import org.opensearch.Version; import org.opensearch.action.ActionListener; -import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterPutWeightedRoutingAction; +import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterAddWeightedRoutingAction; import org.opensearch.action.admin.cluster.shards.routing.weighted.put.ClusterPutWeightedRoutingRequestBuilder; import org.opensearch.client.node.NodeClient; import org.opensearch.cluster.ClusterName; @@ -179,7 +179,7 @@ public void testRegisterWeightedRoutingMetadataWithChangedWeights() throws Inter ClusterPutWeightedRoutingRequestBuilder request = new ClusterPutWeightedRoutingRequestBuilder( client, - ClusterPutWeightedRoutingAction.INSTANCE + ClusterAddWeightedRoutingAction.INSTANCE ); WeightedRouting updatedWeightedRouting = new WeightedRouting("zone", Map.of("zone_A", 1.0, "zone_B", 0.0, "zone_C", 0.0)); request.setWeightedRouting(updatedWeightedRouting); @@ -210,7 +210,7 @@ public void testRegisterWeightedRoutingMetadataWithSameWeights() throws Interrup ClusterPutWeightedRoutingRequestBuilder request = new ClusterPutWeightedRoutingRequestBuilder( client, - ClusterPutWeightedRoutingAction.INSTANCE + ClusterAddWeightedRoutingAction.INSTANCE ); WeightedRouting updatedWeightedRouting = new WeightedRouting("zone", weights); request.setWeightedRouting(updatedWeightedRouting); diff --git a/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterPutWeightedRoutingActionTests.java b/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterAddWeightedRoutingActionTests.java similarity index 98% rename from server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterPutWeightedRoutingActionTests.java rename to server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterAddWeightedRoutingActionTests.java index 3a6655a77b74c..a4cd6224217b7 100644 --- a/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterPutWeightedRoutingActionTests.java +++ b/server/src/test/java/org/opensearch/rest/action/admin/cluster/RestClusterAddWeightedRoutingActionTests.java @@ -24,7 +24,7 @@ import static java.util.Collections.singletonMap; -public class RestClusterPutWeightedRoutingActionTests extends RestActionTestCase { +public class RestClusterAddWeightedRoutingActionTests extends RestActionTestCase { private RestClusterPutWeightedRoutingAction action; @Before