Skip to content

Commit

Permalink
Refactor code
Browse files Browse the repository at this point in the history
Signed-off-by: Anshu Agarwal <anshukag@amazon.com>
  • Loading branch information
Anshu Agarwal committed Sep 26, 2022
1 parent 006600c commit 0240ff0
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions server/src/main/java/org/opensearch/action/ActionModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -566,7 +566,7 @@ public <Request extends ActionRequest, Response extends ActionResponse> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
*
* @opensearch.internal
*/
public final class ClusterPutWeightedRoutingAction extends ActionType<ClusterPutWeightedRoutingResponse> {
public final class ClusterAddWeightedRoutingAction extends ActionType<ClusterPutWeightedRoutingResponse> {

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public TransportAddWeightedRoutingAction(
IndexNameExpressionResolver indexNameExpressionResolver
) {
super(
ClusterPutWeightedRoutingAction.NAME,
ClusterAddWeightedRoutingAction.NAME,
transportService,
clusterService,
threadPool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1270,20 +1270,20 @@ public ActionFuture<AcknowledgedResponse> deleteDanglingIndex(DeleteDanglingInde

@Override
public ActionFuture<ClusterPutWeightedRoutingResponse> putWeightedRouting(ClusterPutWeightedRoutingRequest request) {
return execute(ClusterPutWeightedRoutingAction.INSTANCE, request);
return execute(ClusterAddWeightedRoutingAction.INSTANCE, request);
}

@Override
public void putWeightedRouting(
ClusterPutWeightedRoutingRequest request,
ActionListener<ClusterPutWeightedRoutingResponse> 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import static java.util.Collections.singletonMap;

public class RestClusterPutWeightedRoutingActionTests extends RestActionTestCase {
public class RestClusterAddWeightedRoutingActionTests extends RestActionTestCase {
private RestClusterPutWeightedRoutingAction action;

@Before
Expand Down

0 comments on commit 0240ff0

Please sign in to comment.