From 8fc134d1e2653c28c411f6b5f03f2d1f0a0c26cd Mon Sep 17 00:00:00 2001 From: Tianli Feng Date: Fri, 17 Jun 2022 11:34:40 -0700 Subject: [PATCH] Rename and deprecate remaining methods in the package Signed-off-by: Tianli Feng --- .../admin/indices/shrink/TransportResizeAction.java | 4 ++-- .../TransportClusterManagerNodeAction.java | 4 ++-- .../action/support/master/MasterNodeRequest.java | 5 ++--- .../support/master/TransportMasterNodeAction.java | 12 +++++++++++- .../master/info/TransportClusterInfoAction.java | 3 +-- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java index 50107fdf5f228..ba079aeb03921 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/shrink/TransportResizeAction.java @@ -251,7 +251,7 @@ static CreateIndexClusterStateUpdateRequest prepareCreateIndexRequest( } @Override - protected String getMasterActionName(DiscoveryNode node) { - return super.getMasterActionName(node); + protected String getClusterManagerActionName(DiscoveryNode node) { + return super.getClusterManagerActionName(node); } } diff --git a/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java b/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java index 05f098bd50106..ca2bf9c828dc1 100644 --- a/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java +++ b/server/src/main/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeAction.java @@ -222,7 +222,7 @@ protected void doStart(ClusterState clusterState) { retryOnMasterChange(clusterState, null); } else { DiscoveryNode clusterManagerNode = nodes.getMasterNode(); - final String actionName = getMasterActionName(clusterManagerNode); + final String actionName = getClusterManagerActionName(clusterManagerNode); transportService.sendRequest( clusterManagerNode, actionName, @@ -303,7 +303,7 @@ public void onTimeout(TimeValue timeout) { * Allows to conditionally return a different cluster-manager node action name in the case an action gets renamed. * This mainly for backwards compatibility should be used rarely */ - protected String getMasterActionName(DiscoveryNode node) { + protected String getClusterManagerActionName(DiscoveryNode node) { return actionName; } } diff --git a/server/src/main/java/org/opensearch/action/support/master/MasterNodeRequest.java b/server/src/main/java/org/opensearch/action/support/master/MasterNodeRequest.java index 6b8fde1db8a32..d80868c2c9145 100644 --- a/server/src/main/java/org/opensearch/action/support/master/MasterNodeRequest.java +++ b/server/src/main/java/org/opensearch/action/support/master/MasterNodeRequest.java @@ -63,8 +63,7 @@ protected MasterNodeRequest(StreamInput in) throws IOException { @SuppressWarnings("unchecked") @Deprecated public final Request masterNodeTimeout(TimeValue timeout) { - this.masterNodeTimeout = timeout; - return (Request) this; + return clusterManagerNodeTimeout(timeout); } /** @@ -72,6 +71,6 @@ public final Request masterNodeTimeout(TimeValue timeout) { */ @Deprecated public final Request masterNodeTimeout(String timeout) { - return masterNodeTimeout(TimeValue.parseTimeValue(timeout, null, getClass().getSimpleName() + ".masterNodeTimeout")); + return clusterManagerNodeTimeout(timeout); } } diff --git a/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java b/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java index bbfe991d3911b..3514d941c937d 100644 --- a/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java +++ b/server/src/main/java/org/opensearch/action/support/master/TransportMasterNodeAction.java @@ -39,6 +39,7 @@ import org.opensearch.action.support.clustermanager.TransportClusterManagerNodeAction; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.metadata.IndexNameExpressionResolver; +import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; import org.opensearch.common.io.stream.Writeable; import org.opensearch.tasks.Task; @@ -97,6 +98,15 @@ protected TransportMasterNodeAction( */ @Deprecated protected void masterOperation(Task task, Request request, ClusterState state, ActionListener listener) throws Exception { - super.clusterManagerOperation(task, request, state, listener); + clusterManagerOperation(task, request, state, listener); + } + + /** + * Allows to conditionally return a different cluster-manager node action name in the case an action gets renamed. + * This mainly for backwards compatibility should be used rarely + */ + @Deprecated + protected String getMasterActionName(DiscoveryNode node) { + return getClusterManagerActionName(node); } } diff --git a/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java b/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java index 18c7ac6be89f2..feeda55e224ab 100644 --- a/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java +++ b/server/src/main/java/org/opensearch/action/support/master/info/TransportClusterInfoAction.java @@ -63,8 +63,7 @@ public TransportClusterInfoAction( @Override protected final void masterOperation(final Request request, final ClusterState state, final ActionListener listener) { - String[] concreteIndices = indexNameExpressionResolver.concreteIndexNames(state, request); - doMasterOperation(request, concreteIndices, state, listener); + clusterManagerOperation(request, state, listener); } @Deprecated