Skip to content

Commit

Permalink
Change deprecation version from 2.1 to 2.2
Browse files Browse the repository at this point in the history
Signed-off-by: Tianli Feng <ftianli@amazon.com>
  • Loading branch information
Tianli Feng committed Jul 19, 2022
1 parent db1e208 commit 0a33ed8
Show file tree
Hide file tree
Showing 21 changed files with 61 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public boolean hasDiscoveredClusterManager() {
return clusterStateHealth.hasDiscoveredClusterManager();
}

/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #hasDiscoveredClusterManager()} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #hasDiscoveredClusterManager()} */
@Deprecated
public boolean hasDiscoveredMaster() {
return hasDiscoveredClusterManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ private static Engine.Result performOpOnReplica(
}
if (result.getResultType() == Engine.Result.Type.MAPPING_UPDATE_REQUIRED) {
// Even though the primary waits on all nodes to ack the mapping changes to the cluster-manager
// (see MappingUpdatedAction.updateMappingOnMaster) we still need to protect against missing mappings
// (see MappingUpdatedAction.updateMappingOnClusterManager) we still need to protect against missing mappings
// and wait for them. The reason is concurrent requests. Request r1 which has new field f triggers a
// mapping update. Assume that that update is first applied on the primary, and only later on the replica
// (it’s happening concurrently). Request r2, which now arrives on the primary and which also has the new
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public boolean localNodeClusterManager() {
/**
* Returns <code>true</code> iff the local node is the mater node of the cluster.
*
* @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #localNodeClusterManager()}
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #localNodeClusterManager()}
*/
@Deprecated
public boolean localNodeMaster() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void updateMappingOnClusterManager(Index index, Mapping mappingUpdate, Ac
* {@code timeout} is the cluster-manager node timeout ({@link ClusterManagerNodeRequest#clusterManagerNodeTimeout()}),
* potentially waiting for a cluster-manager node to be available.
*
* @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #updateMappingOnClusterManager(Index, Mapping, ActionListener)}
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #updateMappingOnClusterManager(Index, Mapping, ActionListener)}
*/
@Deprecated
public void updateMappingOnMaster(Index index, Mapping mappingUpdate, ActionListener<Void> listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import org.opensearch.cluster.ClusterStateTaskConfig;
import org.opensearch.cluster.ClusterStateTaskExecutor;
import org.opensearch.cluster.ClusterStateTaskListener;
import org.opensearch.cluster.ClusterManagerNodeChangePredicate;
import org.opensearch.cluster.NotClusterManagerException;
import org.opensearch.cluster.coordination.FailedToCommitClusterStateException;
import org.opensearch.cluster.metadata.IndexMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public boolean isBecomeClusterManagerTask() {
return reason.equals(BECOME_MASTER_TASK_REASON) || reason.equals(BECOME_CLUSTER_MANAGER_TASK_REASON);
}

/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #isBecomeClusterManagerTask()} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #isBecomeClusterManagerTask()} */
@Deprecated
public boolean isBecomeMasterTask() {
return isBecomeClusterManagerTask();
Expand Down Expand Up @@ -372,7 +372,7 @@ public static Task newBecomeClusterManagerTask() {

/**
* a task that is used to signal the election is stopped and we should process pending joins.
* it may be used in combination with {@link JoinTaskExecutor#newBecomeMasterTask()}
* it may be used in combination with {@link JoinTaskExecutor#newBecomeClusterManagerTask()}
*/
public static Task newFinishElectionTask() {
return new Task(null, Task.FINISH_ELECTION_TASK_REASON);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,19 @@ public void writeTo(StreamOutput out) throws IOException {
/**
* @return the node that is currently leading, according to the responding node.
*/
public Optional<DiscoveryNode> getMasterNode() {
public Optional<DiscoveryNode> getClusterManagerNode() {
return clusterManagerNode;
}

/**
* @return the node that is currently leading, according to the responding node.
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getClusterManagerNode()}
*/
@Deprecated
public Optional<DiscoveryNode> getMasterNode() {
return getClusterManagerNode();
}

/**
* @return the collection of known peers of the responding node, or an empty collection if the responding node believes there
* is currently a leader.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public boolean hasDiscoveredClusterManager() {
return hasDiscoveredClusterManager;
}

/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #hasDiscoveredClusterManager()} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #hasDiscoveredClusterManager()} */
@Deprecated
public boolean hasDiscoveredMaster() {
return hasDiscoveredClusterManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1572,7 +1572,7 @@ public PutRequest clusterManagerTimeout(TimeValue clusterManagerTimeout) {
return this;
}

/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #clusterManagerTimeout(TimeValue)} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagerTimeout(TimeValue)} */
@Deprecated
public PutRequest masterTimeout(TimeValue masterTimeout) {
return clusterManagerTimeout(masterTimeout);
Expand Down Expand Up @@ -1623,7 +1623,7 @@ public RemoveRequest clusterManagerTimeout(TimeValue clusterManagerTimeout) {
return this;
}

/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #clusterManagerTimeout} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagerTimeout} */
@Deprecated
public RemoveRequest masterTimeout(TimeValue masterTimeout) {
return clusterManagerTimeout(masterTimeout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static boolean isClusterManagerNode(Settings settings) {
return hasRole(settings, DiscoveryNodeRole.MASTER_ROLE) || hasRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE);
}

/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #isClusterManagerNode(Settings)} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #isClusterManagerNode(Settings)} */
@Deprecated
public static boolean isMasterNode(Settings settings) {
return isClusterManagerNode(settings);
Expand Down Expand Up @@ -475,7 +475,7 @@ public boolean isClusterManagerNode() {
/**
* Can this node become cluster-manager or not.
*
* @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #isClusterManagerNode()}
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #isClusterManagerNode()}
*/
@Deprecated
public boolean isMasterNode() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public boolean isLocalNodeElectedClusterManager() {
/**
* Returns {@code true} if the local node is the elected cluster-manager node.
*
* @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #isLocalNodeElectedClusterManager()}
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #isLocalNodeElectedClusterManager()}
*/
@Deprecated
public boolean isLocalNodeElectedMaster() {
Expand Down Expand Up @@ -172,7 +172,7 @@ public ImmutableOpenMap<String, DiscoveryNode> getClusterManagerNodes() {
* Get a {@link Map} of the discovered cluster-manager nodes arranged by their ids
*
* @return {@link Map} of the discovered cluster-manager nodes arranged by their ids
* @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #getClusterManagerNodes()}
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getClusterManagerNodes()}
*/
@Deprecated
public ImmutableOpenMap<String, DiscoveryNode> getMasterNodes() {
Expand Down Expand Up @@ -201,7 +201,7 @@ public ImmutableOpenMap<String, DiscoveryNode> getClusterManagerAndDataNodes() {
* Get a {@link Map} of the discovered cluster-manager and data nodes arranged by their ids
*
* @return {@link Map} of the discovered cluster-manager and data nodes arranged by their ids
* @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #getClusterManagerAndDataNodes()}
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getClusterManagerAndDataNodes()}
*/
@Deprecated
public ImmutableOpenMap<String, DiscoveryNode> getMasterAndDataNodes() {
Expand Down Expand Up @@ -234,7 +234,7 @@ public Stream<DiscoveryNode> clusterManagersFirstStream() {
/**
* Returns a stream of all nodes, with cluster-manager nodes at the front
*
* @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #clusterManagersFirstStream()}
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagersFirstStream()}
*/
@Deprecated
public Stream<DiscoveryNode> mastersFirstStream() {
Expand Down Expand Up @@ -306,7 +306,7 @@ public String getClusterManagerNodeId() {
* Get the id of the cluster-manager node
*
* @return id of the cluster-manager
* @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #getClusterManagerNodeId()}
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getClusterManagerNodeId()}
*/
@Deprecated
public String getMasterNodeId() {
Expand Down Expand Up @@ -345,7 +345,7 @@ public DiscoveryNode getClusterManagerNode() {
/**
* Returns the cluster-manager node, or {@code null} if there is no cluster-manager node
*
* @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #getClusterManagerNode()}
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getClusterManagerNode()}
*/
@Deprecated
@Nullable
Expand Down Expand Up @@ -616,7 +616,7 @@ public boolean clusterManagerNodeChanged() {
return Objects.equals(newClusterManagerNode, previousClusterManagerNode) == false;
}

/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #clusterManagerNodeChanged()} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagerNodeChanged()} */
@Deprecated
public boolean masterNodeChanged() {
return clusterManagerNodeChanged();
Expand All @@ -627,7 +627,7 @@ public DiscoveryNode previousClusterManagerNode() {
return previousClusterManagerNode;
}

/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #previousClusterManagerNode()} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #previousClusterManagerNode()} */
@Deprecated
@Nullable
public DiscoveryNode previousMasterNode() {
Expand All @@ -639,7 +639,7 @@ public DiscoveryNode newClusterManagerNode() {
return newClusterManagerNode;
}

/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #newClusterManagerNode()} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #newClusterManagerNode()} */
@Deprecated
@Nullable
public DiscoveryNode newMasterNode() {
Expand Down Expand Up @@ -813,7 +813,7 @@ public Builder clusterManagerNodeId(String clusterManagerNodeId) {
return this;
}

/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #clusterManagerNodeId} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagerNodeId} */
@Deprecated
public Builder masterNodeId(String clusterManagerNodeId) {
return clusterManagerNodeId(clusterManagerNodeId);
Expand Down Expand Up @@ -899,7 +899,7 @@ public boolean isLocalNodeElectedClusterManager() {
return clusterManagerNodeId != null && clusterManagerNodeId.equals(localNodeId);
}

/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #isLocalNodeElectedClusterManager()} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #isLocalNodeElectedClusterManager()} */
@Deprecated
public boolean isLocalNodeElectedMaster() {
return isLocalNodeElectedClusterManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,11 @@ private synchronized void scheduleIfNeeded(long currentNanoTime, ClusterState st

// protected so that it can be overridden (and disabled) by unit tests
protected void assertClusterOrClusterManagerStateThread() {
assert ClusterService.assertClusterOrMasterStateThread();
assert ClusterService.assertClusterOrClusterManagerStateThread();
}

// protected so that it can be overridden (and disabled) by unit tests
/** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #assertClusterOrClusterManagerStateThread()} */
/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #assertClusterOrClusterManagerStateThread()} */
@Deprecated
protected void assertClusterOrMasterStateThread() {
assertClusterOrClusterManagerStateThread();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.opensearch.cluster.ClusterStateObserver;
import org.opensearch.cluster.ClusterStateTaskConfig;
import org.opensearch.cluster.LocalNodeClusterManagerListener;
import org.opensearch.cluster.LocalNodeMasterListener;
import org.opensearch.cluster.NodeConnectionsService;
import org.opensearch.cluster.TimeoutClusterStateListener;
import org.opensearch.cluster.metadata.ProcessClusterEventTimeoutException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import org.opensearch.cluster.ClusterStateTaskExecutor;
import org.opensearch.cluster.ClusterStateTaskListener;
import org.opensearch.cluster.LocalNodeClusterManagerListener;
import org.opensearch.cluster.LocalNodeMasterListener;
import org.opensearch.cluster.NodeConnectionsService;
import org.opensearch.cluster.node.DiscoveryNode;
import org.opensearch.cluster.routing.OperationRouting;
Expand Down Expand Up @@ -249,13 +250,19 @@ public ClusterApplierService getClusterApplierService() {
return clusterApplierService;
}

public static boolean assertClusterOrMasterStateThread() {
public static boolean assertClusterOrClusterManagerStateThread() {
assert Thread.currentThread().getName().contains(ClusterApplierService.CLUSTER_UPDATE_THREAD_NAME)
|| Thread.currentThread().getName().contains(MasterService.MASTER_UPDATE_THREAD_NAME)
: "not called from the master/cluster state update thread";
return true;
}

/** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #assertClusterOrClusterManagerStateThread} */
@Deprecated
public static boolean assertClusterOrMasterStateThread() {
return assertClusterOrClusterManagerStateThread();
}

public ClusterName getClusterName() {
return clusterName;
}
Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/org/opensearch/discovery/PeerFinder.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,11 @@ public void handleResponse(PeersResponse response) {

peersRequestInFlight = false;

response.getMasterNode().map(DiscoveryNode::getAddress).ifPresent(PeerFinder.this::startProbe);
response.getClusterManagerNode().map(DiscoveryNode::getAddress).ifPresent(PeerFinder.this::startProbe);
response.getKnownPeers().stream().map(DiscoveryNode::getAddress).forEach(PeerFinder.this::startProbe);
}

if (response.getMasterNode().equals(Optional.of(discoveryNode))) {
if (response.getClusterManagerNode().equals(Optional.of(discoveryNode))) {
// Must not hold lock here to avoid deadlock
assert holdsLock() == false : "PeerFinder mutex is held in error";
onActiveClusterManagerFound(discoveryNode, response.getTerm());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ public synchronized void updateFromClusterManager(
* @param applyingClusterStateVersion the cluster state version being applied when updating the allocation IDs from the cluster-manager
* @param inSyncAllocationIds the allocation IDs of the currently in-sync shard copies
* @param routingTable the shard routing table
* @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #updateFromClusterManager(long, Set, IndexShardRoutingTable)}
* @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #updateFromClusterManager(long, Set, IndexShardRoutingTable)}
*/
@Deprecated
public synchronized void updateFromMaster(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void testUpdatesNodeWithNewRoles() throws Exception {
}

/**
* Validate isBecomeMasterTask() can identify "become cluster manager task" properly
* Validate isBecomeClusterManagerTask() can identify "become cluster manager task" properly
*/
public void testIsBecomeClusterManagerTask() {
JoinTaskExecutor.Task joinTaskOfMaster = JoinTaskExecutor.newBecomeMasterTask();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public void testAutoExpandWhenNodeLeavesAndPossiblyRejoins() throws InterruptedE
nodesToAdd.add(createNode(DiscoveryNodeRole.DATA_ROLE));
}

state = cluster.joinNodesAndBecomeMaster(state, nodesToAdd);
state = cluster.joinNodesAndBecomeClusterManager(state, nodesToAdd);
postTable = state.routingTable().index("index").shard(0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,12 @@ public void testPeersResponseEqualsHashCodeSerialization() {
final long term = in.getTerm();
if (randomBoolean()) {
return new PeersResponse(
in.getMasterNode(),
in.getClusterManagerNode(),
in.getKnownPeers(),
randomValueOtherThan(term, OpenSearchTestCase::randomNonNegativeLong)
);
} else {
if (in.getMasterNode().isPresent()) {
if (in.getClusterManagerNode().isPresent()) {
if (randomBoolean()) {
return new PeersResponse(Optional.of(createNode(randomAlphaOfLength(10))), in.getKnownPeers(), term);
} else {
Expand All @@ -112,7 +112,7 @@ public void testPeersResponseEqualsHashCodeSerialization() {
if (randomBoolean()) {
return new PeersResponse(Optional.of(createNode(randomAlphaOfLength(10))), emptyList(), term);
} else {
return new PeersResponse(in.getMasterNode(), modifyDiscoveryNodesList(in.getKnownPeers(), false), term);
return new PeersResponse(in.getClusterManagerNode(), modifyDiscoveryNodesList(in.getKnownPeers(), false), term);
}
}
}
Expand Down
Loading

0 comments on commit 0a33ed8

Please sign in to comment.