diff --git a/modules/reindex/src/test/java/org/opensearch/index/reindex/RetryTests.java b/modules/reindex/src/test/java/org/opensearch/index/reindex/RetryTests.java index 1c1a55bf59537..55234bcaaf0e2 100644 --- a/modules/reindex/src/test/java/org/opensearch/index/reindex/RetryTests.java +++ b/modules/reindex/src/test/java/org/opensearch/index/reindex/RetryTests.java @@ -123,7 +123,7 @@ public void testReindexFromRemote() throws Exception { */ NodeInfo clusterManagerNode = null; for (NodeInfo candidate : client.admin().cluster().prepareNodesInfo().get().getNodes()) { - if (candidate.getNode().isMasterNode()) { + if (candidate.getNode().isClusterManagerNode()) { clusterManagerNode = candidate; } } diff --git a/plugins/discovery-azure-classic/src/internalClusterTest/java/org/opensearch/discovery/azure/classic/AzureSimpleTests.java b/plugins/discovery-azure-classic/src/internalClusterTest/java/org/opensearch/discovery/azure/classic/AzureSimpleTests.java index f78fb4617d198..4c2dda180eda6 100644 --- a/plugins/discovery-azure-classic/src/internalClusterTest/java/org/opensearch/discovery/azure/classic/AzureSimpleTests.java +++ b/plugins/discovery-azure-classic/src/internalClusterTest/java/org/opensearch/discovery/azure/classic/AzureSimpleTests.java @@ -51,7 +51,7 @@ public void testOneNodeShouldRunUsingPrivateIp() { final String node1 = internalCluster().startNode(settings); registerAzureNode(node1); assertNotNull( - client().admin().cluster().prepareState().setClusterManagerNodeTimeout("1s").get().getState().nodes().getMasterNodeId() + client().admin().cluster().prepareState().setClusterManagerNodeTimeout("1s").get().getState().nodes().getClusterManagerNodeId() ); // We expect having 1 node as part of the cluster, let's test that @@ -66,7 +66,7 @@ public void testOneNodeShouldRunUsingPublicIp() { final String node1 = internalCluster().startNode(settings); registerAzureNode(node1); assertNotNull( - client().admin().cluster().prepareState().setClusterManagerNodeTimeout("1s").get().getState().nodes().getMasterNodeId() + client().admin().cluster().prepareState().setClusterManagerNodeTimeout("1s").get().getState().nodes().getClusterManagerNodeId() ); // We expect having 1 node as part of the cluster, let's test that diff --git a/plugins/discovery-azure-classic/src/internalClusterTest/java/org/opensearch/discovery/azure/classic/AzureTwoStartedNodesTests.java b/plugins/discovery-azure-classic/src/internalClusterTest/java/org/opensearch/discovery/azure/classic/AzureTwoStartedNodesTests.java index f0af35092c8ca..10e8a65e906cc 100644 --- a/plugins/discovery-azure-classic/src/internalClusterTest/java/org/opensearch/discovery/azure/classic/AzureTwoStartedNodesTests.java +++ b/plugins/discovery-azure-classic/src/internalClusterTest/java/org/opensearch/discovery/azure/classic/AzureTwoStartedNodesTests.java @@ -54,14 +54,14 @@ public void testTwoNodesShouldRunUsingPrivateOrPublicIp() { final String node1 = internalCluster().startNode(settings); registerAzureNode(node1); assertNotNull( - client().admin().cluster().prepareState().setClusterManagerNodeTimeout("1s").get().getState().nodes().getMasterNodeId() + client().admin().cluster().prepareState().setClusterManagerNodeTimeout("1s").get().getState().nodes().getClusterManagerNodeId() ); logger.info("--> start another node"); final String node2 = internalCluster().startNode(settings); registerAzureNode(node2); assertNotNull( - client().admin().cluster().prepareState().setClusterManagerNodeTimeout("1s").get().getState().nodes().getMasterNodeId() + client().admin().cluster().prepareState().setClusterManagerNodeTimeout("1s").get().getState().nodes().getClusterManagerNodeId() ); // We expect having 2 nodes as part of the cluster, let's test that diff --git a/plugins/discovery-gce/src/internalClusterTest/java/org/opensearch/discovery/gce/GceDiscoverTests.java b/plugins/discovery-gce/src/internalClusterTest/java/org/opensearch/discovery/gce/GceDiscoverTests.java index de4f267547eb3..4f83c39dc4ef0 100644 --- a/plugins/discovery-gce/src/internalClusterTest/java/org/opensearch/discovery/gce/GceDiscoverTests.java +++ b/plugins/discovery-gce/src/internalClusterTest/java/org/opensearch/discovery/gce/GceDiscoverTests.java @@ -96,7 +96,7 @@ public void testJoin() { .clear() .setNodes(true) .get(); - assertNotNull(clusterStateResponse.getState().nodes().getMasterNodeId()); + assertNotNull(clusterStateResponse.getState().nodes().getClusterManagerNodeId()); // start another node final String secondNode = internalCluster().startNode(); @@ -109,7 +109,7 @@ public void testJoin() { .setNodes(true) .setLocal(true) .get(); - assertNotNull(clusterStateResponse.getState().nodes().getMasterNodeId()); + assertNotNull(clusterStateResponse.getState().nodes().getClusterManagerNodeId()); // wait for the cluster to form assertNoTimeout(client().admin().cluster().prepareHealth().setWaitForNodes(Integer.toString(2)).get()); diff --git a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/state/TransportClusterStateActionDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/state/TransportClusterStateActionDisruptionIT.java index 2dfe784e47350..3be75d672d823 100644 --- a/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/state/TransportClusterStateActionDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/action/admin/cluster/state/TransportClusterStateActionDisruptionIT.java @@ -82,7 +82,10 @@ public void testNonLocalRequestAlwaysFindsClusterManager() throws Exception { } catch (ClusterManagerNotDiscoveredException e) { return; // ok, we hit the disconnected node } - assertNotNull("should always contain a cluster-manager node", clusterStateResponse.getState().nodes().getMasterNodeId()); + assertNotNull( + "should always contain a cluster-manager node", + clusterStateResponse.getState().nodes().getClusterManagerNodeId() + ); }); } @@ -134,7 +137,7 @@ public void testNonLocalRequestAlwaysFindsClusterManagerAndWaitsForMetadata() th } if (clusterStateResponse.isWaitForTimedOut() == false) { final ClusterState state = clusterStateResponse.getState(); - assertNotNull("should always contain a cluster-manager node", state.nodes().getMasterNodeId()); + assertNotNull("should always contain a cluster-manager node", state.nodes().getClusterManagerNodeId()); assertThat("waited for metadata version", state.metadata().version(), greaterThanOrEqualTo(waitForMetadataVersion)); } }); diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/MinimumClusterManagerNodesIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/MinimumClusterManagerNodesIT.java index 8da6040b6f996..c431dfaa14fa0 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/MinimumClusterManagerNodesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/MinimumClusterManagerNodesIT.java @@ -168,7 +168,7 @@ public void testTwoNodesNoClusterManagerBlock() throws Exception { assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(true)); // verify that both nodes are still in the cluster state but there is no cluster-manager assertThat(state.nodes().getSize(), equalTo(2)); - assertThat(state.nodes().getMasterNode(), equalTo(null)); + assertThat(state.nodes().getClusterManagerNode(), equalTo(null)); logger.info("--> starting the previous cluster-manager node again..."); node2Name = internalCluster().startNode(Settings.builder().put(settings).put(clusterManagerDataPathSettings).build()); @@ -387,7 +387,7 @@ public void onFailure(String source, Exception e) { assertThat(failure.get(), instanceOf(FailedToCommitClusterStateException.class)); logger.debug("--> check that there is no cluster-manager in minor partition"); - assertBusy(() -> assertThat(clusterManagerClusterService.state().nodes().getMasterNode(), nullValue())); + assertBusy(() -> assertThat(clusterManagerClusterService.state().nodes().getClusterManagerNode(), nullValue())); // let major partition to elect new cluster-manager, to ensure that old cluster-manager is not elected once partition is restored, // otherwise persistent setting (which is a part of accepted state on old cluster-manager) will be propagated to other nodes @@ -401,7 +401,7 @@ public void onFailure(String source, Exception e) { .actionGet() .getState() .nodes() - .getMasterNode(); + .getClusterManagerNode(); assertThat(clusterManagerNode, notNullValue()); assertThat(clusterManagerNode.getName(), not(equalTo(clusterManager))); }); diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java index e3adeb1ad8d82..df0052f82e43a 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/SimpleClusterStateIT.java @@ -473,7 +473,7 @@ public Collection createComponents( return; } - if (state.nodes().isLocalNodeElectedMaster()) { + if (state.nodes().isLocalNodeElectedClusterManager()) { if (state.custom("test") == null) { if (installed.compareAndSet(false, true)) { clusterService.submitStateUpdateTask("install-metadata-custom", new ClusterStateUpdateTask(Priority.URGENT) { diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/SpecificClusterManagerNodesIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/SpecificClusterManagerNodesIT.java index ebdff162ca4e2..073f006d105f2 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/SpecificClusterManagerNodesIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/SpecificClusterManagerNodesIT.java @@ -69,7 +69,7 @@ public void testSimpleOnlyClusterManagerNodeElection() throws IOException { .actionGet() .getState() .nodes() - .getMasterNodeId(), + .getClusterManagerNodeId(), nullValue() ); fail("should not be able to find cluster-manager"); @@ -87,7 +87,7 @@ public void testSimpleOnlyClusterManagerNodeElection() throws IOException { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(clusterManagerNodeName) ); @@ -100,7 +100,7 @@ public void testSimpleOnlyClusterManagerNodeElection() throws IOException { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(clusterManagerNodeName) ); @@ -119,7 +119,7 @@ public void testSimpleOnlyClusterManagerNodeElection() throws IOException { .actionGet() .getState() .nodes() - .getMasterNodeId(), + .getClusterManagerNodeId(), nullValue() ); fail("should not be able to find cluster-manager"); @@ -140,7 +140,7 @@ public void testSimpleOnlyClusterManagerNodeElection() throws IOException { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(nextClusterManagerEligibleNodeName) ); @@ -153,7 +153,7 @@ public void testSimpleOnlyClusterManagerNodeElection() throws IOException { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(nextClusterManagerEligibleNodeName) ); @@ -173,7 +173,7 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception { .actionGet() .getState() .nodes() - .getMasterNodeId(), + .getClusterManagerNodeId(), nullValue() ); fail("should not be able to find cluster-manager"); @@ -191,7 +191,7 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(clusterManagerNodeName) ); @@ -204,7 +204,7 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(clusterManagerNodeName) ); @@ -220,7 +220,7 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(clusterManagerNodeName) ); @@ -233,7 +233,7 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(clusterManagerNodeName) ); @@ -246,7 +246,7 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(clusterManagerNodeName) ); @@ -264,7 +264,7 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(nextClusterManagerEligableNodeName) ); @@ -277,7 +277,7 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(nextClusterManagerEligableNodeName) ); @@ -292,7 +292,7 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(nextClusterManagerEligableNodeName) ); @@ -305,7 +305,7 @@ public void testElectOnlyBetweenClusterManagerNodes() throws Exception { .actionGet() .getState() .nodes() - .getMasterNode() + .getClusterManagerNode() .getName(), equalTo(nextClusterManagerEligableNodeName) ); diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java index 61b186c951ce8..90b9ff7cab3b5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/RareClusterStateIT.java @@ -244,13 +244,13 @@ public void testDelayedMappingPropagationOnPrimary() throws Exception { // Check routing tables ClusterState state = client().admin().cluster().prepareState().get().getState(); - assertEquals(clusterManager, state.nodes().getMasterNode().getName()); + assertEquals(clusterManager, state.nodes().getClusterManagerNode().getName()); List shards = state.routingTable().allShards("index"); assertThat(shards, hasSize(1)); for (ShardRouting shard : shards) { if (shard.primary()) { // primary must not be on the cluster-manager node - assertFalse(state.nodes().getMasterNodeId().equals(shard.currentNodeId())); + assertFalse(state.nodes().getClusterManagerNodeId().equals(shard.currentNodeId())); } else { fail(); // only primaries } @@ -336,13 +336,13 @@ public void testDelayedMappingPropagationOnReplica() throws Exception { // Check routing tables ClusterState state = client().admin().cluster().prepareState().get().getState(); - assertEquals(clusterManager, state.nodes().getMasterNode().getName()); + assertEquals(clusterManager, state.nodes().getClusterManagerNode().getName()); List shards = state.routingTable().allShards("index"); assertThat(shards, hasSize(2)); for (ShardRouting shard : shards) { if (shard.primary()) { // primary must be on the cluster-manager - assertEquals(state.nodes().getMasterNodeId(), shard.currentNodeId()); + assertEquals(state.nodes().getClusterManagerNodeId(), shard.currentNodeId()); } else { assertTrue(shard.active()); } diff --git a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/VotingConfigurationIT.java b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/VotingConfigurationIT.java index 544565f4c1cd4..64474546f6106 100644 --- a/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/VotingConfigurationIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/cluster/coordination/VotingConfigurationIT.java @@ -105,7 +105,7 @@ public void testElectsNodeNotInVotingConfiguration() throws Exception { final Set votingConfiguration = clusterState.getLastCommittedConfiguration().getNodeIds(); assertThat(votingConfiguration, hasSize(3)); assertThat(clusterState.nodes().getSize(), equalTo(4)); - assertThat(votingConfiguration, hasItem(clusterState.nodes().getMasterNodeId())); + assertThat(votingConfiguration, hasItem(clusterState.nodes().getClusterManagerNodeId())); for (DiscoveryNode discoveryNode : clusterState.nodes()) { if (votingConfiguration.contains(discoveryNode.getId()) == false) { assertThat(excludedNodeName, nullValue()); @@ -155,7 +155,10 @@ public void testElectsNodeNotInVotingConfiguration() throws Exception { .setMetadata(true) .get() .getState(); - assertThat(newClusterState.nodes().getMasterNode().getName(), equalTo(excludedNodeName)); - assertThat(newClusterState.getLastCommittedConfiguration().getNodeIds(), hasItem(newClusterState.nodes().getMasterNodeId())); + assertThat(newClusterState.nodes().getClusterManagerNode().getName(), equalTo(excludedNodeName)); + assertThat( + newClusterState.getLastCommittedConfiguration().getNodeIds(), + hasItem(newClusterState.nodes().getClusterManagerNodeId()) + ); } } diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterManagerDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterManagerDisruptionIT.java index 2f19d1e476c94..cd8846067ad1f 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterManagerDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/ClusterManagerDisruptionIT.java @@ -171,7 +171,11 @@ public void testIsolateClusterManagerAndVerifyClusterStateConsensus() throws Exc try { assertEquals("unequal versions", state.version(), nodeState.version()); assertEquals("unequal node count", state.nodes().getSize(), nodeState.nodes().getSize()); - assertEquals("different cluster-managers ", state.nodes().getMasterNodeId(), nodeState.nodes().getMasterNodeId()); + assertEquals( + "different cluster-managers ", + state.nodes().getClusterManagerNodeId(), + nodeState.nodes().getClusterManagerNodeId() + ); assertEquals("different meta data version", state.metadata().version(), nodeState.metadata().version()); assertEquals("different routing", state.routingTable().toString(), nodeState.routingTable().toString()); } catch (AssertionError t) { @@ -238,7 +242,7 @@ public void testVerifyApiBlocksDuringPartition() throws Exception { for (String node : partitions.getMajoritySide()) { ClusterState nodeState = getNodeClusterState(node); boolean success = true; - if (nodeState.nodes().getMasterNode() == null) { + if (nodeState.nodes().getClusterManagerNode() == null) { success = false; } if (!nodeState.blocks().global().isEmpty()) { diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/DiscoveryDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/DiscoveryDisruptionIT.java index c6e4d95449d42..1825fbdcf32d5 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/DiscoveryDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/DiscoveryDisruptionIT.java @@ -71,7 +71,7 @@ public void testClusterJoinDespiteOfPublishingIssues() throws Exception { TransportService clusterManagerTranspotService = internalCluster().getInstance( TransportService.class, - discoveryNodes.getMasterNode().getName() + discoveryNodes.getClusterManagerNode().getName() ); logger.info("blocking requests from non cluster-manager [{}] to cluster-manager [{}]", nonClusterManagerNode, clusterManagerNode); diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/StableClusterManagerDisruptionIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/StableClusterManagerDisruptionIT.java index fcc2b7a7d5ad4..8992e4749c1aa 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/StableClusterManagerDisruptionIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/StableClusterManagerDisruptionIT.java @@ -129,7 +129,7 @@ public void testFailWithMinimumClusterManagerNodesConfigured() throws Exception private void ensureNoMaster(String node) throws Exception { assertBusy( () -> assertNull( - client(node).admin().cluster().state(new ClusterStateRequest().local(true)).get().getState().nodes().getMasterNode() + client(node).admin().cluster().state(new ClusterStateRequest().local(true)).get().getState().nodes().getClusterManagerNode() ) ); } @@ -220,8 +220,8 @@ public void testStaleClusterManagerNotHijackingMajority() throws Exception { for (final String node : majoritySide) { clusterManagers.put(node, new ArrayList<>()); internalCluster().getInstance(ClusterService.class, node).addListener(event -> { - DiscoveryNode previousClusterManager = event.previousState().nodes().getMasterNode(); - DiscoveryNode currentClusterManager = event.state().nodes().getMasterNode(); + DiscoveryNode previousClusterManager = event.previousState().nodes().getClusterManagerNode(); + DiscoveryNode currentClusterManager = event.state().nodes().getClusterManagerNode(); if (!Objects.equals(previousClusterManager, currentClusterManager)) { logger.info( "--> node {} received new cluster state: {} \n and had previous cluster state: {}", @@ -238,7 +238,7 @@ public void testStaleClusterManagerNotHijackingMajority() throws Exception { final CountDownLatch oldClusterManagerNodeSteppedDown = new CountDownLatch(1); internalCluster().getInstance(ClusterService.class, oldClusterManagerNode).addListener(event -> { - if (event.state().nodes().getMasterNodeId() == null) { + if (event.state().nodes().getClusterManagerNodeId() == null) { oldClusterManagerNodeSteppedDown.countDown(); } }); diff --git a/server/src/internalClusterTest/java/org/opensearch/discovery/single/SingleNodeDiscoveryIT.java b/server/src/internalClusterTest/java/org/opensearch/discovery/single/SingleNodeDiscoveryIT.java index 13aea01772424..47df0aeced3cb 100644 --- a/server/src/internalClusterTest/java/org/opensearch/discovery/single/SingleNodeDiscoveryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/discovery/single/SingleNodeDiscoveryIT.java @@ -112,7 +112,7 @@ public Path nodeConfigPath(int nodeOrdinal) { final ClusterState second = other.getInstance(ClusterService.class).state(); assertThat(first.nodes().getSize(), equalTo(1)); assertThat(second.nodes().getSize(), equalTo(1)); - assertThat(first.nodes().getMasterNodeId(), not(equalTo(second.nodes().getMasterNodeId()))); + assertThat(first.nodes().getClusterManagerNodeId(), not(equalTo(second.nodes().getClusterManagerNodeId()))); assertThat(first.metadata().clusterUUID(), not(equalTo(second.metadata().clusterUUID()))); } } diff --git a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java index 89f4b077138f6..e33560b9bbd4e 100644 --- a/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java +++ b/server/src/internalClusterTest/java/org/opensearch/indices/recovery/IndexRecoveryIT.java @@ -1510,7 +1510,7 @@ public void testOngoingRecoveryAndClusterManagerFailOver() throws Exception { ); phase1ReadyBlocked.await(); internalCluster().restartNode( - clusterService().state().nodes().getMasterNode().getName(), + clusterService().state().nodes().getClusterManagerNode().getName(), new InternalTestCluster.RestartCallback() ); internalCluster().ensureAtLeastNumDataNodes(3); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java index a8035a10e8d91..a2a77a1316898 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/configuration/AddVotingConfigExclusionsRequest.java @@ -132,7 +132,7 @@ Set resolveVotingConfigExclusions(ClusterState currentSta if (nodeDescriptions.length >= 1) { newVotingConfigExclusions = Arrays.stream(allNodes.resolveNodes(nodeDescriptions)) .map(allNodes::get) - .filter(DiscoveryNode::isMasterNode) + .filter(DiscoveryNode::isClusterManagerNode) .map(VotingConfigExclusion::new) .collect(Collectors.toSet()); @@ -147,7 +147,7 @@ Set resolveVotingConfigExclusions(ClusterState currentSta for (String nodeId : nodeIds) { if (allNodes.nodeExists(nodeId)) { DiscoveryNode discoveryNode = allNodes.get(nodeId); - if (discoveryNode.isMasterNode()) { + if (discoveryNode.isClusterManagerNode()) { newVotingConfigExclusions.add(new VotingConfigExclusion(discoveryNode)); } } else { @@ -162,7 +162,7 @@ Set resolveVotingConfigExclusions(ClusterState currentSta for (String nodeName : nodeNames) { if (existingNodes.containsKey(nodeName)) { DiscoveryNode discoveryNode = existingNodes.get(nodeName); - if (discoveryNode.isMasterNode()) { + if (discoveryNode.isClusterManagerNode()) { newVotingConfigExclusions.add(new VotingConfigExclusion(discoveryNode)); } } else { diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java index a67ef721879ce..8cabdff02390c 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponse.java @@ -284,8 +284,14 @@ public int getNumberOfDataNodes() { return clusterStateHealth.getNumberOfDataNodes(); } + public boolean hasDiscoveredClusterManager() { + return clusterStateHealth.hasDiscoveredClusterManager(); + } + + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #hasDiscoveredClusterManager()} */ + @Deprecated public boolean hasDiscoveredMaster() { - return clusterStateHealth.hasDiscoveredMaster(); + return hasDiscoveredClusterManager(); } public int getNumberOfPendingTasks() { @@ -385,8 +391,8 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws builder.field(TIMED_OUT, isTimedOut()); builder.field(NUMBER_OF_NODES, getNumberOfNodes()); builder.field(NUMBER_OF_DATA_NODES, getNumberOfDataNodes()); - builder.field(DISCOVERED_MASTER, hasDiscoveredMaster()); // the field will be removed in a future major version - builder.field(DISCOVERED_CLUSTER_MANAGER, hasDiscoveredMaster()); + builder.field(DISCOVERED_MASTER, hasDiscoveredClusterManager()); // the field will be removed in a future major version + builder.field(DISCOVERED_CLUSTER_MANAGER, hasDiscoveredClusterManager()); builder.field(ACTIVE_PRIMARY_SHARDS, getActivePrimaryShards()); builder.field(ACTIVE_SHARDS, getActiveShards()); builder.field(RELOCATING_SHARDS, getRelocatingShards()); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java index 3e3d373ff3b31..a15fc15ef6a2b 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/health/TransportClusterHealthAction.java @@ -221,7 +221,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { logger.trace( "stopped being cluster-manager while waiting for events with priority [{}]. retrying.", request.waitForEvents() diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java index 25513e6c9d7da..f3c5d51e1907a 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/repositories/cleanup/TransportCleanupRepositoryAction.java @@ -126,14 +126,14 @@ public TransportCleanupRepositoryAction( // We add a state applier that will remove any dangling repository cleanup actions on cluster-manager failover. // This is safe to do since cleanups will increment the repository state id before executing any operations to prevent concurrent // operations from corrupting the repository. This is the same safety mechanism used by snapshot deletes. - if (DiscoveryNode.isMasterNode(clusterService.getSettings())) { + if (DiscoveryNode.isClusterManagerNode(clusterService.getSettings())) { addClusterStateApplier(clusterService); } } private static void addClusterStateApplier(ClusterService clusterService) { clusterService.addStateApplier(event -> { - if (event.localNodeMaster() && event.previousState().nodes().isLocalNodeElectedMaster() == false) { + if (event.localNodeClusterManager() && event.previousState().nodes().isLocalNodeElectedClusterManager() == false) { final RepositoryCleanupInProgress repositoryCleanupInProgress = event.state() .custom(RepositoryCleanupInProgress.TYPE, RepositoryCleanupInProgress.EMPTY); if (repositoryCleanupInProgress.hasCleanupInProgress() == false) { diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java index 0799a8bd22b45..47024e98f82b1 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/settings/TransportClusterUpdateSettingsAction.java @@ -163,7 +163,7 @@ private void reroute(final boolean updateSettingsAcked) { // We're about to send a second update task, so we need to check if we're still the elected cluster-manager // For example the minimum_master_node could have been breached and we're no longer elected cluster-manager, // so we should *not* execute the reroute. - if (!clusterService.state().nodes().isLocalNodeElectedMaster()) { + if (!clusterService.state().nodes().isLocalNodeElectedClusterManager()) { logger.debug("Skipping reroute after cluster update settings, because node is no longer cluster-manager"); listener.onResponse( new ClusterUpdateSettingsResponse( @@ -201,7 +201,7 @@ protected ClusterUpdateSettingsResponse newResponse(boolean acknowledged) { } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { logger.debug( "failed to preform reroute after cluster settings were updated - current node is no longer a cluster-manager" ); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java index ec2697fbd7339..89cd112d30c79 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/state/ClusterStateResponse.java @@ -129,7 +129,7 @@ private static String getClusterManagerNodeId(ClusterState clusterState) { } DiscoveryNodes nodes = clusterState.getNodes(); if (nodes != null) { - return nodes.getMasterNodeId(); + return nodes.getClusterManagerNodeId(); } else { return null; } diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/state/TransportClusterStateAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/state/TransportClusterStateAction.java index b2e09629fc501..a30b6fd580f1a 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/state/TransportClusterStateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/state/TransportClusterStateAction.java @@ -127,7 +127,7 @@ protected void masterOperation( final Predicate acceptableClusterStateOrNotMasterPredicate = request.local() ? acceptableClusterStatePredicate - : acceptableClusterStatePredicate.or(clusterState -> clusterState.nodes().isLocalNodeElectedMaster() == false); + : acceptableClusterStatePredicate.or(clusterState -> clusterState.nodes().isLocalNodeElectedClusterManager() == false); if (acceptableClusterStatePredicate.test(state)) { ActionListener.completeWith(listener, () -> buildResponse(request, state)); diff --git a/server/src/main/java/org/opensearch/action/admin/cluster/stats/TransportClusterStatsAction.java b/server/src/main/java/org/opensearch/action/admin/cluster/stats/TransportClusterStatsAction.java index 984735a648dc7..a13932e137ab0 100644 --- a/server/src/main/java/org/opensearch/action/admin/cluster/stats/TransportClusterStatsAction.java +++ b/server/src/main/java/org/opensearch/action/admin/cluster/stats/TransportClusterStatsAction.java @@ -197,7 +197,7 @@ protected ClusterStatsNodeResponse nodeOperation(ClusterStatsNodeRequest nodeReq } ClusterHealthStatus clusterStatus = null; - if (clusterService.state().nodes().isLocalNodeElectedMaster()) { + if (clusterService.state().nodes().isLocalNodeElectedClusterManager()) { clusterStatus = new ClusterStateHealth(clusterService.state()).getStatus(); } diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java index a75b1877a6b11..80f008072b024 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/delete/TransportDeleteIndexTemplateAction.java @@ -108,7 +108,7 @@ protected void masterOperation( final ActionListener listener ) { indexTemplateService.removeTemplates( - new MetadataIndexTemplateService.RemoveRequest(request.name()).masterTimeout(request.clusterManagerNodeTimeout()), + new MetadataIndexTemplateService.RemoveRequest(request.name()).clusterManagerTimeout(request.clusterManagerNodeTimeout()), new MetadataIndexTemplateService.RemoveListener() { @Override public void onResponse(MetadataIndexTemplateService.RemoveResponse response) { diff --git a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java index fbc7ea6e78af5..8e8bcbab6f2b7 100644 --- a/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java +++ b/server/src/main/java/org/opensearch/action/admin/indices/template/put/TransportPutIndexTemplateAction.java @@ -125,7 +125,7 @@ protected void masterOperation( .mappings(request.mappings()) .aliases(request.aliases()) .create(request.create()) - .masterTimeout(request.clusterManagerNodeTimeout()) + .clusterManagerTimeout(request.clusterManagerNodeTimeout()) .version(request.version()), new MetadataIndexTemplateService.PutListener() { diff --git a/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java b/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java index f1c3e56b02eca..56fb688290002 100644 --- a/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java +++ b/server/src/main/java/org/opensearch/action/bulk/TransportShardBulkAction.java @@ -169,7 +169,7 @@ protected void dispatchedShardOperationOnPrimary( performOnPrimary(request, primary, updateHelper, threadPool::absoluteTimeInMillis, (update, shardId, mappingListener) -> { assert update != null; assert shardId != null; - mappingUpdatedAction.updateMappingOnMaster(shardId.getIndex(), update, mappingListener); + mappingUpdatedAction.updateMappingOnClusterManager(shardId.getIndex(), update, mappingListener); }, mappingUpdateListener -> observer.waitForNextChange(new ClusterStateObserver.Listener() { @Override public void onNewClusterState(ClusterState state) { @@ -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 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 05b2f5eb168d8..a30189a0899a4 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 @@ -165,7 +165,7 @@ class AsyncSingleAction { protected void doStart(ClusterState clusterState) { try { final DiscoveryNodes nodes = clusterState.nodes(); - if (nodes.isLocalNodeElectedMaster() || localExecute(request)) { + if (nodes.isLocalNodeElectedClusterManager() || localExecute(request)) { // check for block, if blocked, retry, else, execute locally final ClusterBlockException blockException = checkBlock(request, clusterState); if (blockException != null) { @@ -204,11 +204,11 @@ protected void doStart(ClusterState clusterState) { .execute(ActionRunnable.wrap(delegate, l -> masterOperation(task, request, clusterState, l))); } } else { - if (nodes.getMasterNode() == null) { + if (nodes.getClusterManagerNode() == null) { logger.debug("no known cluster-manager node, scheduling a retry"); retryOnMasterChange(clusterState, null); } else { - DiscoveryNode clusterManagerNode = nodes.getMasterNode(); + DiscoveryNode clusterManagerNode = nodes.getClusterManagerNode(); final String actionName = getClusterManagerActionName(clusterManagerNode); transportService.sendRequest( clusterManagerNode, @@ -225,7 +225,7 @@ public void handleException(final TransportException exp) { "connection exception while trying to forward request with action name [{}] to " + "master node [{}], scheduling a retry. Error: [{}]", actionName, - nodes.getMasterNode(), + nodes.getClusterManagerNode(), exp.getDetailedMessage() ); retryOnMasterChange(clusterState, cause); diff --git a/server/src/main/java/org/opensearch/cluster/ClusterChangedEvent.java b/server/src/main/java/org/opensearch/cluster/ClusterChangedEvent.java index dd4f6c59fabaa..7e5de435267b4 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterChangedEvent.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterChangedEvent.java @@ -213,8 +213,18 @@ public boolean blocksChanged() { /** * Returns true iff the local node is the mater node of the cluster. */ + public boolean localNodeClusterManager() { + return state.nodes().isLocalNodeElectedClusterManager(); + } + + /** + * Returns true iff the local node is the mater node of the cluster. + * + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #localNodeClusterManager()} + */ + @Deprecated public boolean localNodeMaster() { - return state.nodes().isLocalNodeElectedMaster(); + return localNodeClusterManager(); } /** diff --git a/server/src/main/java/org/opensearch/cluster/ClusterManagerNodeChangePredicate.java b/server/src/main/java/org/opensearch/cluster/ClusterManagerNodeChangePredicate.java index ecb99e06f3ef0..b5c65dacb9542 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterManagerNodeChangePredicate.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterManagerNodeChangePredicate.java @@ -53,10 +53,10 @@ private ClusterManagerNodeChangePredicate() { */ public static Predicate build(ClusterState currentState) { final long currentVersion = currentState.version(); - final DiscoveryNode clusterManagerNode = currentState.nodes().getMasterNode(); + final DiscoveryNode clusterManagerNode = currentState.nodes().getClusterManagerNode(); final String currentMasterId = clusterManagerNode == null ? null : clusterManagerNode.getEphemeralId(); return newState -> { - final DiscoveryNode newClusterManager = newState.nodes().getMasterNode(); + final DiscoveryNode newClusterManager = newState.nodes().getClusterManagerNode(); final boolean accept; if (newClusterManager == null) { accept = false; diff --git a/server/src/main/java/org/opensearch/cluster/ClusterState.java b/server/src/main/java/org/opensearch/cluster/ClusterState.java index 5431bbdbeaf38..491166639b086 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterState.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterState.java @@ -404,8 +404,8 @@ public String toString() { * In essence that means that all the changes from the other cluster state are also reflected by the current one */ public boolean supersedes(ClusterState other) { - return this.nodes().getMasterNodeId() != null - && this.nodes().getMasterNodeId().equals(other.nodes().getMasterNodeId()) + return this.nodes().getClusterManagerNodeId() != null + && this.nodes().getClusterManagerNodeId().equals(other.nodes().getClusterManagerNodeId()) && this.version() > other.version(); } @@ -485,12 +485,12 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws } if (metrics.contains(Metric.MASTER_NODE)) { - builder.field("master_node", nodes().getMasterNodeId()); + builder.field("master_node", nodes().getClusterManagerNodeId()); } // Value of the field is identical with the above, and aims to replace the above field. if (metrics.contains(Metric.CLUSTER_MANAGER_NODE)) { - builder.field("cluster_manager_node", nodes().getMasterNodeId()); + builder.field("cluster_manager_node", nodes().getClusterManagerNodeId()); } if (metrics.contains(Metric.BLOCKS)) { diff --git a/server/src/main/java/org/opensearch/cluster/ClusterStateObserver.java b/server/src/main/java/org/opensearch/cluster/ClusterStateObserver.java index 7ab5785bac350..7945afd120350 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterStateObserver.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterStateObserver.java @@ -311,7 +311,7 @@ private static class StoredState { private final long version; StoredState(ClusterState clusterState) { - this.clusterManagerNodeId = clusterState.nodes().getMasterNodeId(); + this.clusterManagerNodeId = clusterState.nodes().getClusterManagerNodeId(); this.version = clusterState.version(); } @@ -320,7 +320,7 @@ private static class StoredState { * */ public boolean isOlderOrDifferentClusterManager(ClusterState clusterState) { return version < clusterState.version() - || Objects.equals(clusterManagerNodeId, clusterState.nodes().getMasterNodeId()) == false; + || Objects.equals(clusterManagerNodeId, clusterState.nodes().getClusterManagerNodeId()) == false; } } diff --git a/server/src/main/java/org/opensearch/cluster/ClusterStateTaskExecutor.java b/server/src/main/java/org/opensearch/cluster/ClusterStateTaskExecutor.java index 00e58d88d8798..976019ae77d6c 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterStateTaskExecutor.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterStateTaskExecutor.java @@ -52,10 +52,20 @@ public interface ClusterStateTaskExecutor { /** * indicates whether this executor should only run if the current node is cluster-manager */ - default boolean runOnlyOnMaster() { + default boolean runOnlyOnClusterManager() { return true; } + /** + * indicates whether this executor should only run if the current node is cluster-manager + * + * @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #runOnlyOnClusterManager()} + */ + @Deprecated + default boolean runOnlyOnMaster() { + return runOnlyOnClusterManager(); + } + /** * Callback invoked after new cluster state is published. Note that * this method is not invoked if the cluster state was not updated. diff --git a/server/src/main/java/org/opensearch/cluster/ClusterStateTaskListener.java b/server/src/main/java/org/opensearch/cluster/ClusterStateTaskListener.java index 74cc118892579..37108d356d86a 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterStateTaskListener.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterStateTaskListener.java @@ -51,10 +51,21 @@ public interface ClusterStateTaskListener { * called when the task was rejected because the local node is no longer cluster-manager. * Used only for tasks submitted to {@link MasterService}. */ - default void onNoLongerMaster(String source) { + default void onNoLongerClusterManager(String source) { onFailure(source, new NotClusterManagerException("no longer cluster-manager. source: [" + source + "]")); } + /** + * called when the task was rejected because the local node is no longer cluster-manager. + * Used only for tasks submitted to {@link MasterService}. + * + * @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #onNoLongerClusterManager(String)} + */ + @Deprecated + default void onNoLongerMaster(String source) { + onNoLongerClusterManager(source); + } + /** * Called when the result of the {@link ClusterStateTaskExecutor#execute(ClusterState, List)} have been processed * properly by all listeners. diff --git a/server/src/main/java/org/opensearch/cluster/ClusterStateUpdateTask.java b/server/src/main/java/org/opensearch/cluster/ClusterStateUpdateTask.java index f9de49a1f7e58..9225914a931b2 100644 --- a/server/src/main/java/org/opensearch/cluster/ClusterStateUpdateTask.java +++ b/server/src/main/java/org/opensearch/cluster/ClusterStateUpdateTask.java @@ -107,7 +107,7 @@ public Priority priority() { * For local requests, use {@link LocalClusterUpdateTask} instead. */ @Override - public final boolean runOnlyOnMaster() { + public final boolean runOnlyOnClusterManager() { return true; } } diff --git a/server/src/main/java/org/opensearch/cluster/InternalClusterInfoService.java b/server/src/main/java/org/opensearch/cluster/InternalClusterInfoService.java index 97b6f81f35449..5d0ba2c67e961 100644 --- a/server/src/main/java/org/opensearch/cluster/InternalClusterInfoService.java +++ b/server/src/main/java/org/opensearch/cluster/InternalClusterInfoService.java @@ -151,14 +151,14 @@ void setUpdateFrequency(TimeValue updateFrequency) { @Override public void clusterChanged(ClusterChangedEvent event) { - if (event.localNodeMaster() && refreshAndRescheduleRunnable.get() == null) { + if (event.localNodeClusterManager() && refreshAndRescheduleRunnable.get() == null) { logger.trace("elected as cluster-manager, scheduling cluster info update tasks"); executeRefresh(event.state(), "became cluster-manager"); final RefreshAndRescheduleRunnable newRunnable = new RefreshAndRescheduleRunnable(); refreshAndRescheduleRunnable.set(newRunnable); threadPool.scheduleUnlessShuttingDown(updateFrequency, REFRESH_EXECUTOR, newRunnable); - } else if (event.localNodeMaster() == false) { + } else if (event.localNodeClusterManager() == false) { refreshAndRescheduleRunnable.set(null); return; } diff --git a/server/src/main/java/org/opensearch/cluster/LocalClusterUpdateTask.java b/server/src/main/java/org/opensearch/cluster/LocalClusterUpdateTask.java index dfa02b60ee9dc..d730be1f2afb6 100644 --- a/server/src/main/java/org/opensearch/cluster/LocalClusterUpdateTask.java +++ b/server/src/main/java/org/opensearch/cluster/LocalClusterUpdateTask.java @@ -91,7 +91,7 @@ public Priority priority() { } @Override - public final boolean runOnlyOnMaster() { + public final boolean runOnlyOnClusterManager() { return false; } } diff --git a/server/src/main/java/org/opensearch/cluster/LocalNodeClusterManagerListener.java b/server/src/main/java/org/opensearch/cluster/LocalNodeClusterManagerListener.java index 42a6438ff125e..c86aa00a6f2a2 100644 --- a/server/src/main/java/org/opensearch/cluster/LocalNodeClusterManagerListener.java +++ b/server/src/main/java/org/opensearch/cluster/LocalNodeClusterManagerListener.java @@ -51,8 +51,8 @@ public interface LocalNodeClusterManagerListener extends ClusterStateListener { @Override default void clusterChanged(ClusterChangedEvent event) { - final boolean wasClusterManager = event.previousState().nodes().isLocalNodeElectedMaster(); - final boolean isClusterManager = event.localNodeMaster(); + final boolean wasClusterManager = event.previousState().nodes().isLocalNodeElectedClusterManager(); + final boolean isClusterManager = event.localNodeClusterManager(); if (wasClusterManager == false && isClusterManager) { onMaster(); } else if (wasClusterManager && isClusterManager == false) { diff --git a/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java b/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java index 2c4eff5f6d00a..c1c49e1018197 100644 --- a/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java +++ b/server/src/main/java/org/opensearch/cluster/action/index/MappingUpdatedAction.java @@ -111,7 +111,7 @@ public void setClient(Client client) { * {@code timeout} is the cluster-manager node timeout ({@link ClusterManagerNodeRequest#clusterManagerNodeTimeout()}), * potentially waiting for a cluster-manager node to be available. */ - public void updateMappingOnMaster(Index index, Mapping mappingUpdate, ActionListener listener) { + public void updateMappingOnClusterManager(Index index, Mapping mappingUpdate, ActionListener listener) { final RunOnce release = new RunOnce(() -> semaphore.release()); try { @@ -132,6 +132,19 @@ public void updateMappingOnMaster(Index index, Mapping mappingUpdate, ActionList } } + /** + * Update mappings on the cluster-manager node, waiting for the change to be committed, + * but not for the mapping update to be applied on all nodes. The timeout specified by + * {@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.2, because supporting inclusive language, replaced by {@link #updateMappingOnClusterManager(Index, Mapping, ActionListener)} + */ + @Deprecated + public void updateMappingOnMaster(Index index, Mapping mappingUpdate, ActionListener listener) { + updateMappingOnClusterManager(index, mappingUpdate, listener); + } + // used by tests int blockedThreads() { return semaphore.getQueueLength(); diff --git a/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java b/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java index 81a365df9866d..002c5fd3b89db 100644 --- a/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java +++ b/server/src/main/java/org/opensearch/cluster/action/shard/ShardStateAction.java @@ -39,12 +39,12 @@ import org.opensearch.ExceptionsHelper; import org.opensearch.action.ActionListener; import org.opensearch.cluster.ClusterChangedEvent; +import org.opensearch.cluster.ClusterManagerNodeChangePredicate; import org.opensearch.cluster.ClusterState; import org.opensearch.cluster.ClusterStateObserver; 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; @@ -182,7 +182,7 @@ private void sendShardAction( final ActionListener listener ) { ClusterStateObserver observer = new ClusterStateObserver(currentState, clusterService, null, logger, threadPool.getThreadContext()); - DiscoveryNode clusterManagerNode = currentState.nodes().getMasterNode(); + DiscoveryNode clusterManagerNode = currentState.nodes().getClusterManagerNode(); Predicate changePredicate = ClusterManagerNodeChangePredicate.build(currentState); if (clusterManagerNode == null) { logger.warn("no cluster-manager known for action [{}] for shard entry [{}]", actionName, request); @@ -385,7 +385,7 @@ public void onFailure(String source, Exception e) { } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { logger.error("{} no longer cluster-manager while failing shard [{}]", request.shardId, request); try { channel.sendResponse(new NotClusterManagerException(source)); diff --git a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java index cdf673c00fe56..addd2b3e46597 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/ClusterBootstrapService.java @@ -134,7 +134,7 @@ public ClusterBootstrapService( + "]" ); } - if (DiscoveryNode.isMasterNode(settings) == false) { + if (DiscoveryNode.isClusterManagerNode(settings) == false) { throw new IllegalArgumentException( "node with [" + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() @@ -176,7 +176,7 @@ public static boolean discoveryIsConfigured(Settings settings) { void onFoundPeersUpdated() { final Set nodes = getDiscoveredNodes(); if (bootstrappingPermitted.get() - && transportService.getLocalNode().isMasterNode() + && transportService.getLocalNode().isClusterManagerNode() && bootstrapRequirements.isEmpty() == false && isBootstrappedSupplier.getAsBoolean() == false && nodes.stream().noneMatch(Coordinator::isZen1Node)) { @@ -219,7 +219,7 @@ void scheduleUnconfiguredBootstrap() { return; } - if (transportService.getLocalNode().isMasterNode() == false) { + if (transportService.getLocalNode().isClusterManagerNode() == false) { return; } @@ -257,7 +257,7 @@ private Set getDiscoveredNodes() { } private void startBootstrap(Set discoveryNodes, List unsatisfiedRequirements) { - assert discoveryNodes.stream().allMatch(DiscoveryNode::isMasterNode) : discoveryNodes; + assert discoveryNodes.stream().allMatch(DiscoveryNode::isClusterManagerNode) : discoveryNodes; assert discoveryNodes.stream().noneMatch(Coordinator::isZen1Node) : discoveryNodes; assert unsatisfiedRequirements.size() < discoveryNodes.size() : discoveryNodes + " smaller than " + unsatisfiedRequirements; if (bootstrappingPermitted.compareAndSet(true, false)) { @@ -277,7 +277,7 @@ public static boolean isBootstrapPlaceholder(String nodeId) { } private void doBootstrap(VotingConfiguration votingConfiguration) { - assert transportService.getLocalNode().isMasterNode(); + assert transportService.getLocalNode().isClusterManagerNode(); try { votingConfigurationConsumer.accept(votingConfiguration); diff --git a/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java b/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java index d4d2115959e22..bb781012483a1 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/ClusterFormationFailureHelper.java @@ -184,9 +184,10 @@ String getDescription() { if (statusInfo.getStatus() == UNHEALTHY) { return String.format(Locale.ROOT, "this node is unhealthy: %s", statusInfo.getInfo()); } - final List clusterStateNodes = StreamSupport.stream(clusterState.nodes().getMasterNodes().values().spliterator(), false) - .map(n -> n.value.toString()) - .collect(Collectors.toList()); + final List clusterStateNodes = StreamSupport.stream( + clusterState.nodes().getClusterManagerNodes().values().spliterator(), + false + ).map(n -> n.value.toString()).collect(Collectors.toList()); final String discoveryWillContinueDescription = String.format( Locale.ROOT, @@ -206,7 +207,7 @@ String getDescription() { discoveryWillContinueDescription ); - if (clusterState.nodes().getLocalNode().isMasterNode() == false) { + if (clusterState.nodes().getLocalNode().isClusterManagerNode() == false) { return String.format(Locale.ROOT, "cluster-manager not discovered yet: %s", discoveryStateIgnoringQuorum); } diff --git a/server/src/main/java/org/opensearch/cluster/coordination/CoordinationState.java b/server/src/main/java/org/opensearch/cluster/coordination/CoordinationState.java index fcae32af9cad5..08cd7d0ab02db 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/CoordinationState.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/CoordinationState.java @@ -413,7 +413,7 @@ public PublishResponse handlePublishRequest(PublishRequest publishRequest) { } if (clusterState.term() == getLastAcceptedTerm() && clusterState.version() <= getLastAcceptedVersion()) { if (clusterState.term() == ZEN1_BWC_TERM - && clusterState.nodes().getMasterNode().equals(getLastAcceptedState().nodes().getMasterNode()) == false) { + && clusterState.nodes().getClusterManagerNode().equals(getLastAcceptedState().nodes().getClusterManagerNode()) == false) { logger.debug( "handling publish request in compatibility mode despite version mismatch (expected: >[{}], actual: [{}])", getLastAcceptedVersion(), @@ -652,7 +652,7 @@ public static class VoteCollection { private final Set joins; public boolean addVote(DiscoveryNode sourceNode) { - return sourceNode.isMasterNode() && nodes.put(sourceNode.getId(), sourceNode) == null; + return sourceNode.isClusterManagerNode() && nodes.put(sourceNode.getId(), sourceNode) == null; } public boolean addJoinVote(Join join) { diff --git a/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java b/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java index e3a72faace106..21aadb61cc8a5 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java @@ -386,7 +386,7 @@ PublishWithJoinResponse handlePublishRequest(PublishRequest publishRequest) { + getLocalNode(); synchronized (mutex) { - final DiscoveryNode sourceNode = publishRequest.getAcceptedState().nodes().getMasterNode(); + final DiscoveryNode sourceNode = publishRequest.getAcceptedState().nodes().getClusterManagerNode(); logger.trace("handlePublishRequest: handling [{}] from [{}]", publishRequest, sourceNode); if (sourceNode.equals(getLocalNode()) && mode != Mode.LEADER) { @@ -515,10 +515,11 @@ private void startElection() { private void abdicateTo(DiscoveryNode newClusterManager) { assert Thread.holdsLock(mutex); assert mode == Mode.LEADER : "expected to be leader on abdication but was " + mode; - assert newClusterManager.isMasterNode() : "should only abdicate to cluster-manager-eligible node but was " + newClusterManager; + assert newClusterManager.isClusterManagerNode() : "should only abdicate to cluster-manager-eligible node but was " + + newClusterManager; final StartJoinRequest startJoinRequest = new StartJoinRequest(newClusterManager, Math.max(getCurrentTerm(), maxTermSeen) + 1); logger.info("abdicating to {} with term {}", newClusterManager, startJoinRequest.getTerm()); - getLastAcceptedState().nodes().mastersFirstStream().forEach(node -> { + getLastAcceptedState().nodes().clusterManagersFirstStream().forEach(node -> { if (isZen1Node(node) == false) { joinHelper.sendStartJoinRequest(startJoinRequest, node); } @@ -568,7 +569,7 @@ private Join joinLeaderInTerm(StartJoinRequest startJoinRequest) { private void handleJoinRequest(JoinRequest joinRequest, JoinHelper.JoinCallback joinCallback) { assert Thread.holdsLock(mutex) == false; - assert getLocalNode().isMasterNode() : getLocalNode() + " received a join but is not cluster-manager-eligible"; + assert getLocalNode().isClusterManagerNode() : getLocalNode() + " received a join but is not cluster-manager-eligible"; logger.trace("handleJoinRequest: as {}, handling {}", mode, joinRequest); if (singleNodeDiscovery && joinRequest.getSourceNode().equals(getLocalNode()) == false) { @@ -587,7 +588,7 @@ private void handleJoinRequest(JoinRequest joinRequest, JoinHelper.JoinCallback transportService.connectToNode(joinRequest.getSourceNode(), ActionListener.wrap(ignore -> { final ClusterState stateForJoinValidation = getStateForClusterManagerService(); - if (stateForJoinValidation.nodes().isLocalNodeElectedMaster()) { + if (stateForJoinValidation.nodes().isLocalNodeElectedClusterManager()) { onJoinValidators.forEach(a -> a.accept(joinRequest.getSourceNode(), stateForJoinValidation)); if (stateForJoinValidation.getBlocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK) == false) { // we do this in a couple of places including the cluster update thread. This one here is really just best effort @@ -676,7 +677,7 @@ void becomeCandidate(String method) { cleanClusterManagerService(); } - if (applierState.nodes().getMasterNodeId() != null) { + if (applierState.nodes().getClusterManagerNodeId() != null) { applierState = clusterStateWithNoClusterManagerBlock(applierState); clusterApplier.onNewClusterState("becoming candidate: " + method, () -> applierState, (source, e) -> {}); } @@ -688,7 +689,7 @@ void becomeCandidate(String method) { void becomeLeader(String method) { assert Thread.holdsLock(mutex) : "Coordinator mutex not held"; assert mode == Mode.CANDIDATE : "expected candidate but was " + mode; - assert getLocalNode().isMasterNode() : getLocalNode() + " became a leader but is not cluster-manager-eligible"; + assert getLocalNode().isClusterManagerNode() : getLocalNode() + " became a leader but is not cluster-manager-eligible"; logger.debug( "{}: coordinator becoming LEADER in term {} (was {}, lastKnownLeader was [{}])", @@ -714,7 +715,7 @@ void becomeLeader(String method) { void becomeFollower(String method, DiscoveryNode leaderNode) { assert Thread.holdsLock(mutex) : "Coordinator mutex not held"; - assert leaderNode.isMasterNode() : leaderNode + " became a leader but is not cluster-manager-eligible"; + assert leaderNode.isClusterManagerNode() : leaderNode + " became a leader but is not cluster-manager-eligible"; assert mode != Mode.LEADER : "do not switch to follower from leader (should be candidate first)"; if (mode == Mode.FOLLOWER && Optional.of(leaderNode).equals(lastKnownLeader)) { @@ -765,7 +766,7 @@ public void onFailure(String source, Exception e) { @Override public ClusterTasksResult execute(ClusterState currentState) { - if (currentState.nodes().isLocalNodeElectedMaster() == false) { + if (currentState.nodes().isLocalNodeElectedClusterManager() == false) { allocationService.cleanCaches(); } return unchanged(); @@ -884,7 +885,8 @@ public void invariant() { assert peerFinder.getCurrentTerm() == getCurrentTerm(); assert followersChecker.getFastResponseState().term == getCurrentTerm() : followersChecker.getFastResponseState(); assert followersChecker.getFastResponseState().mode == getMode() : followersChecker.getFastResponseState(); - assert (applierState.nodes().getMasterNodeId() == null) == applierState.blocks().hasGlobalBlockWithId(NO_MASTER_BLOCK_ID); + assert (applierState.nodes().getClusterManagerNodeId() == null) == applierState.blocks() + .hasGlobalBlockWithId(NO_MASTER_BLOCK_ID); assert preVoteCollector.getPreVoteResponse().equals(getPreVoteResponse()) : preVoteCollector + " vs " + getPreVoteResponse(); assert lagDetector.getTrackedNodes().contains(getLocalNode()) == false : lagDetector.getTrackedNodes(); @@ -901,11 +903,11 @@ public void invariant() { assert peerFinderLeader.equals(lastKnownLeader) : peerFinderLeader; assert electionScheduler == null : electionScheduler; assert prevotingRound == null : prevotingRound; - assert becomingClusterManager || getStateForClusterManagerService().nodes().getMasterNodeId() != null + assert becomingClusterManager || getStateForClusterManagerService().nodes().getClusterManagerNodeId() != null : getStateForClusterManagerService(); assert leaderChecker.leader() == null : leaderChecker.leader(); - assert getLocalNode().equals(applierState.nodes().getMasterNode()) - || (applierState.nodes().getMasterNodeId() == null && applierState.term() < getCurrentTerm()); + assert getLocalNode().equals(applierState.nodes().getClusterManagerNode()) + || (applierState.nodes().getClusterManagerNodeId() == null && applierState.term() < getCurrentTerm()); assert preVoteCollector.getLeader() == getLocalNode() : preVoteCollector; assert clusterFormationFailureHelper.isRunning() == false; @@ -946,12 +948,12 @@ assert getLocalNode().equals(applierState.nodes().getMasterNode()) assert peerFinderLeader.equals(lastKnownLeader) : peerFinderLeader; assert electionScheduler == null : electionScheduler; assert prevotingRound == null : prevotingRound; - assert getStateForClusterManagerService().nodes().getMasterNodeId() == null : getStateForClusterManagerService(); + assert getStateForClusterManagerService().nodes().getClusterManagerNodeId() == null : getStateForClusterManagerService(); assert leaderChecker.currentNodeIsClusterManager() == false; assert lastKnownLeader.equals(Optional.of(leaderChecker.leader())); assert followersChecker.getKnownFollowers().isEmpty(); - assert lastKnownLeader.get().equals(applierState.nodes().getMasterNode()) - || (applierState.nodes().getMasterNodeId() == null + assert lastKnownLeader.get().equals(applierState.nodes().getClusterManagerNode()) + || (applierState.nodes().getClusterManagerNodeId() == null && (applierState.term() < getCurrentTerm() || applierState.version() < getLastAcceptedState().version())); assert currentPublication.map(Publication::isCommitted).orElse(true); assert preVoteCollector.getLeader().equals(lastKnownLeader.get()) : preVoteCollector; @@ -961,11 +963,11 @@ assert getLocalNode().equals(applierState.nodes().getMasterNode()) assert joinAccumulator instanceof JoinHelper.CandidateJoinAccumulator; assert peerFinderLeader.isPresent() == false : peerFinderLeader; assert prevotingRound == null || electionScheduler != null; - assert getStateForClusterManagerService().nodes().getMasterNodeId() == null : getStateForClusterManagerService(); + assert getStateForClusterManagerService().nodes().getClusterManagerNodeId() == null : getStateForClusterManagerService(); assert leaderChecker.currentNodeIsClusterManager() == false; assert leaderChecker.leader() == null : leaderChecker.leader(); assert followersChecker.getKnownFollowers().isEmpty(); - assert applierState.nodes().getMasterNodeId() == null; + assert applierState.nodes().getClusterManagerNodeId() == null; assert currentPublication.map(Publication::isCommitted).orElse(true); assert preVoteCollector.getLeader() == null : preVoteCollector; assert clusterFormationFailureHelper.isRunning(); @@ -993,7 +995,7 @@ public boolean setInitialConfiguration(final VotingConfiguration votingConfigura return false; } - if (getLocalNode().isMasterNode() == false) { + if (getLocalNode().isClusterManagerNode() == false) { logger.debug("skip setting initial configuration as local node is not a cluster-manager-eligible node"); throw new CoordinationStateRejectedException( "this node is not cluster-manager-eligible, but cluster bootstrapping can only happen on a cluster-manager-eligible node" @@ -1060,14 +1062,14 @@ ClusterState improveConfiguration(ClusterState clusterState) { // the logging much harder to follow. final Stream clusterManagerIneligibleNodeIdsInVotingConfig = StreamSupport.stream(clusterState.nodes().spliterator(), false) .filter( - n -> n.isMasterNode() == false + n -> n.isClusterManagerNode() == false && (clusterState.getLastAcceptedConfiguration().getNodeIds().contains(n.getId()) || clusterState.getLastCommittedConfiguration().getNodeIds().contains(n.getId())) ) .map(DiscoveryNode::getId); final Set liveNodes = StreamSupport.stream(clusterState.nodes().spliterator(), false) - .filter(DiscoveryNode::isMasterNode) + .filter(DiscoveryNode::isClusterManagerNode) .filter(coordinationState.get()::containsJoinVoteFor) .filter(discoveryNode -> isZen1Node(discoveryNode) == false) .collect(Collectors.toSet()); @@ -1108,7 +1110,8 @@ static boolean validVotingConfigExclusionState(ClusterState clusterState) { .map(VotingConfigExclusion::getNodeId) .collect(Collectors.toSet()); for (DiscoveryNode node : clusterState.getNodes()) { - if (node.isMasterNode() && (nodeIdsWithAbsentName.contains(node.getId()) || nodeNamesWithAbsentId.contains(node.getName()))) { + if (node.isClusterManagerNode() + && (nodeIdsWithAbsentName.contains(node.getId()) || nodeNamesWithAbsentId.contains(node.getName()))) { return false; } } @@ -1146,7 +1149,7 @@ public void onFailure(String source, Exception e) { // exposed for tests boolean missingJoinVoteFrom(DiscoveryNode node) { - return node.isMasterNode() && coordinationState.get().containsJoinVoteFor(node) == false; + return node.isClusterManagerNode() && coordinationState.get().containsJoinVoteFor(node) == false; } private void handleJoin(Join join) { @@ -1216,7 +1219,7 @@ ClusterState getStateForClusterManagerService() { } private ClusterState clusterStateWithNoClusterManagerBlock(ClusterState clusterState) { - if (clusterState.nodes().getMasterNodeId() != null) { + if (clusterState.nodes().getClusterManagerNodeId() != null) { // remove block if it already exists before adding new one assert clusterState.blocks().hasGlobalBlockWithId(NO_MASTER_BLOCK_ID) == false : "NO_MASTER_BLOCK should only be added by Coordinator"; @@ -1224,7 +1227,7 @@ private ClusterState clusterStateWithNoClusterManagerBlock(ClusterState clusterS .blocks(clusterState.blocks()) .addGlobalBlock(noClusterManagerBlockService.getNoMasterBlock()) .build(); - final DiscoveryNodes discoveryNodes = new DiscoveryNodes.Builder(clusterState.nodes()).masterNodeId(null).build(); + final DiscoveryNodes discoveryNodes = new DiscoveryNodes.Builder(clusterState.nodes()).clusterManagerNodeId(null).build(); return ClusterState.builder(clusterState).blocks(clusterBlocks).nodes(discoveryNodes).build(); } else { return clusterState; @@ -1425,7 +1428,7 @@ protected void onFoundPeersUpdated() { private void startElectionScheduler() { assert electionScheduler == null : electionScheduler; - if (getLocalNode().isMasterNode() == false) { + if (getLocalNode().isClusterManagerNode() == false) { return; } @@ -1640,7 +1643,7 @@ public void onSuccess(String source) { final ClusterState state = getLastAcceptedState(); // committed state if (localNodeMayWinElection(state) == false) { final List clusterManagerCandidates = completedNodes().stream() - .filter(DiscoveryNode::isMasterNode) + .filter(DiscoveryNode::isClusterManagerNode) .filter(node -> nodeMayWinElection(state, node)) .filter(node -> { // check if cluster_manager candidate would be able to get an election quorum if we were diff --git a/server/src/main/java/org/opensearch/cluster/coordination/FollowersChecker.java b/server/src/main/java/org/opensearch/cluster/coordination/FollowersChecker.java index c9a9ba9af09cd..e69a78eae041d 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/FollowersChecker.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/FollowersChecker.java @@ -168,7 +168,7 @@ public void setCurrentNodes(DiscoveryNodes discoveryNodes) { followerCheckers.keySet().removeIf(isUnknownNode); faultyNodes.removeIf(isUnknownNode); - discoveryNodes.mastersFirstStream().forEach(discoveryNode -> { + discoveryNodes.clusterManagersFirstStream().forEach(discoveryNode -> { if (discoveryNode.equals(discoveryNodes.getLocalNode()) == false && followerCheckers.containsKey(discoveryNode) == false && faultyNodes.contains(discoveryNode) == false) { diff --git a/server/src/main/java/org/opensearch/cluster/coordination/JoinHelper.java b/server/src/main/java/org/opensearch/cluster/coordination/JoinHelper.java index 3accc4f1d5baf..2eae6411eff69 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/JoinHelper.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/JoinHelper.java @@ -156,16 +156,20 @@ public ClusterTasksResult execute(ClusterState currentSta + term + "), there is a newer cluster-manager" ); - } else if (currentState.nodes().getMasterNodeId() == null && joiningTasks.stream().anyMatch(Task::isBecomeMasterTask)) { - assert currentState.term() < term : "there should be at most one become cluster-manager task per election (= by term)"; - final CoordinationMetadata coordinationMetadata = CoordinationMetadata.builder(currentState.coordinationMetadata()) - .term(term) - .build(); - final Metadata metadata = Metadata.builder(currentState.metadata()).coordinationMetadata(coordinationMetadata).build(); - currentState = ClusterState.builder(currentState).metadata(metadata).build(); - } else if (currentState.nodes().isLocalNodeElectedMaster()) { - assert currentState.term() == term : "term should be stable for the same cluster-manager"; - } + } else if (currentState.nodes().getClusterManagerNodeId() == null + && joiningTasks.stream().anyMatch(Task::isBecomeClusterManagerTask)) { + assert currentState.term() < term + : "there should be at most one become cluster-manager task per election (= by term)"; + final CoordinationMetadata coordinationMetadata = CoordinationMetadata.builder(currentState.coordinationMetadata()) + .term(term) + .build(); + final Metadata metadata = Metadata.builder(currentState.metadata()) + .coordinationMetadata(coordinationMetadata) + .build(); + currentState = ClusterState.builder(currentState).metadata(metadata).build(); + } else if (currentState.nodes().isLocalNodeElectedClusterManager()) { + assert currentState.term() == term : "term should be stable for the same cluster-manager"; + } return super.execute(currentState, joiningTasks); } @@ -312,7 +316,7 @@ void logLastFailedJoinAttempt() { } public void sendJoinRequest(DiscoveryNode destination, long term, Optional optionalJoin, Runnable onCompletion) { - assert destination.isMasterNode() : "trying to join cluster-manager-ineligible " + destination; + assert destination.isClusterManagerNode() : "trying to join cluster-manager-ineligible " + destination; final StatusInfo statusInfo = nodeHealthService.getHealth(); if (statusInfo.getStatus() == UNHEALTHY) { logger.debug("dropping join request to [{}]: [{}]", destination, statusInfo.getInfo()); @@ -363,7 +367,7 @@ public String executor() { } public void sendStartJoinRequest(final StartJoinRequest startJoinRequest, final DiscoveryNode destination) { - assert startJoinRequest.getSourceNode().isMasterNode() : "sending start-join request for cluster-manager-ineligible " + assert startJoinRequest.getSourceNode().isClusterManagerNode() : "sending start-join request for cluster-manager-ineligible " + startJoinRequest.getSourceNode(); transportService.sendRequest(destination, START_JOIN_ACTION_NAME, startJoinRequest, new TransportResponseHandler() { @Override @@ -536,7 +540,7 @@ public void close(Mode newMode) { final String stateUpdateSource = "elected-as-cluster-manager ([" + pendingAsTasks.size() + "] nodes joined)"; - pendingAsTasks.put(JoinTaskExecutor.newBecomeMasterTask(), (source, e) -> {}); + pendingAsTasks.put(JoinTaskExecutor.newBecomeClusterManagerTask(), (source, e) -> {}); pendingAsTasks.put(JoinTaskExecutor.newFinishElectionTask(), (source, e) -> {}); joinTaskExecutor = joinTaskExecutorGenerator.get(); masterService.submitStateUpdateTasks( diff --git a/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java b/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java index 629a016e0eab1..7582946bb8f3f 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java @@ -103,10 +103,16 @@ public String toString() { return node != null ? node + " " + reason : reason; } - public boolean isBecomeMasterTask() { + public boolean isBecomeClusterManagerTask() { return reason.equals(BECOME_MASTER_TASK_REASON) || reason.equals(BECOME_CLUSTER_MANAGER_TASK_REASON); } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #isBecomeClusterManagerTask()} */ + @Deprecated + public boolean isBecomeMasterTask() { + return isBecomeClusterManagerTask(); + } + public boolean isFinishElectionTask() { return reason.equals(FINISH_ELECTION_TASK_REASON); } @@ -143,7 +149,7 @@ public ClusterTasksResult execute(ClusterState currentState, List jo if (joiningNodes.size() == 1 && joiningNodes.get(0).isFinishElectionTask()) { return results.successes(joiningNodes).build(currentState); - } else if (currentNodes.getMasterNode() == null && joiningNodes.stream().anyMatch(Task::isBecomeMasterTask)) { + } else if (currentNodes.getClusterManagerNode() == null && joiningNodes.stream().anyMatch(Task::isBecomeClusterManagerTask)) { assert joiningNodes.stream().anyMatch(Task::isFinishElectionTask) : "becoming a cluster-manager but election is not finished " + joiningNodes; // use these joins to try and become the cluster-manager. @@ -151,10 +157,10 @@ public ClusterTasksResult execute(ClusterState currentState, List jo // during the cluster state publishing guarantees that we have enough newState = becomeClusterManagerAndTrimConflictingNodes(currentState, joiningNodes); nodesChanged = true; - } else if (currentNodes.isLocalNodeElectedMaster() == false) { + } else if (currentNodes.isLocalNodeElectedClusterManager() == false) { logger.trace( "processing node joins, but we are not the cluster-manager. current cluster-manager: {}", - currentNodes.getMasterNode() + currentNodes.getClusterManagerNode() ); throw new NotClusterManagerException("Node [" + currentNodes.getLocalNode() + "] not cluster-manager for join request"); } else { @@ -163,7 +169,7 @@ public ClusterTasksResult execute(ClusterState currentState, List jo DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(newState.nodes()); - assert nodesBuilder.isLocalNodeElectedMaster(); + assert nodesBuilder.isLocalNodeElectedClusterManager(); Version minClusterNodeVersion = newState.nodes().getMinNodeVersion(); Version maxClusterNodeVersion = newState.nodes().getMaxNodeVersion(); @@ -172,7 +178,7 @@ public ClusterTasksResult execute(ClusterState currentState, List jo // processing any joins Map joiniedNodeNameIds = new HashMap<>(); for (final Task joinTask : joiningNodes) { - if (joinTask.isBecomeMasterTask() || joinTask.isFinishElectionTask()) { + if (joinTask.isBecomeClusterManagerTask() || joinTask.isFinishElectionTask()) { // noop } else if (currentNodes.nodeExistsWithSameRoles(joinTask.node()) && !currentNodes.nodeExistsWithBWCVersion(joinTask.node())) { logger.debug("received a join request for an existing node [{}]", joinTask.node()); @@ -190,7 +196,7 @@ public ClusterTasksResult execute(ClusterState currentState, List jo nodesChanged = true; minClusterNodeVersion = Version.min(minClusterNodeVersion, node.getVersion()); maxClusterNodeVersion = Version.max(maxClusterNodeVersion, node.getVersion()); - if (node.isMasterNode()) { + if (node.isClusterManagerNode()) { joiniedNodeNameIds.put(node.getName(), node.getId()); } } catch (IllegalArgumentException | IllegalStateException e) { @@ -245,13 +251,13 @@ public ClusterTasksResult execute(ClusterState currentState, List jo } protected ClusterState.Builder becomeClusterManagerAndTrimConflictingNodes(ClusterState currentState, List joiningNodes) { - assert currentState.nodes().getMasterNodeId() == null : currentState; + assert currentState.nodes().getClusterManagerNodeId() == null : currentState; DiscoveryNodes currentNodes = currentState.nodes(); DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(currentNodes); - nodesBuilder.masterNodeId(currentState.nodes().getLocalNodeId()); + nodesBuilder.clusterManagerNodeId(currentState.nodes().getLocalNodeId()); for (final Task joinTask : joiningNodes) { - if (joinTask.isBecomeMasterTask()) { + if (joinTask.isBecomeClusterManagerTask()) { refreshDiscoveryNodeVersionAfterUpgrade(currentNodes, nodesBuilder); } else if (joinTask.isFinishElectionTask()) { // no-op @@ -343,7 +349,7 @@ private void refreshDiscoveryNodeVersionAfterUpgrade(DiscoveryNodes currentNodes } @Override - public boolean runOnlyOnMaster() { + public boolean runOnlyOnClusterManager() { // we validate that we are allowed to change the cluster state during cluster state processing return false; } @@ -366,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); diff --git a/server/src/main/java/org/opensearch/cluster/coordination/LeaderChecker.java b/server/src/main/java/org/opensearch/cluster/coordination/LeaderChecker.java index f1d2754fbbfa7..3d90c7366d2d6 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/LeaderChecker.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/LeaderChecker.java @@ -193,7 +193,7 @@ void setCurrentNodes(DiscoveryNodes discoveryNodes) { // For assertions boolean currentNodeIsClusterManager() { - return discoveryNodes.isLocalNodeElectedMaster(); + return discoveryNodes.isLocalNodeElectedClusterManager(); } private void handleLeaderCheck(LeaderCheckRequest request) { @@ -209,7 +209,7 @@ private void handleLeaderCheck(LeaderCheckRequest request) { + "]"; logger.debug(message); throw new NodeHealthCheckFailureException(message); - } else if (discoveryNodes.isLocalNodeElectedMaster() == false) { + } else if (discoveryNodes.isLocalNodeElectedClusterManager() == false) { logger.debug("rejecting leader check on non-cluster-manager {}", request); throw new CoordinationStateRejectedException( "rejecting leader check from [" + request.getSender() + "] sent to a node that is no longer the cluster-manager" diff --git a/server/src/main/java/org/opensearch/cluster/coordination/NodeRemovalClusterStateTaskExecutor.java b/server/src/main/java/org/opensearch/cluster/coordination/NodeRemovalClusterStateTaskExecutor.java index 3a466d0bfe6dd..2cf0fb3bffeee 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/NodeRemovalClusterStateTaskExecutor.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/NodeRemovalClusterStateTaskExecutor.java @@ -136,7 +136,7 @@ public void onFailure(final String source, final Exception e) { } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { logger.debug("no longer cluster-manager while processing node removal [{}]", source); } diff --git a/server/src/main/java/org/opensearch/cluster/coordination/PeersResponse.java b/server/src/main/java/org/opensearch/cluster/coordination/PeersResponse.java index 8e2e6fde3a485..0b0d6f8e57174 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/PeersResponse.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/PeersResponse.java @@ -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 getMasterNode() { + public Optional 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 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. diff --git a/server/src/main/java/org/opensearch/cluster/coordination/Publication.java b/server/src/main/java/org/opensearch/cluster/coordination/Publication.java index c85ea07591edc..429890e7420de 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/Publication.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/Publication.java @@ -78,7 +78,10 @@ public Publication(PublishRequest publishRequest, AckListener ackListener, LongS startTime = currentTimeSupplier.getAsLong(); applyCommitRequest = Optional.empty(); publicationTargets = new ArrayList<>(publishRequest.getAcceptedState().getNodes().getNodes().size()); - publishRequest.getAcceptedState().getNodes().mastersFirstStream().forEach(n -> publicationTargets.add(new PublicationTarget(n))); + publishRequest.getAcceptedState() + .getNodes() + .clusterManagersFirstStream() + .forEach(n -> publicationTargets.add(new PublicationTarget(n))); } public void start(Set faultyNodes) { diff --git a/server/src/main/java/org/opensearch/cluster/coordination/PublicationTransportHandler.java b/server/src/main/java/org/opensearch/cluster/coordination/PublicationTransportHandler.java index c3b3b237a1944..8ef8124799bf0 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/PublicationTransportHandler.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/PublicationTransportHandler.java @@ -232,7 +232,7 @@ private PublishWithJoinResponse handleIncomingPublishRequest(BytesTransportReque private PublishWithJoinResponse acceptState(ClusterState incomingState) { // if the state is coming from the current node, use original request instead (see currentPublishRequestToSelf for explanation) - if (transportService.getLocalNode().equals(incomingState.nodes().getMasterNode())) { + if (transportService.getLocalNode().equals(incomingState.nodes().getClusterManagerNode())) { final PublishRequest publishRequest = currentPublishRequestToSelf.get(); if (publishRequest == null || publishRequest.getAcceptedState().stateUUID().equals(incomingState.stateUUID()) == false) { throw new IllegalStateException("publication to self failed for " + publishRequest); diff --git a/server/src/main/java/org/opensearch/cluster/coordination/Reconfigurator.java b/server/src/main/java/org/opensearch/cluster/coordination/Reconfigurator.java index 2d268b5cca779..1570a84ab871f 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/Reconfigurator.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/Reconfigurator.java @@ -125,14 +125,14 @@ public VotingConfiguration reconfigure( ); final Set liveNodeIds = liveNodes.stream() - .filter(DiscoveryNode::isMasterNode) + .filter(DiscoveryNode::isClusterManagerNode) .map(DiscoveryNode::getId) .collect(Collectors.toSet()); final Set currentConfigNodeIds = currentConfig.getNodeIds(); final Set orderedCandidateNodes = new TreeSet<>(); liveNodes.stream() - .filter(DiscoveryNode::isMasterNode) + .filter(DiscoveryNode::isClusterManagerNode) .filter(n -> retiredNodeIds.contains(n.getId()) == false) .forEach( n -> orderedCandidateNodes.add( diff --git a/server/src/main/java/org/opensearch/cluster/coordination/UnsafeBootstrapClusterManagerCommand.java b/server/src/main/java/org/opensearch/cluster/coordination/UnsafeBootstrapClusterManagerCommand.java index 8506a59b22763..229c20b8dea17 100644 --- a/server/src/main/java/org/opensearch/cluster/coordination/UnsafeBootstrapClusterManagerCommand.java +++ b/server/src/main/java/org/opensearch/cluster/coordination/UnsafeBootstrapClusterManagerCommand.java @@ -98,7 +98,7 @@ public class UnsafeBootstrapClusterManagerCommand extends OpenSearchNodeCommand protected boolean validateBeforeLock(Terminal terminal, Environment env) { Settings settings = env.settings(); terminal.println(Terminal.Verbosity.VERBOSE, "Checking node.roles setting"); - Boolean clusterManager = DiscoveryNode.isMasterNode(settings); + Boolean clusterManager = DiscoveryNode.isClusterManagerNode(settings); if (clusterManager == false) { throw new OpenSearchException(NOT_CLUSTER_MANAGER_NODE_MSG); } diff --git a/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java b/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java index f1fe680f80769..673695e217a5b 100644 --- a/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java +++ b/server/src/main/java/org/opensearch/cluster/health/ClusterStateHealth.java @@ -86,7 +86,7 @@ public ClusterStateHealth(final ClusterState clusterState) { public ClusterStateHealth(final ClusterState clusterState, final String[] concreteIndices) { numberOfNodes = clusterState.nodes().getSize(); numberOfDataNodes = clusterState.nodes().getDataNodes().size(); - hasDiscoveredClusterManager = clusterState.nodes().getMasterNodeId() != null; + hasDiscoveredClusterManager = clusterState.nodes().getClusterManagerNodeId() != null; indices = new HashMap<>(); for (String index : concreteIndices) { IndexRoutingTable indexRoutingTable = clusterState.routingTable().index(index); @@ -238,10 +238,16 @@ public double getActiveShardsPercent() { return activeShardsPercent; } - public boolean hasDiscoveredMaster() { + public boolean hasDiscoveredClusterManager() { return hasDiscoveredClusterManager; } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #hasDiscoveredClusterManager()} */ + @Deprecated + public boolean hasDiscoveredMaster() { + return hasDiscoveredClusterManager(); + } + @Override public Iterator iterator() { return indices.values().iterator(); diff --git a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java index 6dded44fe70bb..1a0f4f0f83e00 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/MetadataIndexTemplateService.java @@ -132,7 +132,7 @@ public void removeTemplates(final RemoveRequest request, final RemoveListener li @Override public TimeValue timeout() { - return request.masterTimeout; + return request.clusterManagerTimeout; } @Override @@ -860,7 +860,7 @@ public void putTemplate(final PutRequest request, final PutListener listener) { @Override public TimeValue timeout() { - return request.masterTimeout; + return request.clusterManagerTimeout; } @Override @@ -1526,6 +1526,10 @@ public static class PutRequest { String mappings = null; List aliases = new ArrayList<>(); + TimeValue clusterManagerTimeout = ClusterManagerNodeRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT; + + /** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #clusterManagerTimeout} */ + @Deprecated TimeValue masterTimeout = ClusterManagerNodeRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT; public PutRequest(String cause, String name) { @@ -1563,11 +1567,17 @@ public PutRequest aliases(Set aliases) { return this; } - public PutRequest masterTimeout(TimeValue masterTimeout) { - this.masterTimeout = masterTimeout; + public PutRequest clusterManagerTimeout(TimeValue clusterManagerTimeout) { + this.clusterManagerTimeout = clusterManagerTimeout; return this; } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagerTimeout(TimeValue)} */ + @Deprecated + public PutRequest masterTimeout(TimeValue masterTimeout) { + return clusterManagerTimeout(masterTimeout); + } + public PutRequest version(Integer version) { this.version = version; return this; @@ -1598,16 +1608,26 @@ public boolean acknowledged() { */ public static class RemoveRequest { final String name; + TimeValue clusterManagerTimeout = ClusterManagerNodeRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT; + + /** @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #clusterManagerTimeout} */ + @Deprecated TimeValue masterTimeout = ClusterManagerNodeRequest.DEFAULT_CLUSTER_MANAGER_NODE_TIMEOUT; public RemoveRequest(String name) { this.name = name; } - public RemoveRequest masterTimeout(TimeValue masterTimeout) { - this.masterTimeout = masterTimeout; + public RemoveRequest clusterManagerTimeout(TimeValue clusterManagerTimeout) { + this.clusterManagerTimeout = clusterManagerTimeout; return this; } + + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagerTimeout} */ + @Deprecated + public RemoveRequest masterTimeout(TimeValue masterTimeout) { + return clusterManagerTimeout(masterTimeout); + } } /** diff --git a/server/src/main/java/org/opensearch/cluster/metadata/SystemIndexMetadataUpgradeService.java b/server/src/main/java/org/opensearch/cluster/metadata/SystemIndexMetadataUpgradeService.java index c708f3830f431..b1dd490a032b0 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/SystemIndexMetadataUpgradeService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/SystemIndexMetadataUpgradeService.java @@ -70,8 +70,8 @@ public SystemIndexMetadataUpgradeService(SystemIndices systemIndices, ClusterSer @Override public void clusterChanged(ClusterChangedEvent event) { - if (event.localNodeMaster() != clusterManager) { - this.clusterManager = event.localNodeMaster(); + if (event.localNodeClusterManager() != clusterManager) { + this.clusterManager = event.localNodeClusterManager(); } if (clusterManager && updateTaskPending == false) { diff --git a/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java b/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java index 01cadf3910267..51da1c73e57a4 100644 --- a/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java +++ b/server/src/main/java/org/opensearch/cluster/metadata/TemplateUpgradeService.java @@ -109,7 +109,7 @@ public TemplateUpgradeService( } return upgradedTemplates; }; - if (DiscoveryNode.isMasterNode(clusterService.getSettings())) { + if (DiscoveryNode.isClusterManagerNode(clusterService.getSettings())) { clusterService.addListener(this); } } @@ -117,7 +117,7 @@ public TemplateUpgradeService( @Override public void clusterChanged(ClusterChangedEvent event) { ClusterState state = event.state(); - if (state.nodes().isLocalNodeElectedMaster() == false) { + if (state.nodes().isLocalNodeElectedClusterManager() == false) { return; } if (state.blocks().hasGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK)) { diff --git a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java index 0d55624a35998..beb69e7f1cfaa 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNode.java @@ -74,7 +74,7 @@ public class DiscoveryNode implements Writeable, ToXContentFragment { public static boolean nodeRequiresLocalStorage(Settings settings) { boolean localStorageEnable = Node.NODE_LOCAL_STORAGE_SETTING.get(settings); - if (localStorageEnable == false && (isDataNode(settings) || isMasterNode(settings))) { + if (localStorageEnable == false && (isDataNode(settings) || isClusterManagerNode(settings))) { // TODO: make this a proper setting validation logic, requiring multi-settings validation throw new IllegalArgumentException("storage can not be disabled for cluster-manager and data nodes"); } @@ -96,10 +96,16 @@ public static boolean hasRole(final Settings settings, final DiscoveryNodeRole r } } - public static boolean isMasterNode(Settings settings) { + public static boolean isClusterManagerNode(Settings settings) { return hasRole(settings, DiscoveryNodeRole.MASTER_ROLE) || hasRole(settings, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #isClusterManagerNode(Settings)} */ + @Deprecated + public static boolean isMasterNode(Settings settings) { + return isClusterManagerNode(settings); + } + /** * Due to the way that plugins may not be available when settings are being initialized, * not all roles may be available from a static/initializing context such as a {@link Setting} @@ -462,10 +468,20 @@ public boolean isDataNode() { /** * Can this node become cluster-manager or not. */ - public boolean isMasterNode() { + public boolean isClusterManagerNode() { return roles.contains(DiscoveryNodeRole.MASTER_ROLE) || roles.contains(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } + /** + * Can this node become cluster-manager or not. + * + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #isClusterManagerNode()} + */ + @Deprecated + public boolean isMasterNode() { + return isClusterManagerNode(); + } + /** * Returns a boolean that tells whether this an ingest node or not */ diff --git a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java index 0304a51f330c8..8f1d8ef824a56 100644 --- a/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java +++ b/server/src/main/java/org/opensearch/cluster/node/DiscoveryNodes.java @@ -114,7 +114,7 @@ public Iterator iterator() { /** * Returns {@code true} if the local node is the elected cluster-manager node. */ - public boolean isLocalNodeElectedMaster() { + public boolean isLocalNodeElectedClusterManager() { if (localNodeId == null) { // we don't know yet the local node id, return false return false; @@ -122,6 +122,16 @@ public boolean isLocalNodeElectedMaster() { return localNodeId.equals(clusterManagerNodeId); } + /** + * Returns {@code true} if the local node is the elected cluster-manager node. + * + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #isLocalNodeElectedClusterManager()} + */ + @Deprecated + public boolean isLocalNodeElectedMaster() { + return isLocalNodeElectedClusterManager(); + } + /** * Get the number of known nodes * @@ -154,10 +164,21 @@ public ImmutableOpenMap getDataNodes() { * * @return {@link Map} of the discovered cluster-manager nodes arranged by their ids */ - public ImmutableOpenMap getMasterNodes() { + public ImmutableOpenMap getClusterManagerNodes() { return this.clusterManagerNodes; } + /** + * 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.2, because supporting inclusive language, replaced by {@link #getClusterManagerNodes()} + */ + @Deprecated + public ImmutableOpenMap getMasterNodes() { + return getClusterManagerNodes(); + } + /** * @return All the ingest nodes arranged by their ids */ @@ -170,12 +191,23 @@ public ImmutableOpenMap getIngestNodes() { * * @return {@link Map} of the discovered cluster-manager and data nodes arranged by their ids */ - public ImmutableOpenMap getMasterAndDataNodes() { + public ImmutableOpenMap getClusterManagerAndDataNodes() { ImmutableOpenMap.Builder nodes = ImmutableOpenMap.builder(dataNodes); nodes.putAll(clusterManagerNodes); return nodes.build(); } + /** + * 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.2, because supporting inclusive language, replaced by {@link #getClusterManagerAndDataNodes()} + */ + @Deprecated + public ImmutableOpenMap getMasterAndDataNodes() { + return getClusterManagerAndDataNodes(); + } + /** * Get a {@link Map} of the coordinating only nodes (nodes which are neither cluster-manager, nor data, nor ingest nodes) arranged by their ids * @@ -192,13 +224,23 @@ public ImmutableOpenMap getCoordinatingOnlyNodes() { /** * Returns a stream of all nodes, with cluster-manager nodes at the front */ - public Stream mastersFirstStream() { + public Stream clusterManagersFirstStream() { return Stream.concat( StreamSupport.stream(clusterManagerNodes.spliterator(), false).map(cur -> cur.value), - StreamSupport.stream(this.spliterator(), false).filter(n -> n.isMasterNode() == false) + StreamSupport.stream(this.spliterator(), false).filter(n -> n.isClusterManagerNode() == false) ); } + /** + * Returns a stream of all nodes, with cluster-manager nodes at the front + * + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagersFirstStream()} + */ + @Deprecated + public Stream mastersFirstStream() { + return clusterManagersFirstStream(); + } + /** * Get a node by its id * @@ -256,10 +298,21 @@ public boolean nodeExistsWithBWCVersion(DiscoveryNode discoveryNode) { * * @return id of the cluster-manager */ - public String getMasterNodeId() { + public String getClusterManagerNodeId() { return this.clusterManagerNodeId; } + /** + * Get the id of the cluster-manager node + * + * @return id of the cluster-manager + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getClusterManagerNodeId()} + */ + @Deprecated + public String getMasterNodeId() { + return getClusterManagerNodeId(); + } + /** * Get the id of the local node * @@ -282,13 +335,24 @@ public DiscoveryNode getLocalNode() { * Returns the cluster-manager node, or {@code null} if there is no cluster-manager node */ @Nullable - public DiscoveryNode getMasterNode() { + public DiscoveryNode getClusterManagerNode() { if (clusterManagerNodeId != null) { return nodes.get(clusterManagerNodeId); } return null; } + /** + * Returns the cluster-manager node, or {@code null} if there is no cluster-manager node + * + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #getClusterManagerNode()} + */ + @Deprecated + @Nullable + public DiscoveryNode getMasterNode() { + return getClusterManagerNode(); + } + /** * Get a node by its address * @@ -396,7 +460,7 @@ public String[] resolveNodes(String... nodes) { resolvedNodesIds.add(localNodeId); } } else if (nodeId.equals("_master") || nodeId.equals("_cluster_manager")) { - String clusterManagerNodeId = getMasterNodeId(); + String clusterManagerNodeId = getClusterManagerNodeId(); if (clusterManagerNodeId != null) { resolvedNodesIds.add(clusterManagerNodeId); } @@ -490,8 +554,8 @@ public Delta delta(DiscoveryNodes other) { } return new Delta( - other.getMasterNode(), - getMasterNode(), + other.getClusterManagerNode(), + getClusterManagerNode(), localNodeId, Collections.unmodifiableList(removed), Collections.unmodifiableList(added) @@ -507,7 +571,7 @@ public String toString() { if (node == getLocalNode()) { sb.append(", local"); } - if (node == getMasterNode()) { + if (node == getClusterManagerNode()) { sb.append(", cluster-manager"); } sb.append("\n"); @@ -545,23 +609,43 @@ private Delta( } public boolean hasChanges() { - return masterNodeChanged() || !removed.isEmpty() || !added.isEmpty(); + return clusterManagerNodeChanged() || !removed.isEmpty() || !added.isEmpty(); } - public boolean masterNodeChanged() { + public boolean clusterManagerNodeChanged() { return Objects.equals(newClusterManagerNode, previousClusterManagerNode) == false; } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagerNodeChanged()} */ + @Deprecated + public boolean masterNodeChanged() { + return clusterManagerNodeChanged(); + } + @Nullable public DiscoveryNode previousClusterManagerNode() { return previousClusterManagerNode; } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #previousClusterManagerNode()} */ + @Deprecated @Nullable - public DiscoveryNode newMasterNode() { + public DiscoveryNode previousMasterNode() { + return previousClusterManagerNode(); + } + + @Nullable + public DiscoveryNode newClusterManagerNode() { return newClusterManagerNode; } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #newClusterManagerNode()} */ + @Deprecated + @Nullable + public DiscoveryNode newMasterNode() { + return newClusterManagerNode(); + } + public boolean removed() { return !removed.isEmpty(); } @@ -580,14 +664,14 @@ public List addedNodes() { public String shortSummary() { final StringBuilder summary = new StringBuilder(); - if (masterNodeChanged()) { + if (clusterManagerNodeChanged()) { summary.append("cluster-manager node changed {previous ["); if (previousClusterManagerNode() != null) { summary.append(previousClusterManagerNode()); } summary.append("], current ["); - if (newMasterNode() != null) { - summary.append(newMasterNode()); + if (newClusterManagerNode() != null) { + summary.append(newClusterManagerNode()); } summary.append("]}"); } @@ -631,7 +715,7 @@ public void writeTo(StreamOutput out) throws IOException { public static DiscoveryNodes readFrom(StreamInput in, DiscoveryNode localNode) throws IOException { Builder builder = new Builder(); if (in.readBoolean()) { - builder.masterNodeId(in.readString()); + builder.clusterManagerNodeId(in.readString()); } if (localNode != null) { builder.localNodeId(localNode.getId()); @@ -679,7 +763,7 @@ public Builder() { } public Builder(DiscoveryNodes nodes) { - this.clusterManagerNodeId = nodes.getMasterNodeId(); + this.clusterManagerNodeId = nodes.getClusterManagerNodeId(); this.localNodeId = nodes.getLocalNodeId(); this.nodes = ImmutableOpenMap.builder(nodes.getNodes()); } @@ -724,11 +808,17 @@ public Builder remove(DiscoveryNode node) { return this; } - public Builder masterNodeId(String clusterManagerNodeId) { + public Builder clusterManagerNodeId(String clusterManagerNodeId) { this.clusterManagerNodeId = clusterManagerNodeId; return this; } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #clusterManagerNodeId} */ + @Deprecated + public Builder masterNodeId(String clusterManagerNodeId) { + return clusterManagerNodeId(clusterManagerNodeId); + } + public Builder localNodeId(String localNodeId) { this.localNodeId = localNodeId; return this; @@ -761,7 +851,7 @@ private String validateAdd(DiscoveryNode node) { public DiscoveryNodes build() { ImmutableOpenMap.Builder dataNodesBuilder = ImmutableOpenMap.builder(); - ImmutableOpenMap.Builder masterNodesBuilder = ImmutableOpenMap.builder(); + ImmutableOpenMap.Builder clusterManagerNodesBuilder = ImmutableOpenMap.builder(); ImmutableOpenMap.Builder ingestNodesBuilder = ImmutableOpenMap.builder(); Version minNodeVersion = null; Version maxNodeVersion = null; @@ -771,11 +861,11 @@ public DiscoveryNodes build() { if (nodeEntry.value.isDataNode()) { dataNodesBuilder.put(nodeEntry.key, nodeEntry.value); } - if (nodeEntry.value.isMasterNode()) { - masterNodesBuilder.put(nodeEntry.key, nodeEntry.value); + if (nodeEntry.value.isClusterManagerNode()) { + clusterManagerNodesBuilder.put(nodeEntry.key, nodeEntry.value); } final Version version = nodeEntry.value.getVersion(); - if (nodeEntry.value.isDataNode() || nodeEntry.value.isMasterNode()) { + if (nodeEntry.value.isDataNode() || nodeEntry.value.isClusterManagerNode()) { if (minNonClientNodeVersion == null) { minNonClientNodeVersion = version; maxNonClientNodeVersion = version; @@ -794,7 +884,7 @@ public DiscoveryNodes build() { return new DiscoveryNodes( nodes.build(), dataNodesBuilder.build(), - masterNodesBuilder.build(), + clusterManagerNodesBuilder.build(), ingestNodesBuilder.build(), clusterManagerNodeId, localNodeId, @@ -805,9 +895,15 @@ public DiscoveryNodes build() { ); } - public boolean isLocalNodeElectedMaster() { + public boolean isLocalNodeElectedClusterManager() { return clusterManagerNodeId != null && clusterManagerNodeId.equals(localNodeId); } + + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #isLocalNodeElectedClusterManager()} */ + @Deprecated + public boolean isLocalNodeElectedMaster() { + return isLocalNodeElectedClusterManager(); + } } /** diff --git a/server/src/main/java/org/opensearch/cluster/routing/BatchedRerouteService.java b/server/src/main/java/org/opensearch/cluster/routing/BatchedRerouteService.java index 0738254823964..641fb9abf73e0 100644 --- a/server/src/main/java/org/opensearch/cluster/routing/BatchedRerouteService.java +++ b/server/src/main/java/org/opensearch/cluster/routing/BatchedRerouteService.java @@ -141,7 +141,7 @@ public ClusterState execute(ClusterState currentState) { } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { synchronized (mutex) { if (pendingRerouteListeners == currentListeners) { pendingRerouteListeners = null; diff --git a/server/src/main/java/org/opensearch/cluster/routing/DelayedAllocationService.java b/server/src/main/java/org/opensearch/cluster/routing/DelayedAllocationService.java index 321b10be6463d..844b78dccc59b 100644 --- a/server/src/main/java/org/opensearch/cluster/routing/DelayedAllocationService.java +++ b/server/src/main/java/org/opensearch/cluster/routing/DelayedAllocationService.java @@ -150,7 +150,7 @@ public DelayedAllocationService(ThreadPool threadPool, ClusterService clusterSer this.threadPool = threadPool; this.clusterService = clusterService; this.allocationService = allocationService; - if (DiscoveryNode.isMasterNode(clusterService.getSettings())) { + if (DiscoveryNode.isClusterManagerNode(clusterService.getSettings())) { clusterService.addListener(this); } } @@ -174,7 +174,7 @@ protected long currentNanoTime() { @Override public void clusterChanged(ClusterChangedEvent event) { - if (event.localNodeMaster()) { + if (event.localNodeClusterManager()) { long currentNanoTime = currentNanoTime(); scheduleIfNeeded(currentNanoTime, event.state()); } @@ -196,7 +196,7 @@ private void removeIfSameTask(DelayedRerouteTask expectedTask) { * Figure out if an existing scheduled reroute is good enough or whether we need to cancel and reschedule. */ private synchronized void scheduleIfNeeded(long currentNanoTime, ClusterState state) { - assertClusterOrMasterStateThread(); + assertClusterOrClusterManagerStateThread(); long nextDelayNanos = UnassignedInfo.findNextDelayedAllocation(currentNanoTime, state); if (nextDelayNanos < 0) { logger.trace("no need to schedule reroute - no delayed unassigned shards"); @@ -236,7 +236,14 @@ 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.assertClusterOrClusterManagerStateThread(); + } + + // protected so that it can be overridden (and disabled) by unit tests + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #assertClusterOrClusterManagerStateThread()} */ + @Deprecated protected void assertClusterOrMasterStateThread() { - assert ClusterService.assertClusterOrMasterStateThread(); + assertClusterOrClusterManagerStateThread(); } } diff --git a/server/src/main/java/org/opensearch/cluster/service/ClusterApplierService.java b/server/src/main/java/org/opensearch/cluster/service/ClusterApplierService.java index bc1397989dc96..ce6672f0961bd 100644 --- a/server/src/main/java/org/opensearch/cluster/service/ClusterApplierService.java +++ b/server/src/main/java/org/opensearch/cluster/service/ClusterApplierService.java @@ -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; @@ -277,10 +278,19 @@ public void removeTimeoutListener(TimeoutClusterStateListener listener) { /** * Add a listener for on/off local node cluster-manager events */ - public void addLocalNodeMasterListener(LocalNodeClusterManagerListener listener) { + public void addLocalNodeClusterManagerListener(LocalNodeClusterManagerListener listener) { addListener(listener); } + /** + * Add a listener for on/off local node cluster-manager events + * @deprecated As of 2.1, because supporting inclusive language, replaced by {@link #addLocalNodeClusterManagerListener} + */ + @Deprecated + public void addLocalNodeMasterListener(LocalNodeMasterListener listener) { + addLocalNodeClusterManagerListener(listener); + } + /** * Adds a cluster state listener that is expected to be removed during a short period of time. * If provided, the listener will be notified once a specific time has elapsed. diff --git a/server/src/main/java/org/opensearch/cluster/service/ClusterService.java b/server/src/main/java/org/opensearch/cluster/service/ClusterService.java index baf453d18b3b3..c58bb4d9a947c 100644 --- a/server/src/main/java/org/opensearch/cluster/service/ClusterService.java +++ b/server/src/main/java/org/opensearch/cluster/service/ClusterService.java @@ -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; @@ -214,8 +215,17 @@ public void removeListener(ClusterStateListener listener) { /** * Add a listener for on/off local node cluster-manager events */ - public void addLocalNodeMasterListener(LocalNodeClusterManagerListener listener) { - clusterApplierService.addLocalNodeMasterListener(listener); + public void addLocalNodeClusterManagerListener(LocalNodeClusterManagerListener listener) { + clusterApplierService.addLocalNodeClusterManagerListener(listener); + } + + /** + * Add a listener for on/off local node cluster-manager events + * @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #addLocalNodeClusterManagerListener} + */ + @Deprecated + public void addLocalNodeMasterListener(LocalNodeMasterListener listener) { + addLocalNodeClusterManagerListener(listener); } public MasterService getMasterService() { @@ -240,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; } diff --git a/server/src/main/java/org/opensearch/cluster/service/MasterService.java b/server/src/main/java/org/opensearch/cluster/service/MasterService.java index 2d52887858372..cc58c56e00dd5 100644 --- a/server/src/main/java/org/opensearch/cluster/service/MasterService.java +++ b/server/src/main/java/org/opensearch/cluster/service/MasterService.java @@ -256,7 +256,7 @@ private void runTasks(TaskInputs taskInputs) { logger.debug("executing cluster state update for [{}]", summary); final ClusterState previousClusterState = state(); - if (!previousClusterState.nodes().isLocalNodeElectedMaster() && taskInputs.runOnlyWhenClusterManager()) { + if (!previousClusterState.nodes().isLocalNodeElectedClusterManager() && taskInputs.runOnlyWhenClusterManager()) { logger.debug("failing [{}]: local node is no longer cluster-manager", summary); taskInputs.onNoLongerClusterManager(); return; @@ -616,9 +616,9 @@ public void onFailure(String source, Exception e) { } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { try (ThreadContext.StoredContext ignore = context.get()) { - listener.onNoLongerMaster(source); + listener.onNoLongerClusterManager(source); } catch (Exception e) { logger.error( () -> new ParameterizedMessage( @@ -745,7 +745,7 @@ private static class AckCountDownListener implements Discovery.AckListener { this.ackedTaskListener = ackedTaskListener; this.clusterStateVersion = clusterStateVersion; this.threadPool = threadPool; - this.clusterManagerNode = nodes.getMasterNode(); + this.clusterManagerNode = nodes.getClusterManagerNode(); int countDown = 0; for (DiscoveryNode node : nodes) { // we always wait for at least the cluster-manager node @@ -823,8 +823,8 @@ private ClusterTasksResult executeTasks(TaskInputs taskInputs, ClusterSt List inputs = taskInputs.updateTasks.stream().map(tUpdateTask -> tUpdateTask.task).collect(Collectors.toList()); clusterTasksResult = taskInputs.executor.execute(previousClusterState, inputs); if (previousClusterState != clusterTasksResult.resultingState - && previousClusterState.nodes().isLocalNodeElectedMaster() - && (clusterTasksResult.resultingState.nodes().isLocalNodeElectedMaster() == false)) { + && previousClusterState.nodes().isLocalNodeElectedClusterManager() + && (clusterTasksResult.resultingState.nodes().isLocalNodeElectedClusterManager() == false)) { throw new AssertionError("update task submitted to ClusterManagerService cannot remove cluster-manager"); } } catch (Exception e) { @@ -888,11 +888,11 @@ private class TaskInputs { } boolean runOnlyWhenClusterManager() { - return executor.runOnlyOnMaster(); + return executor.runOnlyOnClusterManager(); } void onNoLongerClusterManager() { - updateTasks.forEach(task -> task.listener.onNoLongerMaster(task.source())); + updateTasks.forEach(task -> task.listener.onNoLongerClusterManager(task.source())); } } diff --git a/server/src/main/java/org/opensearch/common/settings/ConsistentSettingsService.java b/server/src/main/java/org/opensearch/common/settings/ConsistentSettingsService.java index e01a7919a4755..a644192db552c 100644 --- a/server/src/main/java/org/opensearch/common/settings/ConsistentSettingsService.java +++ b/server/src/main/java/org/opensearch/common/settings/ConsistentSettingsService.java @@ -123,7 +123,7 @@ public boolean areAllConsistent() { "no published hash for the consistent secure setting [{}] but it exists on the local node", concreteSecureSetting.getKey() ); - if (state.nodes().isLocalNodeElectedMaster()) { + if (state.nodes().isLocalNodeElectedClusterManager()) { throw new IllegalStateException( "Master node cannot validate consistent setting. No published hash for [" + concreteSecureSetting.getKey() @@ -162,7 +162,7 @@ public boolean areAllConsistent() { concreteSecureSetting.getKey(), computedSaltedHash ); - if (state.nodes().isLocalNodeElectedMaster()) { + if (state.nodes().isLocalNodeElectedClusterManager()) { throw new IllegalStateException( "Master node cannot validate consistent setting. The published hash [" + publishedHash diff --git a/server/src/main/java/org/opensearch/discovery/HandshakingTransportAddressConnector.java b/server/src/main/java/org/opensearch/discovery/HandshakingTransportAddressConnector.java index fcc890b1c21c9..8c0073cbbf245 100644 --- a/server/src/main/java/org/opensearch/discovery/HandshakingTransportAddressConnector.java +++ b/server/src/main/java/org/opensearch/discovery/HandshakingTransportAddressConnector.java @@ -141,7 +141,7 @@ protected void innerOnResponse(DiscoveryNode remoteNode) { if (remoteNode.equals(transportService.getLocalNode())) { listener.onFailure(new ConnectTransportException(remoteNode, "local node found")); - } else if (remoteNode.isMasterNode() == false) { + } else if (remoteNode.isClusterManagerNode() == false) { listener.onFailure( new ConnectTransportException(remoteNode, "non-cluster-manager-eligible node found") ); diff --git a/server/src/main/java/org/opensearch/discovery/PeerFinder.java b/server/src/main/java/org/opensearch/discovery/PeerFinder.java index 03cdc4ba68cc9..a601a6fbe4d82 100644 --- a/server/src/main/java/org/opensearch/discovery/PeerFinder.java +++ b/server/src/main/java/org/opensearch/discovery/PeerFinder.java @@ -174,7 +174,7 @@ PeersResponse handlePeersRequest(PeersRequest peersRequest) { final List knownPeers; if (active) { assert leader.isPresent() == false : leader; - if (peersRequest.getSourceNode().isMasterNode()) { + if (peersRequest.getSourceNode().isClusterManagerNode()) { startProbe(peersRequest.getSourceNode().getAddress()); } peersRequest.getKnownPeers().stream().map(DiscoveryNode::getAddress).forEach(this::startProbe); @@ -291,7 +291,7 @@ private boolean handleWakeUp() { } logger.trace("probing cluster-manager nodes from cluster state: {}", lastAcceptedNodes); - for (ObjectCursor discoveryNodeObjectCursor : lastAcceptedNodes.getMasterNodes().values()) { + for (ObjectCursor discoveryNodeObjectCursor : lastAcceptedNodes.getClusterManagerNodes().values()) { startProbe(discoveryNodeObjectCursor.value.getAddress()); } @@ -396,7 +396,7 @@ void establishConnection() { transportAddressConnector.connectToRemoteMasterNode(transportAddress, new ActionListener() { @Override public void onResponse(DiscoveryNode remoteNode) { - assert remoteNode.isMasterNode() : remoteNode + " is not cluster-manager-eligible"; + assert remoteNode.isClusterManagerNode() : remoteNode + " is not cluster-manager-eligible"; assert remoteNode.equals(getLocalNode()) == false : remoteNode + " is the local node"; synchronized (mutex) { if (active == false) { @@ -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()); diff --git a/server/src/main/java/org/opensearch/env/NodeEnvironment.java b/server/src/main/java/org/opensearch/env/NodeEnvironment.java index d1f1fa73790a3..91fe6a82b0b5e 100644 --- a/server/src/main/java/org/opensearch/env/NodeEnvironment.java +++ b/server/src/main/java/org/opensearch/env/NodeEnvironment.java @@ -354,12 +354,12 @@ public NodeEnvironment(Settings settings, Environment environment) throws IOExce applySegmentInfosTrace(settings); assertCanWrite(); - if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings)) { + if (DiscoveryNode.isClusterManagerNode(settings) || DiscoveryNode.isDataNode(settings)) { ensureAtomicMoveSupported(nodePaths); } if (DiscoveryNode.isDataNode(settings) == false) { - if (DiscoveryNode.isMasterNode(settings) == false) { + if (DiscoveryNode.isClusterManagerNode(settings) == false) { ensureNoIndexMetadata(nodePaths); } diff --git a/server/src/main/java/org/opensearch/env/NodeRepurposeCommand.java b/server/src/main/java/org/opensearch/env/NodeRepurposeCommand.java index 2e9ea67a93944..58d6f33292273 100644 --- a/server/src/main/java/org/opensearch/env/NodeRepurposeCommand.java +++ b/server/src/main/java/org/opensearch/env/NodeRepurposeCommand.java @@ -96,7 +96,7 @@ protected void processNodePaths(Terminal terminal, Path[] dataPaths, int nodeLoc throws IOException { assert DiscoveryNode.isDataNode(env.settings()) == false; - if (DiscoveryNode.isMasterNode(env.settings()) == false) { + if (DiscoveryNode.isClusterManagerNode(env.settings()) == false) { processNoClusterManagerNoDataNode(terminal, dataPaths, env); } else { processClusterManagerNoDataNode(terminal, dataPaths, env); diff --git a/server/src/main/java/org/opensearch/gateway/Gateway.java b/server/src/main/java/org/opensearch/gateway/Gateway.java index f46f4317c83e1..413c08569c64a 100644 --- a/server/src/main/java/org/opensearch/gateway/Gateway.java +++ b/server/src/main/java/org/opensearch/gateway/Gateway.java @@ -70,7 +70,7 @@ public Gateway( } public void performStateRecovery(final GatewayStateRecoveredListener listener) throws GatewayException { - final String[] nodesIds = clusterService.state().nodes().getMasterNodes().keys().toArray(String.class); + final String[] nodesIds = clusterService.state().nodes().getClusterManagerNodes().keys().toArray(String.class); logger.trace("performing state recovery from {}", Arrays.toString(nodesIds)); final TransportNodesListGatewayMetaState.NodesGatewayMetaState nodesState = listGatewayMetaState.list(nodesIds, null).actionGet(); diff --git a/server/src/main/java/org/opensearch/gateway/GatewayMetaState.java b/server/src/main/java/org/opensearch/gateway/GatewayMetaState.java index 610219ab1f054..f70fdea153893 100644 --- a/server/src/main/java/org/opensearch/gateway/GatewayMetaState.java +++ b/server/src/main/java/org/opensearch/gateway/GatewayMetaState.java @@ -127,7 +127,7 @@ public void start( ) { assert persistedState.get() == null : "should only start once, but already have " + persistedState.get(); - if (DiscoveryNode.isMasterNode(settings) || DiscoveryNode.isDataNode(settings)) { + if (DiscoveryNode.isClusterManagerNode(settings) || DiscoveryNode.isDataNode(settings)) { try { final PersistedClusterStateService.OnDiskState onDiskState = persistedClusterStateService.loadBestOnDiskState(); @@ -158,7 +158,7 @@ public void start( .build() ); - if (DiscoveryNode.isMasterNode(settings)) { + if (DiscoveryNode.isClusterManagerNode(settings)) { persistedState = new LucenePersistedState(persistedClusterStateService, currentTerm, clusterState); } else { persistedState = new AsyncLucenePersistedState( diff --git a/server/src/main/java/org/opensearch/gateway/GatewayService.java b/server/src/main/java/org/opensearch/gateway/GatewayService.java index 06e92b7f0d7cf..d04f3ee15d888 100644 --- a/server/src/main/java/org/opensearch/gateway/GatewayService.java +++ b/server/src/main/java/org/opensearch/gateway/GatewayService.java @@ -188,7 +188,7 @@ public GatewayService( @Override protected void doStart() { - if (DiscoveryNode.isMasterNode(clusterService.getSettings())) { + if (DiscoveryNode.isClusterManagerNode(clusterService.getSettings())) { // use post applied so that the state will be visible to the background recovery thread we spawn in performStateRecovery clusterService.addListener(this); } @@ -210,7 +210,7 @@ public void clusterChanged(final ClusterChangedEvent event) { final ClusterState state = event.state(); - if (state.nodes().isLocalNodeElectedMaster() == false) { + if (state.nodes().isLocalNodeElectedClusterManager() == false) { // not our job to recover return; } @@ -220,12 +220,12 @@ public void clusterChanged(final ClusterChangedEvent event) { } final DiscoveryNodes nodes = state.nodes(); - if (state.nodes().getMasterNodeId() == null) { + if (state.nodes().getClusterManagerNodeId() == null) { logger.debug("not recovering from gateway, no cluster-manager elected yet"); - } else if (recoverAfterNodes != -1 && (nodes.getMasterAndDataNodes().size()) < recoverAfterNodes) { + } else if (recoverAfterNodes != -1 && (nodes.getClusterManagerAndDataNodes().size()) < recoverAfterNodes) { logger.debug( "not recovering from gateway, nodes_size (data+master) [{}] < recover_after_nodes [{}]", - nodes.getMasterAndDataNodes().size(), + nodes.getClusterManagerAndDataNodes().size(), recoverAfterNodes ); } else if (recoverAfterDataNodes != -1 && nodes.getDataNodes().size() < recoverAfterDataNodes) { @@ -234,10 +234,10 @@ public void clusterChanged(final ClusterChangedEvent event) { nodes.getDataNodes().size(), recoverAfterDataNodes ); - } else if (recoverAfterClusterManagerNodes != -1 && nodes.getMasterNodes().size() < recoverAfterClusterManagerNodes) { + } else if (recoverAfterClusterManagerNodes != -1 && nodes.getClusterManagerNodes().size() < recoverAfterClusterManagerNodes) { logger.debug( "not recovering from gateway, nodes_size (master) [{}] < recover_after_master_nodes [{}]", - nodes.getMasterNodes().size(), + nodes.getClusterManagerNodes().size(), recoverAfterClusterManagerNodes ); } else { @@ -251,19 +251,24 @@ public void clusterChanged(final ClusterChangedEvent event) { // one of the expected is set, see if all of them meet the need, and ignore the timeout in this case enforceRecoverAfterTime = false; reason = ""; - if (expectedNodes != -1 && (nodes.getMasterAndDataNodes().size() < expectedNodes)) { // does not meet the expected... + if (expectedNodes != -1 && (nodes.getClusterManagerAndDataNodes().size() < expectedNodes)) { // does not meet the + // expected... enforceRecoverAfterTime = true; - reason = "expecting [" + expectedNodes + "] nodes, but only have [" + nodes.getMasterAndDataNodes().size() + "]"; + reason = "expecting [" + + expectedNodes + + "] nodes, but only have [" + + nodes.getClusterManagerAndDataNodes().size() + + "]"; } else if (expectedDataNodes != -1 && (nodes.getDataNodes().size() < expectedDataNodes)) { // does not meet the expected... enforceRecoverAfterTime = true; reason = "expecting [" + expectedDataNodes + "] data nodes, but only have [" + nodes.getDataNodes().size() + "]"; - } else if (expectedClusterManagerNodes != -1 && (nodes.getMasterNodes().size() < expectedClusterManagerNodes)) { + } else if (expectedClusterManagerNodes != -1 && (nodes.getClusterManagerNodes().size() < expectedClusterManagerNodes)) { // does not meet the expected... enforceRecoverAfterTime = true; reason = "expecting [" + expectedClusterManagerNodes + "] cluster-manager nodes, but only have [" - + nodes.getMasterNodes().size() + + nodes.getClusterManagerNodes().size() + "]"; } } @@ -341,7 +346,7 @@ public void clusterStateProcessed(final String source, final ClusterState oldSta } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { logger.debug("stepped down as cluster-manager before recovering state [{}]", source); resetRecoveredFlags(); } diff --git a/server/src/main/java/org/opensearch/gateway/LocalAllocateDangledIndices.java b/server/src/main/java/org/opensearch/gateway/LocalAllocateDangledIndices.java index 98b3c104aadbf..735140ca5dc24 100644 --- a/server/src/main/java/org/opensearch/gateway/LocalAllocateDangledIndices.java +++ b/server/src/main/java/org/opensearch/gateway/LocalAllocateDangledIndices.java @@ -108,7 +108,7 @@ public LocalAllocateDangledIndices( public void allocateDangled(Collection indices, ActionListener listener) { ClusterState clusterState = clusterService.state(); - DiscoveryNode clusterManagerNode = clusterState.nodes().getMasterNode(); + DiscoveryNode clusterManagerNode = clusterState.nodes().getClusterManagerNode(); if (clusterManagerNode == null) { listener.onFailure(new ClusterManagerNotDiscoveredException("no cluster-manager to send allocate dangled request")); return; @@ -165,7 +165,7 @@ public ClusterState execute(ClusterState currentState) { indexMetadata.getIndex(), request.fromNode, indexMetadata.getCreationVersion(), - currentState.getNodes().getMasterNode().getVersion() + currentState.getNodes().getClusterManagerNode().getVersion() ); continue; } diff --git a/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java b/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java index d63a178b4213a..55d95381923b3 100644 --- a/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java +++ b/server/src/main/java/org/opensearch/index/seqno/ReplicationTracker.java @@ -135,7 +135,7 @@ public class ReplicationTracker extends AbstractIndexShardComponent implements L * to eagerly. As consequence, some of the methods in this class are not allowed to be called while a handoff is in progress, * in particular {@link #markAllocationIdAsInSync}. * - * A notable exception to this is the method {@link #updateFromMaster}, which is still allowed to be called during a relocation handoff. + * A notable exception to this is the method {@link #updateFromClusterManager}, which is still allowed to be called during a relocation handoff. * The reason for this is that the handoff might fail and can be aborted (using {@link #abortRelocationHandoff}), in which case * it is important that the global checkpoint tracker does not miss any state updates that might happened during the handoff attempt. * This means, however, that the global checkpoint can still advance after the primary relocation handoff has been initiated, but only @@ -1176,7 +1176,7 @@ private void addPeerRecoveryRetentionLeaseForSolePrimary() { * @param inSyncAllocationIds the allocation IDs of the currently in-sync shard copies * @param routingTable the shard routing table */ - public synchronized void updateFromMaster( + public synchronized void updateFromClusterManager( final long applyingClusterStateVersion, final Set inSyncAllocationIds, final IndexShardRoutingTable routingTable @@ -1239,6 +1239,22 @@ public synchronized void updateFromMaster( assert invariant(); } + /** + * Notifies the tracker of the current allocation IDs in the cluster state. + * @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.2, because supporting inclusive language, replaced by {@link #updateFromClusterManager(long, Set, IndexShardRoutingTable)} + */ + @Deprecated + public synchronized void updateFromMaster( + final long applyingClusterStateVersion, + final Set inSyncAllocationIds, + final IndexShardRoutingTable routingTable + ) { + updateFromClusterManager(applyingClusterStateVersion, inSyncAllocationIds, routingTable); + } + /** * Called when the recovery process for a shard has opened the engine on the target shard. Ensures that the right data structures * have been set up locally to track local checkpoint information for the shard and that the shard is added to the replication group. @@ -1558,7 +1574,7 @@ private Runnable getClusterManagerUpdateOperationFromCurrentState() { } }); final IndexShardRoutingTable lastAppliedRoutingTable = routingTable; - return () -> updateFromMaster(lastAppliedClusterStateVersion, inSyncAllocationIds, lastAppliedRoutingTable); + return () -> updateFromClusterManager(lastAppliedClusterStateVersion, inSyncAllocationIds, lastAppliedRoutingTable); } /** diff --git a/server/src/main/java/org/opensearch/index/shard/IndexShard.java b/server/src/main/java/org/opensearch/index/shard/IndexShard.java index e54c08d4cbad3..67084789fb60e 100644 --- a/server/src/main/java/org/opensearch/index/shard/IndexShard.java +++ b/server/src/main/java/org/opensearch/index/shard/IndexShard.java @@ -513,7 +513,7 @@ public void updateShardState( } if (newRouting.primary()) { - replicationTracker.updateFromMaster(applyingClusterStateVersion, inSyncAllocationIds, routingTable); + replicationTracker.updateFromClusterManager(applyingClusterStateVersion, inSyncAllocationIds, routingTable); } if (state == IndexShardState.POST_RECOVERY && newRouting.active()) { diff --git a/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java b/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java index 96326fd70c2bd..68360e065092e 100644 --- a/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java +++ b/server/src/main/java/org/opensearch/indices/cluster/IndicesClusterStateService.java @@ -207,14 +207,14 @@ public IndicesClusterStateService( @Override protected void doStart() { // Doesn't make sense to manage shards on non-master and non-data nodes - if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isMasterNode(settings)) { + if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isClusterManagerNode(settings)) { clusterService.addHighPriorityApplier(this); } } @Override protected void doStop() { - if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isMasterNode(settings)) { + if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isClusterManagerNode(settings)) { clusterService.removeApplier(this); } } @@ -272,7 +272,7 @@ private void updateFailedShardsCache(final ClusterState state) { return; } - DiscoveryNode clusterManagerNode = state.nodes().getMasterNode(); + DiscoveryNode clusterManagerNode = state.nodes().getClusterManagerNode(); // remove items from cache which are not in our routing table anymore and // resend failures that have not executed on cluster-manager yet @@ -509,7 +509,7 @@ private void createIndices(final ClusterState state) { indexService = indicesService.createIndex(indexMetadata, buildInIndexListener, true); if (indexService.updateMapping(null, indexMetadata) && sendRefreshMapping) { nodeMappingRefreshAction.nodeMappingRefresh( - state.nodes().getMasterNode(), + state.nodes().getClusterManagerNode(), new NodeMappingRefreshAction.NodeMappingRefreshRequest( indexMetadata.getIndex().getName(), indexMetadata.getIndexUUID(), @@ -556,7 +556,7 @@ private void updateIndices(ClusterChangedEvent event) { reason = "mapping update failed"; if (indexService.updateMapping(currentIndexMetadata, newIndexMetadata) && sendRefreshMapping) { nodeMappingRefreshAction.nodeMappingRefresh( - state.nodes().getMasterNode(), + state.nodes().getClusterManagerNode(), new NodeMappingRefreshAction.NodeMappingRefreshRequest( newIndexMetadata.getIndex().getName(), newIndexMetadata.getIndexUUID(), @@ -681,15 +681,15 @@ private void updateShard( "{} cluster-manager marked shard as initializing, but shard has state [{}], resending shard started to {}", shardRouting.shardId(), state, - nodes.getMasterNode() + nodes.getClusterManagerNode() ); } - if (nodes.getMasterNode() != null) { + if (nodes.getClusterManagerNode() != null) { shardStateAction.shardStarted( shardRouting, primaryTerm, "cluster-manager " - + nodes.getMasterNode() + + nodes.getClusterManagerNode() + " marked shard as initializing, but shard state is [" + state + "], mark shard as started", @@ -878,7 +878,7 @@ public interface Shard { * - Updates and persists the new routing value. * - Updates the primary term if this shard is a primary. * - Updates the allocation ids that are tracked by the shard if it is a primary. - * See {@link ReplicationTracker#updateFromMaster(long, Set, IndexShardRoutingTable)} for details. + * See {@link ReplicationTracker#updateFromClusterManager(long, Set, IndexShardRoutingTable)} for details. * * @param shardRouting the new routing entry * @param primaryTerm the new primary term diff --git a/server/src/main/java/org/opensearch/node/Node.java b/server/src/main/java/org/opensearch/node/Node.java index d937daaaec454..e9800200c197d 100644 --- a/server/src/main/java/org/opensearch/node/Node.java +++ b/server/src/main/java/org/opensearch/node/Node.java @@ -728,7 +728,7 @@ protected Node( systemIndices, scriptService ); - if (DiscoveryNode.isMasterNode(settings)) { + if (DiscoveryNode.isClusterManagerNode(settings)) { clusterService.addListener(new SystemIndexMetadataUpgradeService(systemIndices, clusterService)); } new TemplateUpgradeService(client, clusterService, threadPool, indexTemplateMetadataUpgraders); @@ -1122,7 +1122,7 @@ public Node start() throws NodeValidationException { ClusterState clusterState = clusterService.state(); ClusterStateObserver observer = new ClusterStateObserver(clusterState, clusterService, null, logger, thread.getThreadContext()); - if (clusterState.nodes().getMasterNodeId() == null) { + if (clusterState.nodes().getClusterManagerNodeId() == null) { logger.debug("waiting to join the cluster. timeout [{}]", initialStateTimeout); final CountDownLatch latch = new CountDownLatch(1); observer.waitForNextChange(new ClusterStateObserver.Listener() { @@ -1141,7 +1141,7 @@ public void onTimeout(TimeValue timeout) { logger.warn("timed out while waiting for initial discovery state - timeout: {}", initialStateTimeout); latch.countDown(); } - }, state -> state.nodes().getMasterNodeId() != null, initialStateTimeout); + }, state -> state.nodes().getClusterManagerNodeId() != null, initialStateTimeout); try { latch.await(); @@ -1464,7 +1464,7 @@ protected ClusterInfoService newClusterInfoService( NodeClient client ) { final InternalClusterInfoService service = new InternalClusterInfoService(settings, clusterService, threadPool, client); - if (DiscoveryNode.isMasterNode(settings)) { + if (DiscoveryNode.isClusterManagerNode(settings)) { // listen for state changes (this node starts/stops being the elected cluster manager, or new nodes are added) clusterService.addListener(service); } diff --git a/server/src/main/java/org/opensearch/persistent/PersistentTasksClusterService.java b/server/src/main/java/org/opensearch/persistent/PersistentTasksClusterService.java index b9cb03854829d..9dc7f7d7380cc 100644 --- a/server/src/main/java/org/opensearch/persistent/PersistentTasksClusterService.java +++ b/server/src/main/java/org/opensearch/persistent/PersistentTasksClusterService.java @@ -93,7 +93,7 @@ public PersistentTasksClusterService( this.decider = new EnableAssignmentDecider(settings, clusterService.getClusterSettings()); this.threadPool = threadPool; this.periodicRechecker = new PeriodicRechecker(CLUSTER_TASKS_ALLOCATION_RECHECK_INTERVAL_SETTING.get(settings)); - if (DiscoveryNode.isMasterNode(settings)) { + if (DiscoveryNode.isClusterManagerNode(settings)) { clusterService.addListener(this); } clusterService.getClusterSettings() @@ -356,7 +356,7 @@ private Assignment createAssignment( @Override public void clusterChanged(ClusterChangedEvent event) { - if (event.localNodeMaster()) { + if (event.localNodeClusterManager()) { if (shouldReassignPersistentTasks(event)) { // We want to avoid a periodic check duplicating this work periodicRechecker.cancel(); @@ -409,7 +409,7 @@ boolean shouldReassignPersistentTasks(final ClusterChangedEvent event) { return false; } - boolean masterChanged = event.previousState().nodes().isLocalNodeElectedMaster() == false; + boolean masterChanged = event.previousState().nodes().isLocalNodeElectedClusterManager() == false; if (persistentTasksChanged(event) || event.nodesChanged() @@ -518,7 +518,7 @@ protected boolean mustReschedule() { @Override public void runInternal() { - if (clusterService.localNode().isMasterNode()) { + if (clusterService.localNode().isClusterManagerNode()) { final ClusterState state = clusterService.state(); logger.trace("periodic persistent task assignment check running for cluster state {}", state.getVersion()); if (isAnyTaskUnassigned(state.getMetadata().custom(PersistentTasksCustomMetadata.TYPE))) { diff --git a/server/src/main/java/org/opensearch/repositories/RepositoriesService.java b/server/src/main/java/org/opensearch/repositories/RepositoriesService.java index 5b4e30f8495e8..c70c10495b7b5 100644 --- a/server/src/main/java/org/opensearch/repositories/RepositoriesService.java +++ b/server/src/main/java/org/opensearch/repositories/RepositoriesService.java @@ -126,7 +126,7 @@ public RepositoriesService( this.threadPool = threadPool; // Doesn't make sense to maintain repositories on non-master and non-data nodes // Nothing happens there anyway - if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isMasterNode(settings)) { + if (DiscoveryNode.isDataNode(settings) || DiscoveryNode.isClusterManagerNode(settings)) { if (isDedicatedVotingOnlyNode(DiscoveryNode.getRolesFromSettings(settings)) == false) { clusterService.addHighPriorityApplier(this); } @@ -238,7 +238,7 @@ public void onFailure(String source, Exception e) { @Override public boolean mustAck(DiscoveryNode discoveryNode) { // repository is created on both cluster-manager and data nodes - return discoveryNode.isMasterNode() || discoveryNode.isDataNode(); + return discoveryNode.isClusterManagerNode() || discoveryNode.isDataNode(); } } ); @@ -293,7 +293,7 @@ public ClusterState execute(ClusterState currentState) { @Override public boolean mustAck(DiscoveryNode discoveryNode) { // repository was created on both cluster-manager and data nodes - return discoveryNode.isMasterNode() || discoveryNode.isDataNode(); + return discoveryNode.isClusterManagerNode() || discoveryNode.isDataNode(); } } ); diff --git a/server/src/main/java/org/opensearch/repositories/VerifyNodeRepositoryAction.java b/server/src/main/java/org/opensearch/repositories/VerifyNodeRepositoryAction.java index 98e8521ecff57..3c6d948aee453 100644 --- a/server/src/main/java/org/opensearch/repositories/VerifyNodeRepositoryAction.java +++ b/server/src/main/java/org/opensearch/repositories/VerifyNodeRepositoryAction.java @@ -96,7 +96,7 @@ public void verify(String repository, String verificationToken, final ActionList final DiscoveryNodes discoNodes = clusterService.state().nodes(); final DiscoveryNode localNode = discoNodes.getLocalNode(); - final ObjectContainer masterAndDataNodes = discoNodes.getMasterAndDataNodes().values(); + final ObjectContainer masterAndDataNodes = discoNodes.getClusterManagerAndDataNodes().values(); final List nodes = new ArrayList<>(); for (ObjectCursor cursor : masterAndDataNodes) { DiscoveryNode node = cursor.value; diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestClusterManagerAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestClusterManagerAction.java index c1cf887884678..ac57ba16abcf8 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestClusterManagerAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestClusterManagerAction.java @@ -113,7 +113,7 @@ private Table buildTable(RestRequest request, ClusterStateResponse state) { DiscoveryNodes nodes = state.getState().nodes(); table.startRow(); - DiscoveryNode clusterManager = nodes.get(nodes.getMasterNodeId()); + DiscoveryNode clusterManager = nodes.get(nodes.getClusterManagerNodeId()); if (clusterManager == null) { table.addCell("-"); table.addCell("-"); diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java index 717df832d5d73..b4d336f4c10c0 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestHealthAction.java @@ -119,7 +119,7 @@ private Table buildTable(final ClusterHealthResponse health, final RestRequest r t.addCell(health.getStatus().name().toLowerCase(Locale.ROOT)); t.addCell(health.getNumberOfNodes()); t.addCell(health.getNumberOfDataNodes()); - t.addCell(health.hasDiscoveredMaster()); + t.addCell(health.hasDiscoveredClusterManager()); t.addCell(health.getActiveShards()); t.addCell(health.getActivePrimaryShards()); t.addCell(health.getRelocatingShards()); diff --git a/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java b/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java index b2c34a01c344d..f39f96ece180a 100644 --- a/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java +++ b/server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java @@ -343,7 +343,7 @@ Table buildTable( ) { DiscoveryNodes nodes = state.getState().nodes(); - String clusterManagerId = nodes.getMasterNodeId(); + String clusterManagerId = nodes.getClusterManagerNodeId(); Table table = getTableWithHeader(req); for (DiscoveryNode node : nodes) { diff --git a/server/src/main/java/org/opensearch/snapshots/InternalSnapshotsInfoService.java b/server/src/main/java/org/opensearch/snapshots/InternalSnapshotsInfoService.java index 10328d3e2ce9f..518e4a558b2df 100644 --- a/server/src/main/java/org/opensearch/snapshots/InternalSnapshotsInfoService.java +++ b/server/src/main/java/org/opensearch/snapshots/InternalSnapshotsInfoService.java @@ -130,7 +130,7 @@ public InternalSnapshotsInfoService( this.maxConcurrentFetches = INTERNAL_SNAPSHOT_INFO_MAX_CONCURRENT_FETCHES_SETTING.get(settings); final ClusterSettings clusterSettings = clusterService.getClusterSettings(); clusterSettings.addSettingsUpdateConsumer(INTERNAL_SNAPSHOT_INFO_MAX_CONCURRENT_FETCHES_SETTING, this::setMaxConcurrentFetches); - if (DiscoveryNode.isMasterNode(settings)) { + if (DiscoveryNode.isClusterManagerNode(settings)) { clusterService.addListener(this); } } @@ -155,7 +155,7 @@ public SnapshotShardSizeInfo snapshotShardSizes() { @Override public void clusterChanged(ClusterChangedEvent event) { - if (event.localNodeMaster()) { + if (event.localNodeClusterManager()) { final Set onGoingSnapshotRecoveries = listOfSnapshotShards(event.state()); int unknownShards = 0; @@ -180,7 +180,7 @@ public void clusterChanged(ClusterChangedEvent event) { fetchNextSnapshotShard(); } - } else if (event.previousState().nodes().isLocalNodeElectedMaster()) { + } else if (event.previousState().nodes().isLocalNodeElectedClusterManager()) { // TODO Maybe just clear out non-ongoing snapshot recoveries is the node is cluster-manager eligible, so that we don't // have to repopulate the data over and over in an unstable cluster-manager situation? synchronized (mutex) { diff --git a/server/src/main/java/org/opensearch/snapshots/RestoreService.java b/server/src/main/java/org/opensearch/snapshots/RestoreService.java index 15cf0654ad67e..0b32621c716ca 100644 --- a/server/src/main/java/org/opensearch/snapshots/RestoreService.java +++ b/server/src/main/java/org/opensearch/snapshots/RestoreService.java @@ -189,7 +189,7 @@ public RestoreService( this.allocationService = allocationService; this.createIndexService = createIndexService; this.metadataIndexUpgradeService = metadataIndexUpgradeService; - if (DiscoveryNode.isMasterNode(clusterService.getSettings())) { + if (DiscoveryNode.isClusterManagerNode(clusterService.getSettings())) { clusterService.addStateApplier(this); } this.clusterSettings = clusterService.getClusterSettings(); @@ -969,7 +969,7 @@ public void onFailure(final String source, final Exception e) { } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { logger.debug("no longer cluster-manager while processing restore state update [{}]", source); } @@ -1119,7 +1119,7 @@ public static Set restoringIndices(final ClusterState currentState, final @Override public void applyClusterState(ClusterChangedEvent event) { try { - if (event.localNodeMaster()) { + if (event.localNodeClusterManager()) { cleanupRestoreState(event); } } catch (Exception t) { diff --git a/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java b/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java index 9295cff5c1f54..6c36f5cea1e36 100644 --- a/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java +++ b/server/src/main/java/org/opensearch/snapshots/SnapshotShardsService.java @@ -150,8 +150,8 @@ public void clusterChanged(ClusterChangedEvent event) { } } - String previousClusterManagerNodeId = event.previousState().nodes().getMasterNodeId(); - String currentMasterNodeId = event.state().nodes().getMasterNodeId(); + String previousClusterManagerNodeId = event.previousState().nodes().getClusterManagerNodeId(); + String currentMasterNodeId = event.state().nodes().getClusterManagerNodeId(); if (currentMasterNodeId != null && currentMasterNodeId.equals(previousClusterManagerNodeId) == false) { syncShardStatsOnNewMaster(event); } diff --git a/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java b/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java index c87bf33727524..024fb6ec53089 100644 --- a/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java +++ b/server/src/main/java/org/opensearch/snapshots/SnapshotsService.java @@ -235,7 +235,7 @@ public SnapshotsService( actionFilters, indexNameExpressionResolver ); - if (DiscoveryNode.isMasterNode(settings)) { + if (DiscoveryNode.isClusterManagerNode(settings)) { // addLowPriorityApplier to make sure that Repository will be created before snapshot clusterService.addLowPriorityApplier(this); maxConcurrentOperations = MAX_CONCURRENT_SNAPSHOT_OPERATIONS_SETTING.get(settings); @@ -1120,7 +1120,7 @@ public void onFailure(String source, Exception e) { } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { // We are not longer a cluster-manager - we shouldn't try to do any cleanup // The new cluster-manager will take care of it logger.warn( @@ -1181,7 +1181,7 @@ public void onFailure(@Nullable Exception e) { userCreateSnapshotListener.onFailure(ExceptionsHelper.useOrSuppress(e, this.e)); } - public void onNoLongerMaster() { + public void onNoLongerClusterManager() { userCreateSnapshotListener.onFailure(e); } } @@ -1305,11 +1305,11 @@ public static List currentSnapshots( @Override public void applyClusterState(ClusterChangedEvent event) { try { - if (event.localNodeMaster()) { + if (event.localNodeClusterManager()) { // We don't remove old cluster-manager when cluster-manager flips anymore. So, we need to check for change in // cluster-manager SnapshotsInProgress snapshotsInProgress = event.state().custom(SnapshotsInProgress.TYPE, SnapshotsInProgress.EMPTY); - final boolean newClusterManager = event.previousState().nodes().isLocalNodeElectedMaster() == false; + final boolean newClusterManager = event.previousState().nodes().isLocalNodeElectedClusterManager() == false; processExternalChanges( newClusterManager || removedNodesCleanupNeeded(snapshotsInProgress, event.nodesDelta().removedNodes()), event.routingTableChanged() && waitingShardsStartedOrUnassigned(snapshotsInProgress, event) @@ -2091,12 +2091,12 @@ public void onFailure(String source, Exception e) { } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { failure.addSuppressed(new SnapshotException(snapshot, "no longer cluster-manager")); failSnapshotCompletionListeners(snapshot, failure); failAllListenersOnMasterFailOver(new NotClusterManagerException(source)); if (listener != null) { - listener.onNoLongerMaster(); + listener.onNoLongerClusterManager(); } } diff --git a/server/src/main/java/org/opensearch/transport/ConnectionProfile.java b/server/src/main/java/org/opensearch/transport/ConnectionProfile.java index 708d1a3a0e4c1..b9764c0c53f4a 100644 --- a/server/src/main/java/org/opensearch/transport/ConnectionProfile.java +++ b/server/src/main/java/org/opensearch/transport/ConnectionProfile.java @@ -103,7 +103,10 @@ public static ConnectionProfile buildDefaultConnectionProfile(Settings settings) builder.addConnections(connectionsPerNodeBulk, TransportRequestOptions.Type.BULK); builder.addConnections(connectionsPerNodePing, TransportRequestOptions.Type.PING); // if we are not cluster-manager eligible we don't need a dedicated channel to publish the state - builder.addConnections(DiscoveryNode.isMasterNode(settings) ? connectionsPerNodeState : 0, TransportRequestOptions.Type.STATE); + builder.addConnections( + DiscoveryNode.isClusterManagerNode(settings) ? connectionsPerNodeState : 0, + TransportRequestOptions.Type.STATE + ); // if we are not a data-node we don't need any dedicated channels for recovery builder.addConnections(DiscoveryNode.isDataNode(settings) ? connectionsPerNodeRecovery : 0, TransportRequestOptions.Type.RECOVERY); builder.addConnections(connectionsPerNodeReg, TransportRequestOptions.Type.REG); diff --git a/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java b/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java index 3e95c937a296f..47fd5fc2c9489 100644 --- a/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java +++ b/server/src/main/java/org/opensearch/transport/SniffConnectionStrategy.java @@ -141,7 +141,7 @@ public class SniffConnectionStrategy extends RemoteConnectionStrategy { static final int CHANNELS_PER_CONNECTION = 6; private static final Predicate DEFAULT_NODE_PREDICATE = (node) -> Version.CURRENT.isCompatible(node.getVersion()) - && (node.isMasterNode() == false || node.isDataNode() || node.isIngestNode()); + && (node.isClusterManagerNode() == false || node.isDataNode() || node.isIngestNode()); private final List configuredSeedNodes; private final List> seedNodes; diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java index dfd6d059cc3a8..0c728c8314517 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportAddVotingConfigExclusionsActionTests.java @@ -175,7 +175,7 @@ public void setupForTest() { .add(otherNode2) .add(otherDataNode) .localNodeId(localNode.getId()) - .masterNodeId(localNode.getId()) + .clusterManagerNodeId(localNode.getId()) ) .metadata( Metadata.builder() diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java index 604eee4763c89..b3620bf757256 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/configuration/TransportClearVotingConfigExclusionsActionTests.java @@ -126,7 +126,11 @@ public void setupForTest() { transportService.acceptIncomingRequests(); final ClusterState.Builder builder = builder(new ClusterName("cluster")).nodes( - new Builder().add(localNode).add(otherNode1).add(otherNode2).localNodeId(localNode.getId()).masterNodeId(localNode.getId()) + new Builder().add(localNode) + .add(otherNode1) + .add(otherNode2) + .localNodeId(localNode.getId()) + .clusterManagerNodeId(localNode.getId()) ); builder.metadata( Metadata.builder() diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponsesTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponsesTests.java index 6022838d924d3..8cec478eb4d7c 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponsesTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/health/ClusterHealthResponsesTests.java @@ -116,7 +116,7 @@ public void testClusterHealthVerifyClusterManagerNodeDiscovery() throws IOExcept DiscoveryNode localNode = new DiscoveryNode("node", OpenSearchTestCase.buildNewFakeTransportAddress(), Version.CURRENT); // set the node information to verify cluster_manager_node discovery in ClusterHealthResponse ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)) - .nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId()).masterNodeId(localNode.getId())) + .nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId()).clusterManagerNodeId(localNode.getId())) .build(); int pendingTasks = randomIntBetween(0, 200); int inFlight = randomIntBetween(0, 200); @@ -132,7 +132,7 @@ public void testClusterHealthVerifyClusterManagerNodeDiscovery() throws IOExcept pendingTaskInQueueTime ); clusterHealth = maybeSerialize(clusterHealth); - assertThat(clusterHealth.getClusterStateHealth().hasDiscoveredMaster(), Matchers.equalTo(true)); + assertThat(clusterHealth.getClusterStateHealth().hasDiscoveredClusterManager(), Matchers.equalTo(true)); assertClusterHealth(clusterHealth); } @@ -146,7 +146,7 @@ private void assertClusterHealth(ClusterHealthResponse clusterHealth) { assertThat(clusterHealth.getUnassignedShards(), Matchers.equalTo(clusterStateHealth.getUnassignedShards())); assertThat(clusterHealth.getNumberOfNodes(), Matchers.equalTo(clusterStateHealth.getNumberOfNodes())); assertThat(clusterHealth.getNumberOfDataNodes(), Matchers.equalTo(clusterStateHealth.getNumberOfDataNodes())); - assertThat(clusterHealth.hasDiscoveredMaster(), Matchers.equalTo(clusterStateHealth.hasDiscoveredMaster())); + assertThat(clusterHealth.hasDiscoveredClusterManager(), Matchers.equalTo(clusterStateHealth.hasDiscoveredClusterManager())); } public void testVersionCompatibleSerialization() throws IOException { @@ -240,7 +240,7 @@ public void testParseFromXContentWithDiscoveredClusterManagerField() throws IOEx assertNotNull(clusterHealth); assertThat(clusterHealth.getClusterName(), Matchers.equalTo("535799904437:7-1-3-node")); assertThat(clusterHealth.getNumberOfNodes(), Matchers.equalTo(6)); - assertThat(clusterHealth.hasDiscoveredMaster(), Matchers.equalTo(true)); + assertThat(clusterHealth.hasDiscoveredClusterManager(), Matchers.equalTo(true)); } } @@ -261,7 +261,7 @@ public void testParseFromXContentWithoutDiscoveredClusterManagerField() throws I assertNotNull(clusterHealth); assertThat(clusterHealth.getClusterName(), Matchers.equalTo("535799904437:7-1-3-node")); assertThat(clusterHealth.getNumberOfNodes(), Matchers.equalTo(6)); - assertThat(clusterHealth.hasDiscoveredMaster(), Matchers.equalTo(false)); + assertThat(clusterHealth.hasDiscoveredClusterManager(), Matchers.equalTo(false)); } } @@ -283,7 +283,7 @@ public void testParseFromXContentWithDeprecatedDiscoveredMasterField() throws IO ) ) { ClusterHealthResponse clusterHealth = ClusterHealthResponse.fromXContent(parser); - assertThat(clusterHealth.hasDiscoveredMaster(), Matchers.equalTo(true)); + assertThat(clusterHealth.hasDiscoveredClusterManager(), Matchers.equalTo(true)); } try ( @@ -299,7 +299,7 @@ public void testParseFromXContentWithDeprecatedDiscoveredMasterField() throws IO ) ) { ClusterHealthResponse clusterHealth = ClusterHealthResponse.fromXContent(parser); - assertThat(clusterHealth.hasDiscoveredMaster(), Matchers.equalTo(true)); + assertThat(clusterHealth.hasDiscoveredClusterManager(), Matchers.equalTo(true)); } } @@ -449,7 +449,7 @@ protected ClusterHealthResponse mutateInstance(ClusterHealthResponse instance) { state.getUnassignedShards(), state.getNumberOfNodes(), state.getNumberOfDataNodes(), - state.hasDiscoveredMaster(), + state.hasDiscoveredClusterManager(), state.getActiveShardsPercent(), state.getStatus(), state.getIndices() diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java index 7a7bc18876932..94f9be6c3ee85 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java @@ -61,7 +61,7 @@ public class ClusterRerouteResponseTests extends OpenSearchTestCase { public void testToXContent() throws IOException { DiscoveryNode node0 = new DiscoveryNode("node0", new TransportAddress(TransportAddress.META_ADDRESS, 9000), Version.CURRENT); - DiscoveryNodes nodes = new DiscoveryNodes.Builder().add(node0).masterNodeId(node0.getId()).build(); + DiscoveryNodes nodes = new DiscoveryNodes.Builder().add(node0).clusterManagerNodeId(node0.getId()).build(); IndexMetadata indexMetadata = IndexMetadata.builder("index") .settings( Settings.builder() diff --git a/server/src/test/java/org/opensearch/action/admin/cluster/state/ClusterStateResponseTests.java b/server/src/test/java/org/opensearch/action/admin/cluster/state/ClusterStateResponseTests.java index 6455cd553f932..1cf5ecd9fde9e 100644 --- a/server/src/test/java/org/opensearch/action/admin/cluster/state/ClusterStateResponseTests.java +++ b/server/src/test/java/org/opensearch/action/admin/cluster/state/ClusterStateResponseTests.java @@ -49,7 +49,7 @@ protected ClusterStateResponse createTestInstance() { if (randomBoolean()) { ClusterState.Builder clusterStateBuilder = ClusterState.builder(clusterName).version(randomNonNegativeLong()); if (randomBoolean()) { - clusterStateBuilder.nodes(DiscoveryNodes.builder().masterNodeId(randomAlphaOfLength(4)).build()); + clusterStateBuilder.nodes(DiscoveryNodes.builder().clusterManagerNodeId(randomAlphaOfLength(4)).build()); } clusterState = clusterStateBuilder.build(); } diff --git a/server/src/test/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java b/server/src/test/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java index 930fe4ad6049d..bf43823f47079 100644 --- a/server/src/test/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java @@ -284,7 +284,7 @@ void setClusterState(ClusterService clusterService, String index) { } } discoBuilder.localNodeId(newNode(0).getId()); - discoBuilder.masterNodeId(newNode(numberOfNodes - 1).getId()); + discoBuilder.clusterManagerNodeId(newNode(numberOfNodes - 1).getId()); ClusterState.Builder stateBuilder = ClusterState.builder(new ClusterName(TEST_CLUSTER)); stateBuilder.nodes(discoBuilder); final IndexMetadata.Builder indexMetadata = IndexMetadata.builder(index) @@ -374,7 +374,7 @@ public void testRequestsAreNotSentToFailedClusterManager() { Request request = new Request(new String[] { TEST_INDEX }); PlainActionFuture listener = new PlainActionFuture<>(); - DiscoveryNode clusterManagerNode = clusterService.state().nodes().getMasterNode(); + DiscoveryNode clusterManagerNode = clusterService.state().nodes().getClusterManagerNode(); DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes()); builder.remove(clusterManagerNode.getId()); @@ -460,10 +460,10 @@ public void testResultAggregation() throws ExecutionException, InterruptedExcept final boolean simulateFailedClusterManagerNode = rarely(); DiscoveryNode failedClusterManagerNode = null; if (simulateFailedClusterManagerNode) { - failedClusterManagerNode = clusterService.state().nodes().getMasterNode(); + failedClusterManagerNode = clusterService.state().nodes().getClusterManagerNode(); DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes()); builder.remove(failedClusterManagerNode.getId()); - builder.masterNodeId(null); + builder.clusterManagerNodeId(null); setState(clusterService, ClusterState.builder(clusterService.state()).nodes(builder)); } diff --git a/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java b/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java index acfdf7982e9d0..f0b62914213c1 100644 --- a/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/clustermanager/TransportClusterManagerNodeActionTests.java @@ -405,7 +405,7 @@ public void testDelegateToClusterManager() throws ExecutionException, Interrupte assertThat(transport.capturedRequests().length, equalTo(1)); CapturingTransport.CapturedRequest capturedRequest = transport.capturedRequests()[0]; - assertTrue(capturedRequest.node.isMasterNode()); + assertTrue(capturedRequest.node.isClusterManagerNode()); assertThat(capturedRequest.request, equalTo(request)); assertThat(capturedRequest.action, equalTo("internal:testAction")); @@ -432,7 +432,7 @@ public void testDelegateToFailingClusterManager() throws ExecutionException, Int CapturingTransport.CapturedRequest[] capturedRequests = transport.getCapturedRequestsAndClear(); assertThat(capturedRequests.length, equalTo(1)); CapturingTransport.CapturedRequest capturedRequest = capturedRequests[0]; - assertTrue(capturedRequest.node.isMasterNode()); + assertTrue(capturedRequest.node.isClusterManagerNode()); assertThat(capturedRequest.request, equalTo(request)); assertThat(capturedRequest.action, equalTo("internal:testAction")); @@ -447,14 +447,14 @@ public void testDelegateToFailingClusterManager() throws ExecutionException, Int if (randomBoolean()) { // simulate cluster-manager node removal final DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(clusterService.state().nodes()); - nodesBuilder.masterNodeId(null); + nodesBuilder.clusterManagerNodeId(null); setState(clusterService, ClusterState.builder(clusterService.state()).nodes(nodesBuilder)); } if (randomBoolean()) { // reset the same state to increment a version simulating a join of an existing node // simulating use being disconnected final DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(clusterService.state().nodes()); - nodesBuilder.masterNodeId(clusterManagerNode.getId()); + nodesBuilder.clusterManagerNodeId(clusterManagerNode.getId()); setState(clusterService, ClusterState.builder(clusterService.state()).nodes(nodesBuilder)); } else { // simulate cluster-manager restart followed by a state recovery - this will reset the cluster state version @@ -466,7 +466,7 @@ public void testDelegateToFailingClusterManager() throws ExecutionException, Int clusterManagerNode.getVersion() ); nodesBuilder.add(clusterManagerNode); - nodesBuilder.masterNodeId(clusterManagerNode.getId()); + nodesBuilder.clusterManagerNodeId(clusterManagerNode.getId()); final ClusterState.Builder builder = ClusterState.builder(clusterService.state()).nodes(nodesBuilder); setState(clusterService, builder.version(0)); } @@ -474,7 +474,7 @@ public void testDelegateToFailingClusterManager() throws ExecutionException, Int capturedRequests = transport.getCapturedRequestsAndClear(); assertThat(capturedRequests.length, equalTo(1)); capturedRequest = capturedRequests[0]; - assertTrue(capturedRequest.node.isMasterNode()); + assertTrue(capturedRequest.node.isClusterManagerNode()); assertThat(capturedRequest.request, equalTo(request)); assertThat(capturedRequest.action, equalTo("internal:testAction")); } else if (failsWithConnectTransportException) { @@ -524,7 +524,7 @@ protected void masterOperation(Request request, ClusterState state, ActionListen assertThat(transport.capturedRequests().length, equalTo(1)); CapturingTransport.CapturedRequest capturedRequest = transport.capturedRequests()[0]; - assertTrue(capturedRequest.node.isMasterNode()); + assertTrue(capturedRequest.node.isClusterManagerNode()); assertThat(capturedRequest.request, equalTo(request)); assertThat(capturedRequest.action, equalTo("internal:testAction")); @@ -559,7 +559,7 @@ public void testDelegateToClusterManagerOnNodeWithDeprecatedMasterRole() throws assertThat(transport.capturedRequests().length, equalTo(1)); CapturingTransport.CapturedRequest capturedRequest = transport.capturedRequests()[0]; - assertTrue(capturedRequest.node.isMasterNode()); + assertTrue(capturedRequest.node.isClusterManagerNode()); assertThat(capturedRequest.request, equalTo(request)); assertThat(capturedRequest.action, equalTo("internal:testAction")); diff --git a/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java b/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java index 53ebceb25510a..86657a98d9a1d 100644 --- a/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java +++ b/server/src/test/java/org/opensearch/action/support/nodes/TransportNodesActionTests.java @@ -226,7 +226,7 @@ public void setUp() throws Exception { discoveryNodes.add(node); } discoBuilder.localNodeId(randomFrom(discoveryNodes).getId()); - discoBuilder.masterNodeId(randomFrom(discoveryNodes).getId()); + discoBuilder.clusterManagerNodeId(randomFrom(discoveryNodes).getId()); ClusterState.Builder stateBuilder = ClusterState.builder(clusterService.getClusterName()); stateBuilder.nodes(discoBuilder); ClusterState clusterState = stateBuilder.build(); diff --git a/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationAllPermitsAcquisitionTests.java b/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationAllPermitsAcquisitionTests.java index b034b335bd9a3..98972d4063a97 100644 --- a/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationAllPermitsAcquisitionTests.java +++ b/server/src/test/java/org/opensearch/action/support/replication/TransportReplicationAllPermitsAcquisitionTests.java @@ -142,7 +142,7 @@ public void setUp() throws Exception { Set roles = new HashSet<>(DiscoveryNodeRole.BUILT_IN_ROLES); DiscoveryNode node1 = new DiscoveryNode("_name1", "_node1", buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT); DiscoveryNode node2 = new DiscoveryNode("_name2", "_node2", buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT); - state.nodes(DiscoveryNodes.builder().add(node1).add(node2).localNodeId(node1.getId()).masterNodeId(node1.getId())); + state.nodes(DiscoveryNodes.builder().add(node1).add(node2).localNodeId(node1.getId()).clusterManagerNodeId(node1.getId())); shardId = new ShardId("index", UUID.randomUUID().toString(), 0); ShardRouting shardRouting = newShardRouting( diff --git a/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java b/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java index 16f21a48d7ab8..df7c10cd1acd8 100644 --- a/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java +++ b/server/src/test/java/org/opensearch/cluster/ClusterChangedEventTests.java @@ -115,11 +115,11 @@ public void testLocalNodeIsClusterManager() { ClusterState previousState = createSimpleClusterState(); ClusterState newState = createState(numNodesInCluster, true, initialIndices); ClusterChangedEvent event = new ClusterChangedEvent("_na_", newState, previousState); - assertTrue("local node should be cluster-manager", event.localNodeMaster()); + assertTrue("local node should be cluster-manager", event.localNodeClusterManager()); newState = createState(numNodesInCluster, false, initialIndices); event = new ClusterChangedEvent("_na_", newState, previousState); - assertFalse("local node should not be cluster-manager", event.localNodeMaster()); + assertFalse("local node should not be cluster-manager", event.localNodeClusterManager()); } /** @@ -319,10 +319,10 @@ public void testLocalNodeIsClusterManagerWithDeprecatedMasterRole() { final DiscoveryNodes.Builder builderLocalIsMaster = DiscoveryNodes.builder(); final DiscoveryNode node0 = newNode("node_0", Set.of(DiscoveryNodeRole.MASTER_ROLE)); final DiscoveryNode node1 = newNode("node_1", Set.of(DiscoveryNodeRole.DATA_ROLE)); - builderLocalIsMaster.add(node0).add(node1).masterNodeId(node0.getId()).localNodeId(node0.getId()); + builderLocalIsMaster.add(node0).add(node1).clusterManagerNodeId(node0.getId()).localNodeId(node0.getId()); final DiscoveryNodes.Builder builderLocalNotMaster = DiscoveryNodes.builder(); - builderLocalNotMaster.add(node0).add(node1).masterNodeId(node0.getId()).localNodeId(node1.getId()); + builderLocalNotMaster.add(node0).add(node1).clusterManagerNodeId(node0.getId()).localNodeId(node1.getId()); ClusterState previousState = createSimpleClusterState(); final Metadata metadata = createMetadata(initialIndices); @@ -332,7 +332,7 @@ public void testLocalNodeIsClusterManagerWithDeprecatedMasterRole() { .routingTable(createRoutingTable(1, metadata)) .build(); ClusterChangedEvent event = new ClusterChangedEvent("_na_", newState, previousState); - assertTrue("local node should be master", event.localNodeMaster()); + assertTrue("local node should be master", event.localNodeClusterManager()); newState = ClusterState.builder(TEST_CLUSTER_NAME) .nodes(builderLocalNotMaster.build()) @@ -340,7 +340,7 @@ public void testLocalNodeIsClusterManagerWithDeprecatedMasterRole() { .routingTable(createRoutingTable(1, metadata)) .build(); event = new ClusterChangedEvent("_na_", newState, previousState); - assertFalse("local node should not be master", event.localNodeMaster()); + assertFalse("local node should not be master", event.localNodeClusterManager()); } private static class CustomMetadata2 extends TestCustomMetadata { @@ -476,7 +476,7 @@ private static DiscoveryNodes createDiscoveryNodes(final int numNodes, final boo Set roles = new HashSet<>(); if (i == 0) { // the cluster-manager node - builder.masterNodeId(nodeId); + builder.clusterManagerNodeId(nodeId); roles.add(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } else if (i == 1) { // the alternate cluster-manager node diff --git a/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java b/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java index 3155954d020a4..f5461054ca70c 100644 --- a/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java +++ b/server/src/test/java/org/opensearch/cluster/ClusterStateTests.java @@ -90,15 +90,15 @@ public void testSupersedes() { ClusterState noClusterManager2 = ClusterState.builder(name).version(randomInt(5)).nodes(nodes).build(); ClusterState withClusterManager1a = ClusterState.builder(name) .version(randomInt(5)) - .nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.getId())) + .nodes(DiscoveryNodes.builder(nodes).clusterManagerNodeId(node1.getId())) .build(); ClusterState withClusterManager1b = ClusterState.builder(name) .version(randomInt(5)) - .nodes(DiscoveryNodes.builder(nodes).masterNodeId(node1.getId())) + .nodes(DiscoveryNodes.builder(nodes).clusterManagerNodeId(node1.getId())) .build(); ClusterState withClusterManager2 = ClusterState.builder(name) .version(randomInt(5)) - .nodes(DiscoveryNodes.builder(nodes).masterNodeId(node2.getId())) + .nodes(DiscoveryNodes.builder(nodes).clusterManagerNodeId(node2.getId())) .build(); // states with no cluster-manager should never supersede anything @@ -871,7 +871,7 @@ private ClusterState buildClusterState() throws IOException { .stateUUID("stateUUID") .nodes( DiscoveryNodes.builder() - .masterNodeId("clusterManagerNodeId") + .clusterManagerNodeId("clusterManagerNodeId") .add(new DiscoveryNode("nodeId1", new TransportAddress(InetAddress.getByName("127.0.0.1"), 111), Version.CURRENT)) .build() ) diff --git a/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java b/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java index 7f09f1eb8e2be..a989bacbf47bb 100644 --- a/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java +++ b/server/src/test/java/org/opensearch/cluster/InternalClusterInfoServiceSchedulingTests.java @@ -69,7 +69,9 @@ public class InternalClusterInfoServiceSchedulingTests extends OpenSearchTestCas public void testScheduling() { final DiscoveryNode discoveryNode = new DiscoveryNode("test", buildNewFakeTransportAddress(), Version.CURRENT); final DiscoveryNodes noClusterManager = DiscoveryNodes.builder().add(discoveryNode).localNodeId(discoveryNode.getId()).build(); - final DiscoveryNodes localClusterManager = DiscoveryNodes.builder(noClusterManager).masterNodeId(discoveryNode.getId()).build(); + final DiscoveryNodes localClusterManager = DiscoveryNodes.builder(noClusterManager) + .clusterManagerNodeId(discoveryNode.getId()) + .build(); final Settings.Builder settingsBuilder = Settings.builder().put(Node.NODE_NAME_SETTING.getKey(), discoveryNode.getName()); if (randomBoolean()) { diff --git a/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java b/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java index 2278d09722fe2..7325024138500 100644 --- a/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java +++ b/server/src/test/java/org/opensearch/cluster/action/index/MappingUpdatedActionTests.java @@ -130,13 +130,13 @@ protected void sendUpdateMapping(Index index, Mapping mappingUpdate, ActionListe }; PlainActionFuture fut1 = new PlainActionFuture<>(); - mua.updateMappingOnMaster(null, null, fut1); + mua.updateMappingOnClusterManager(null, null, fut1); assertEquals(1, inFlightListeners.size()); assertEquals(0, mua.blockedThreads()); PlainActionFuture fut2 = new PlainActionFuture<>(); Thread thread = new Thread(() -> { - mua.updateMappingOnMaster(null, null, fut2); // blocked + mua.updateMappingOnClusterManager(null, null, fut2); // blocked }); thread.start(); assertBusy(() -> assertEquals(1, mua.blockedThreads())); diff --git a/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java b/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java index a61d878d90c7c..2138f28f7b8c2 100644 --- a/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java +++ b/server/src/test/java/org/opensearch/cluster/action/shard/ShardStateActionTests.java @@ -197,7 +197,7 @@ public void testSuccess() throws InterruptedException { assertEquals(shardEntry.shardId, shardRouting.shardId()); assertEquals(shardEntry.allocationId, shardRouting.allocationId().getId()); // sent to the cluster-manager - assertEquals(clusterService.state().nodes().getMasterNode().getId(), capturedRequests[0].node.getId()); + assertEquals(clusterService.state().nodes().getClusterManagerNode().getId(), capturedRequests[0].node.getId()); transport.handleResponse(capturedRequests[0].requestId, TransportResponse.Empty.INSTANCE); @@ -211,7 +211,7 @@ public void testNoClusterManager() throws InterruptedException { setState(clusterService, ClusterStateCreationUtils.stateWithActivePrimary(index, true, randomInt(5))); DiscoveryNodes.Builder noClusterManagerBuilder = DiscoveryNodes.builder(clusterService.state().nodes()); - noClusterManagerBuilder.masterNodeId(null); + noClusterManagerBuilder.clusterManagerNodeId(null); setState(clusterService, ClusterState.builder(clusterService.state()).nodes(noClusterManagerBuilder)); CountDownLatch latch = new CountDownLatch(1); @@ -504,7 +504,9 @@ private void setUpClusterManagerRetryVerification( ) { shardStateAction.setOnBeforeWaitForNewClusterManagerAndRetry(() -> { DiscoveryNodes.Builder clusterManagerBuilder = DiscoveryNodes.builder(clusterService.state().nodes()); - clusterManagerBuilder.masterNodeId(clusterService.state().nodes().getMasterNodes().iterator().next().value.getId()); + clusterManagerBuilder.clusterManagerNodeId( + clusterService.state().nodes().getClusterManagerNodes().iterator().next().value.getId() + ); setState(clusterService, ClusterState.builder(clusterService.state()).nodes(clusterManagerBuilder)); }); diff --git a/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java b/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java index b9ae08775d11a..81fbaf5fce8c0 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/CoordinatorTests.java @@ -170,7 +170,7 @@ public void testDoesNotElectNonClusterManagerNode() { cluster.stabilise(); final ClusterNode leader = cluster.getAnyLeader(); - assertTrue(leader.getLocalNode().isMasterNode()); + assertTrue(leader.getLocalNode().isClusterManagerNode()); } } @@ -1729,7 +1729,7 @@ public void testDoesNotPerformElectionWhenRestartingFollower() { final ClusterNode leader = cluster.getAnyLeader(); final long expectedTerm = leader.coordinator.getCurrentTerm(); - if (cluster.clusterNodes.stream().filter(n -> n.getLocalNode().isMasterNode()).count() == 2) { + if (cluster.clusterNodes.stream().filter(n -> n.getLocalNode().isClusterManagerNode()).count() == 2) { // in the 2-node case, auto-shrinking the voting configuration is required to reduce the voting configuration down to just // the leader, otherwise restarting the other cluster-manager-eligible node triggers an election leader.submitSetAutoShrinkVotingConfiguration(true); diff --git a/server/src/test/java/org/opensearch/cluster/coordination/FollowersCheckerTests.java b/server/src/test/java/org/opensearch/cluster/coordination/FollowersCheckerTests.java index d5947bf444d17..5bbbed5f4f8c0 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/FollowersCheckerTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/FollowersCheckerTests.java @@ -713,7 +713,7 @@ public void testPreferClusterManagerNodes() { .map(cr -> cr.node) .collect(Collectors.toList()); List sortedFollowerTargets = new ArrayList<>(followerTargets); - Collections.sort(sortedFollowerTargets, Comparator.comparing(n -> n.isMasterNode() == false)); + Collections.sort(sortedFollowerTargets, Comparator.comparing(n -> n.isClusterManagerNode() == false)); assertEquals(sortedFollowerTargets, followerTargets); } diff --git a/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java b/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java index ddf5ce39a6a18..479dbc3835b2f 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/JoinTaskExecutorTests.java @@ -189,7 +189,7 @@ public void testUpdatesNodeWithNewRoles() throws Exception { DiscoveryNodes.builder() .add(clusterManagerNode) .localNodeId(clusterManagerNode.getId()) - .masterNodeId(clusterManagerNode.getId()) + .clusterManagerNodeId(clusterManagerNode.getId()) .add(bwcNode) ) .build(); @@ -282,12 +282,12 @@ public void testUpdatesNodeWithOpenSearchVersionForExistingAndNewNodes() throws } /** - * 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(); - assertThat(joinTaskOfMaster.isBecomeMasterTask(), is(true)); + assertThat(joinTaskOfMaster.isBecomeClusterManagerTask(), is(true)); JoinTaskExecutor.Task joinTaskOfClusterManager = JoinTaskExecutor.newBecomeClusterManagerTask(); - assertThat(joinTaskOfClusterManager.isBecomeMasterTask(), is(true)); + assertThat(joinTaskOfClusterManager.isBecomeClusterManagerTask(), is(true)); } } diff --git a/server/src/test/java/org/opensearch/cluster/coordination/LeaderCheckerTests.java b/server/src/test/java/org/opensearch/cluster/coordination/LeaderCheckerTests.java index b06799312d99a..6a93f05803484 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/LeaderCheckerTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/LeaderCheckerTests.java @@ -453,7 +453,7 @@ public void testLeaderBehaviour() { final DiscoveryNodes discoveryNodes = DiscoveryNodes.builder() .add(localNode) .localNodeId(localNode.getId()) - .masterNodeId(localNode.getId()) + .clusterManagerNodeId(localNode.getId()) .build(); { @@ -498,7 +498,7 @@ public void testLeaderBehaviour() { } { - leaderChecker.setCurrentNodes(DiscoveryNodes.builder(discoveryNodes).add(otherNode).masterNodeId(null).build()); + leaderChecker.setCurrentNodes(DiscoveryNodes.builder(discoveryNodes).add(otherNode).clusterManagerNodeId(null).build()); final CapturingTransportResponseHandler handler = new CapturingTransportResponseHandler(); transportService.sendRequest(localNode, LEADER_CHECK_ACTION_NAME, new LeaderCheckRequest(otherNode), handler); diff --git a/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java b/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java index 806468ed5e761..8e81a3043426f 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/NodeJoinTests.java @@ -336,17 +336,17 @@ public void testJoinWithHigherTermElectsLeader() { () -> new StatusInfo(HEALTHY, "healthy-info") ); assertFalse(isLocalNodeElectedMaster()); - assertNull(coordinator.getStateForClusterManagerService().nodes().getMasterNodeId()); + assertNull(coordinator.getStateForClusterManagerService().nodes().getClusterManagerNodeId()); long newTerm = initialTerm + randomLongBetween(1, 10); SimpleFuture fut = joinNodeAsync( new JoinRequest(node1, newTerm, Optional.of(new Join(node1, node0, newTerm, initialTerm, initialVersion))) ); assertEquals(Coordinator.Mode.LEADER, coordinator.getMode()); - assertNull(coordinator.getStateForClusterManagerService().nodes().getMasterNodeId()); + assertNull(coordinator.getStateForClusterManagerService().nodes().getClusterManagerNodeId()); deterministicTaskQueue.runAllRunnableTasks(); assertTrue(fut.isDone()); assertTrue(isLocalNodeElectedMaster()); - assertTrue(coordinator.getStateForClusterManagerService().nodes().isLocalNodeElectedMaster()); + assertTrue(coordinator.getStateForClusterManagerService().nodes().isLocalNodeElectedClusterManager()); } public void testJoinWithHigherTermButBetterStateGetsRejected() { diff --git a/server/src/test/java/org/opensearch/cluster/coordination/PublicationTests.java b/server/src/test/java/org/opensearch/cluster/coordination/PublicationTests.java index 3e86ec11ae7b3..517456f54b785 100644 --- a/server/src/test/java/org/opensearch/cluster/coordination/PublicationTests.java +++ b/server/src/test/java/org/opensearch/cluster/coordination/PublicationTests.java @@ -462,7 +462,7 @@ public void testPublishingToClusterManagersFirst() { List publicationTargets = new ArrayList<>(publication.pendingPublications.keySet()); List sortedPublicationTargets = new ArrayList<>(publicationTargets); - Collections.sort(sortedPublicationTargets, Comparator.comparing(n -> n.isMasterNode() == false)); + Collections.sort(sortedPublicationTargets, Comparator.comparing(n -> n.isClusterManagerNode() == false)); assertEquals(sortedPublicationTargets, publicationTargets); } diff --git a/server/src/test/java/org/opensearch/cluster/health/ClusterStateHealthTests.java b/server/src/test/java/org/opensearch/cluster/health/ClusterStateHealthTests.java index bd856d5c41ace..80e76d44b9c41 100644 --- a/server/src/test/java/org/opensearch/cluster/health/ClusterStateHealthTests.java +++ b/server/src/test/java/org/opensearch/cluster/health/ClusterStateHealthTests.java @@ -144,7 +144,7 @@ public void testClusterHealthWaitsForClusterStateApplication() throws Interrupte setState( clusterService, ClusterState.builder(clusterService.state()) - .nodes(DiscoveryNodes.builder(clusterService.state().nodes()).masterNodeId(null)) + .nodes(DiscoveryNodes.builder(clusterService.state().nodes()).clusterManagerNodeId(null)) .build() ); @@ -163,7 +163,7 @@ public void testClusterHealthWaitsForClusterStateApplication() throws Interrupte .onNewClusterState( "restore cluster-manager", () -> ClusterState.builder(currentState) - .nodes(DiscoveryNodes.builder(currentState.nodes()).masterNodeId(currentState.nodes().getLocalNodeId())) + .nodes(DiscoveryNodes.builder(currentState.nodes()).clusterManagerNodeId(currentState.nodes().getLocalNodeId())) .build(), (source, e) -> {} ); @@ -219,7 +219,10 @@ public void testClusterHealth() throws IOException { ClusterStateHealth clusterStateHealth = new ClusterStateHealth(clusterState, concreteIndices); logger.info("cluster status: {}, expected {}", clusterStateHealth.getStatus(), counter.status()); clusterStateHealth = maybeSerialize(clusterStateHealth); - assertThat(clusterStateHealth.hasDiscoveredMaster(), equalTo(clusterService.state().nodes().getMasterNodeId() != null)); + assertThat( + clusterStateHealth.hasDiscoveredClusterManager(), + equalTo(clusterService.state().nodes().getClusterManagerNodeId() != null) + ); assertClusterHealth(clusterStateHealth, counter); } diff --git a/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java b/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java index 7497a9ce75460..d06ec8a32e552 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/AutoExpandReplicasTests.java @@ -190,7 +190,7 @@ public void testAutoExpandWhenNodeLeavesAndPossiblyRejoins() throws InterruptedE assertThat(postTable.toString(), postTable.getAllAllocationIds(), everyItem(is(in(preTable.getAllAllocationIds())))); } else { // fake an election where conflicting nodes are removed and readded - state = ClusterState.builder(state).nodes(DiscoveryNodes.builder(state.nodes()).masterNodeId(null).build()).build(); + state = ClusterState.builder(state).nodes(DiscoveryNodes.builder(state.nodes()).clusterManagerNodeId(null).build()).build(); List conflictingNodes = randomSubsetOf(2, dataNodes); unchangedNodeIds = dataNodes.stream() @@ -215,7 +215,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); } diff --git a/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java b/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java index 1e52fa380793e..d3e47c3e42f25 100644 --- a/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/metadata/TemplateUpgradeServiceTests.java @@ -367,7 +367,7 @@ public void clusterChanged(ClusterChangedEvent event) { new DiscoveryNode("node1", "node1", buildNewFakeTransportAddress(), emptyMap(), MASTER_DATA_ROLES, Version.CURRENT) ) .localNodeId("node1") - .masterNodeId("node1") + .clusterManagerNodeId("node1") .build() ) .metadata(metadata) diff --git a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java index 55c518c62973e..630902f94d335 100644 --- a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java +++ b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodeRoleSettingTests.java @@ -58,11 +58,11 @@ public void testIsIngestNode() { public void testIsMasterNode() { // It's used to add MASTER_ROLE into 'roleMap', because MASTER_ROLE is removed from DiscoveryNodeRole.BUILT_IN_ROLES in 2.0. DiscoveryNode.setAdditionalRoles(Collections.emptySet()); - runRoleTest(DiscoveryNode::isMasterNode, DiscoveryNodeRole.MASTER_ROLE); + runRoleTest(DiscoveryNode::isClusterManagerNode, DiscoveryNodeRole.MASTER_ROLE); } public void testIsClusterManagerNode() { - runRoleTest(DiscoveryNode::isMasterNode, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); + runRoleTest(DiscoveryNode::isClusterManagerNode, DiscoveryNodeRole.CLUSTER_MANAGER_ROLE); } public void testIsRemoteClusterClient() { diff --git a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java index 80c7d8c9417fe..0d87981e60681 100644 --- a/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java +++ b/server/src/test/java/org/opensearch/cluster/node/DiscoveryNodesTests.java @@ -110,7 +110,7 @@ public void testAll() { final String[] nonClusterManagerNodes = StreamSupport.stream(discoveryNodes.getNodes().values().spliterator(), false) .map(n -> n.value) - .filter(n -> n.isMasterNode() == false) + .filter(n -> n.isClusterManagerNode() == false) .map(DiscoveryNode::getId) .toArray(String[]::new); assertThat(discoveryNodes.resolveNodes("_all", "cluster_manager:false"), arrayContainingInAnyOrder(nonClusterManagerNodes)); @@ -123,13 +123,13 @@ public void testCoordinatorOnlyNodes() { final String[] coordinatorOnlyNodes = StreamSupport.stream(discoveryNodes.getNodes().values().spliterator(), false) .map(n -> n.value) - .filter(n -> n.isDataNode() == false && n.isIngestNode() == false && n.isMasterNode() == false) + .filter(n -> n.isDataNode() == false && n.isIngestNode() == false && n.isClusterManagerNode() == false) .map(DiscoveryNode::getId) .toArray(String[]::new); final String[] nonCoordinatorOnlyNodes = StreamSupport.stream(discoveryNodes.getNodes().values().spliterator(), false) .map(n -> n.value) - .filter(n -> n.isMasterNode() || n.isDataNode() || n.isIngestNode()) + .filter(n -> n.isClusterManagerNode() || n.isDataNode() || n.isIngestNode()) .map(DiscoveryNode::getId) .toArray(String[]::new); @@ -179,11 +179,11 @@ public void testClusterManagersFirst() { final List inputNodes = randomNodes(10); final DiscoveryNodes.Builder discoBuilder = DiscoveryNodes.builder(); inputNodes.forEach(discoBuilder::add); - final List returnedNodes = discoBuilder.build().mastersFirstStream().collect(Collectors.toList()); + final List returnedNodes = discoBuilder.build().clusterManagersFirstStream().collect(Collectors.toList()); assertEquals(returnedNodes.size(), inputNodes.size()); assertEquals(new HashSet<>(returnedNodes), new HashSet<>(inputNodes)); final List sortedNodes = new ArrayList<>(returnedNodes); - Collections.sort(sortedNodes, Comparator.comparing(n -> n.isMasterNode() == false)); + Collections.sort(sortedNodes, Comparator.comparing(n -> n.isClusterManagerNode() == false)); assertEquals(sortedNodes, returnedNodes); } @@ -260,13 +260,13 @@ public void testDeltas() { DiscoveryNodes.Builder builderA = DiscoveryNodes.builder(); nodesA.stream().forEach(builderA::add); final String clusterManagerAId = clusterManagerA == null ? null : clusterManagerA.getId(); - builderA.masterNodeId(clusterManagerAId); + builderA.clusterManagerNodeId(clusterManagerAId); builderA.localNodeId(RandomPicks.randomFrom(random(), nodesA).getId()); DiscoveryNodes.Builder builderB = DiscoveryNodes.builder(); nodesB.stream().forEach(builderB::add); final String clusterManagerBId = clusterManagerB == null ? null : clusterManagerB.getId(); - builderB.masterNodeId(clusterManagerBId); + builderB.clusterManagerNodeId(clusterManagerBId); builderB.localNodeId(RandomPicks.randomFrom(random(), nodesB).getId()); final DiscoveryNodes discoNodesA = builderA.build(); @@ -282,15 +282,15 @@ public void testDeltas() { assertThat(delta.previousClusterManagerNode().getId(), equalTo(clusterManagerAId)); } if (clusterManagerB == null) { - assertThat(delta.newMasterNode(), nullValue()); + assertThat(delta.newClusterManagerNode(), nullValue()); } else { - assertThat(delta.newMasterNode().getId(), equalTo(clusterManagerBId)); + assertThat(delta.newClusterManagerNode().getId(), equalTo(clusterManagerBId)); } if (Objects.equals(clusterManagerAId, clusterManagerBId)) { - assertFalse(delta.masterNodeChanged()); + assertFalse(delta.clusterManagerNodeChanged()); } else { - assertTrue(delta.masterNodeChanged()); + assertTrue(delta.clusterManagerNodeChanged()); } Set newNodes = new HashSet<>(nodesB); @@ -316,13 +316,13 @@ public void testDeprecatedMasterNodeFilter() { final String[] clusterManagerNodes = StreamSupport.stream(discoveryNodes.getNodes().values().spliterator(), false) .map(n -> n.value) - .filter(n -> n.isMasterNode() == true) + .filter(n -> n.isClusterManagerNode() == true) .map(DiscoveryNode::getId) .toArray(String[]::new); final String[] nonClusterManagerNodes = StreamSupport.stream(discoveryNodes.getNodes().values().spliterator(), false) .map(n -> n.value) - .filter(n -> n.isMasterNode() == false) + .filter(n -> n.isClusterManagerNode() == false) .map(DiscoveryNode::getId) .toArray(String[]::new); @@ -366,7 +366,7 @@ private static DiscoveryNodes buildDiscoveryNodes() { discoBuilder = discoBuilder.add(node); } discoBuilder.localNodeId(randomFrom(nodesList).getId()); - discoBuilder.masterNodeId(randomFrom(nodesList).getId()); + discoBuilder.clusterManagerNodeId(randomFrom(nodesList).getId()); return discoBuilder.build(); } @@ -384,7 +384,7 @@ Set matchingNodeIds(DiscoveryNodes nodes) { ELECTED_MASTER("_master") { @Override Set matchingNodeIds(DiscoveryNodes nodes) { - return Collections.singleton(nodes.getMasterNodeId()); + return Collections.singleton(nodes.getClusterManagerNodeId()); } }, // TODO: Remove this element after removing DiscoveryNodeRole.MASTER_ROLE @@ -392,7 +392,7 @@ Set matchingNodeIds(DiscoveryNodes nodes) { @Override Set matchingNodeIds(DiscoveryNodes nodes) { Set ids = new HashSet<>(); - nodes.getMasterNodes().keysIt().forEachRemaining(ids::add); + nodes.getClusterManagerNodes().keysIt().forEachRemaining(ids::add); return ids; } }, @@ -400,7 +400,7 @@ Set matchingNodeIds(DiscoveryNodes nodes) { @Override Set matchingNodeIds(DiscoveryNodes nodes) { Set ids = new HashSet<>(); - nodes.getMasterNodes().keysIt().forEachRemaining(ids::add); + nodes.getClusterManagerNodes().keysIt().forEachRemaining(ids::add); return ids; } }, @@ -495,7 +495,7 @@ public void testMaxMinNodeVersion() { ) ); discoBuilder.localNodeId("name_1"); - discoBuilder.masterNodeId("name_2"); + discoBuilder.clusterManagerNodeId("name_2"); DiscoveryNodes build = discoBuilder.build(); assertEquals(Version.fromString("1.1.0"), build.getMaxNodeVersion()); assertEquals(LegacyESVersion.fromString("5.1.0"), build.getMinNodeVersion()); @@ -523,7 +523,7 @@ public void testNodeExistsWithBWCVersion() { discoBuilder.add(node_2); discoBuilder.localNodeId("name_1"); - discoBuilder.masterNodeId("name_2"); + discoBuilder.clusterManagerNodeId("name_2"); DiscoveryNodes build = discoBuilder.build(); assertTrue(build.nodeExistsWithBWCVersion(buildDiscoveryNodeFromExisting(node_1, Version.CURRENT))); assertFalse(build.nodeExistsWithBWCVersion(buildDiscoveryNodeFromExisting(node_2, LegacyESVersion.fromString("7.10.2")))); diff --git a/server/src/test/java/org/opensearch/cluster/routing/BatchedRerouteServiceTests.java b/server/src/test/java/org/opensearch/cluster/routing/BatchedRerouteServiceTests.java index 2f6d34e1eb204..241ee3fca3553 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/BatchedRerouteServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/BatchedRerouteServiceTests.java @@ -237,7 +237,10 @@ public void testNotifiesOnFailure() throws InterruptedException { clusterService.getClusterApplierService().onNewClusterState("simulated", () -> { ClusterState state = clusterService.state(); return ClusterState.builder(state) - .nodes(DiscoveryNodes.builder(state.nodes()).masterNodeId(randomBoolean() ? null : state.nodes().getLocalNodeId())) + .nodes( + DiscoveryNodes.builder(state.nodes()) + .clusterManagerNodeId(randomBoolean() ? null : state.nodes().getLocalNodeId()) + ) .build(); }, (source, e) -> {}); } diff --git a/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java b/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java index 635dfe409058a..a3878f5cbeb25 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/DelayedAllocationServiceTests.java @@ -108,7 +108,7 @@ public void testNoDelayedUnassigned() throws Exception { .routingTable(RoutingTable.builder().addAsNew(metadata.index("test")).build()) .build(); clusterState = ClusterState.builder(clusterState) - .nodes(DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2")).localNodeId("node1").masterNodeId("node1")) + .nodes(DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2")).localNodeId("node1").clusterManagerNodeId("node1")) .build(); clusterState = allocationService.reroute(clusterState, "reroute"); // starting primaries @@ -154,7 +154,7 @@ public void testDelayedUnassignedScheduleReroute() throws Exception { .routingTable(RoutingTable.builder().addAsNew(metadata.index("test")).build()) .build(); clusterState = ClusterState.builder(clusterState) - .nodes(DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2")).localNodeId("node1").masterNodeId("node1")) + .nodes(DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2")).localNodeId("node1").clusterManagerNodeId("node1")) .build(); final long baseTimestampNanos = System.nanoTime(); allocationService.setNanoTimeOverride(baseTimestampNanos); @@ -264,7 +264,7 @@ public void testDelayedUnassignedScheduleRerouteAfterDelayedReroute() throws Exc DiscoveryNodes.builder() .add(newNode("node0", singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))) .localNodeId("node0") - .masterNodeId("node0") + .clusterManagerNodeId("node0") .add(newNode("node1")) .add(newNode("node2")) .add(newNode("node3")) @@ -449,7 +449,7 @@ public void testDelayedUnassignedScheduleRerouteRescheduledOnShorterDelay() thro .add(newNode("node3")) .add(newNode("node4")) .localNodeId("node1") - .masterNodeId("node1") + .clusterManagerNodeId("node1") ) .build(); final long nodeLeftTimestampNanos = System.nanoTime(); @@ -556,7 +556,7 @@ private TestDelayAllocationService(ThreadPool threadPool, ClusterService cluster } @Override - protected void assertClusterOrMasterStateThread() { + protected void assertClusterOrClusterManagerStateThread() { // do not check this in the unit tests } diff --git a/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java b/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java index 1a047b3ccd9da..4c0bdb2c900c7 100644 --- a/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java +++ b/server/src/test/java/org/opensearch/cluster/routing/allocation/decider/RestoreInProgressAllocationDeciderTests.java @@ -201,7 +201,7 @@ private ClusterState createInitialClusterState() { DiscoveryNodes discoveryNodes = DiscoveryNodes.builder() .add(newNode("cluster-manager", Collections.singleton(DiscoveryNodeRole.CLUSTER_MANAGER_ROLE))) .localNodeId("cluster-manager") - .masterNodeId("cluster-manager") + .clusterManagerNodeId("cluster-manager") .build(); ClusterState clusterState = ClusterState.builder(ClusterName.DEFAULT) @@ -230,7 +230,7 @@ private Decision executeAllocation(final ClusterState clusterState, final ShardR if (randomBoolean()) { decision = decider.canAllocate(shardRouting, allocation); } else { - DiscoveryNode node = clusterState.getNodes().getMasterNode(); + DiscoveryNode node = clusterState.getNodes().getClusterManagerNode(); decision = decider.canAllocate(shardRouting, new RoutingNode(node.getId(), node), allocation); } return decision; diff --git a/server/src/test/java/org/opensearch/cluster/serialization/ClusterSerializationTests.java b/server/src/test/java/org/opensearch/cluster/serialization/ClusterSerializationTests.java index 83e99475dc6a4..05a9fb272fbac 100644 --- a/server/src/test/java/org/opensearch/cluster/serialization/ClusterSerializationTests.java +++ b/server/src/test/java/org/opensearch/cluster/serialization/ClusterSerializationTests.java @@ -85,7 +85,7 @@ public void testClusterStateSerialization() throws Exception { .add(newNode("node2")) .add(newNode("node3")) .localNodeId("node1") - .masterNodeId("node2") + .clusterManagerNodeId("node2") .build(); ClusterState clusterState = ClusterState.builder(new ClusterName("clusterName1")) diff --git a/server/src/test/java/org/opensearch/cluster/serialization/ClusterStateToStringTests.java b/server/src/test/java/org/opensearch/cluster/serialization/ClusterStateToStringTests.java index b2e9b8ddb9ea7..f16a1eda2f34d 100644 --- a/server/src/test/java/org/opensearch/cluster/serialization/ClusterStateToStringTests.java +++ b/server/src/test/java/org/opensearch/cluster/serialization/ClusterStateToStringTests.java @@ -67,7 +67,7 @@ public void testClusterStateSerialization() throws Exception { DiscoveryNodes nodes = DiscoveryNodes.builder() .add(new DiscoveryNode("node_foo", buildNewFakeTransportAddress(), emptyMap(), emptySet(), Version.CURRENT)) .localNodeId("node_foo") - .masterNodeId("node_foo") + .clusterManagerNodeId("node_foo") .build(); ClusterState clusterState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY)) diff --git a/server/src/test/java/org/opensearch/cluster/service/ClusterApplierServiceTests.java b/server/src/test/java/org/opensearch/cluster/service/ClusterApplierServiceTests.java index a603dac9f42ca..830a7d2a557f2 100644 --- a/server/src/test/java/org/opensearch/cluster/service/ClusterApplierServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/service/ClusterApplierServiceTests.java @@ -119,7 +119,7 @@ private TimedClusterApplierService createTimedClusterService(boolean makeCluster DiscoveryNodes.builder() .add(localNode) .localNodeId(localNode.getId()) - .masterNodeId(makeClusterManager ? localNode.getId() : null) + .clusterManagerNodeId(makeClusterManager ? localNode.getId() : null) ) .blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK) .build() @@ -297,7 +297,7 @@ public void testLocalNodeClusterManagerListenerCallbacks() { TimedClusterApplierService timedClusterApplierService = createTimedClusterService(false); AtomicBoolean isClusterManager = new AtomicBoolean(); - timedClusterApplierService.addLocalNodeMasterListener(new LocalNodeClusterManagerListener() { + timedClusterApplierService.addLocalNodeClusterManagerListener(new LocalNodeClusterManagerListener() { @Override public void onMaster() { isClusterManager.set(true); @@ -311,20 +311,20 @@ public void offMaster() { ClusterState state = timedClusterApplierService.state(); DiscoveryNodes nodes = state.nodes(); - DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(nodes).masterNodeId(nodes.getLocalNodeId()); + DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder(nodes).clusterManagerNodeId(nodes.getLocalNodeId()); state = ClusterState.builder(state).blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK).nodes(nodesBuilder).build(); setState(timedClusterApplierService, state); assertThat(isClusterManager.get(), is(true)); nodes = state.nodes(); - nodesBuilder = DiscoveryNodes.builder(nodes).masterNodeId(null); + nodesBuilder = DiscoveryNodes.builder(nodes).clusterManagerNodeId(null); state = ClusterState.builder(state) .blocks(ClusterBlocks.builder().addGlobalBlock(NoClusterManagerBlockService.NO_MASTER_BLOCK_WRITES)) .nodes(nodesBuilder) .build(); setState(timedClusterApplierService, state); assertThat(isClusterManager.get(), is(false)); - nodesBuilder = DiscoveryNodes.builder(nodes).masterNodeId(nodes.getLocalNodeId()); + nodesBuilder = DiscoveryNodes.builder(nodes).clusterManagerNodeId(nodes.getLocalNodeId()); state = ClusterState.builder(state).blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK).nodes(nodesBuilder).build(); setState(timedClusterApplierService, state); assertThat(isClusterManager.get(), is(true)); diff --git a/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java b/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java index c829bef576be5..8827064974a19 100644 --- a/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java +++ b/server/src/test/java/org/opensearch/cluster/service/MasterServiceTests.java @@ -136,7 +136,7 @@ private MasterService createClusterManagerService(boolean makeClusterManager) { DiscoveryNodes.builder() .add(localNode) .localNodeId(localNode.getId()) - .masterNodeId(makeClusterManager ? localNode.getId() : null) + .clusterManagerNodeId(makeClusterManager ? localNode.getId() : null) ) .blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK) .build(); diff --git a/server/src/test/java/org/opensearch/discovery/AbstractDisruptionTestCase.java b/server/src/test/java/org/opensearch/discovery/AbstractDisruptionTestCase.java index 307edc2f03075..fda1e0022c754 100644 --- a/server/src/test/java/org/opensearch/discovery/AbstractDisruptionTestCase.java +++ b/server/src/test/java/org/opensearch/discovery/AbstractDisruptionTestCase.java @@ -167,7 +167,10 @@ void assertNoClusterManager(final String node, @Nullable final ClusterBlock expe assertBusy(() -> { ClusterState state = getNodeClusterState(node); final DiscoveryNodes nodes = state.nodes(); - assertNull("node [" + node + "] still has [" + nodes.getMasterNode() + "] as cluster-manager", nodes.getMasterNode()); + assertNull( + "node [" + node + "] still has [" + nodes.getClusterManagerNode() + "] as cluster-manager", + nodes.getClusterManagerNode() + ); if (expectedBlocks != null) { for (ClusterBlockLevel level : expectedBlocks.levels()) { assertTrue( @@ -183,10 +186,10 @@ void assertDifferentClusterManager(final String node, final String oldClusterMan assertBusy(() -> { ClusterState state = getNodeClusterState(node); String clusterManagerNode = null; - if (state.nodes().getMasterNode() != null) { - clusterManagerNode = state.nodes().getMasterNode().getName(); + if (state.nodes().getClusterManagerNode() != null) { + clusterManagerNode = state.nodes().getClusterManagerNode().getName(); } - logger.trace("[{}] cluster-manager is [{}]", node, state.nodes().getMasterNode()); + logger.trace("[{}] cluster-manager is [{}]", node, state.nodes().getClusterManagerNode()); assertThat( "node [" + node + "] still has [" + clusterManagerNode + "] as cluster-manager", oldClusterManagerNode, @@ -201,7 +204,9 @@ void assertClusterManager(String clusterManagerNode, List nodes) throws ClusterState state = getNodeClusterState(node); String failMsgSuffix = "cluster_state:\n" + state; assertThat("wrong node count on [" + node + "]. " + failMsgSuffix, state.nodes().getSize(), equalTo(nodes.size())); - String otherClusterManagerNodeName = state.nodes().getMasterNode() != null ? state.nodes().getMasterNode().getName() : null; + String otherClusterManagerNodeName = state.nodes().getClusterManagerNode() != null + ? state.nodes().getClusterManagerNode().getName() + : null; assertThat( "wrong cluster-manager on node [" + node + "]. " + failMsgSuffix, otherClusterManagerNodeName, diff --git a/server/src/test/java/org/opensearch/discovery/PeerFinderMessagesTests.java b/server/src/test/java/org/opensearch/discovery/PeerFinderMessagesTests.java index a274760872e88..bcf41ebf65a04 100644 --- a/server/src/test/java/org/opensearch/discovery/PeerFinderMessagesTests.java +++ b/server/src/test/java/org/opensearch/discovery/PeerFinderMessagesTests.java @@ -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 { @@ -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); } } } diff --git a/server/src/test/java/org/opensearch/discovery/PeerFinderTests.java b/server/src/test/java/org/opensearch/discovery/PeerFinderTests.java index 2f78e60631ec2..5e7dede0309c6 100644 --- a/server/src/test/java/org/opensearch/discovery/PeerFinderTests.java +++ b/server/src/test/java/org/opensearch/discovery/PeerFinderTests.java @@ -140,7 +140,7 @@ public void run() { for (final Map.Entry addressAndNode : reachableNodes.entrySet()) { if (addressAndNode.getKey().equals(transportAddress)) { final DiscoveryNode discoveryNode = addressAndNode.getValue(); - if (discoveryNode.isMasterNode()) { + if (discoveryNode.isClusterManagerNode()) { disconnectedNodes.remove(discoveryNode); connectedNodes.add(discoveryNode); assertTrue(inFlightConnectionAttempts.remove(transportAddress)); @@ -477,7 +477,7 @@ public void testRespondsToRequestWhenActive() { peerFinder.activate(lastAcceptedNodes); final PeersResponse peersResponse1 = peerFinder.handlePeersRequest(new PeersRequest(sourceNode, Collections.emptyList())); - assertFalse(peersResponse1.getMasterNode().isPresent()); + assertFalse(peersResponse1.getClusterManagerNode().isPresent()); assertThat(peersResponse1.getKnownPeers(), empty()); // sourceNode is not yet known assertThat(peersResponse1.getTerm(), is(0L)); @@ -488,7 +488,7 @@ public void testRespondsToRequestWhenActive() { final long updatedTerm = randomNonNegativeLong(); peerFinder.setCurrentTerm(updatedTerm); final PeersResponse peersResponse2 = peerFinder.handlePeersRequest(new PeersRequest(sourceNode, Collections.emptyList())); - assertFalse(peersResponse2.getMasterNode().isPresent()); + assertFalse(peersResponse2.getClusterManagerNode().isPresent()); assertThat(peersResponse2.getKnownPeers(), contains(sourceNode)); assertThat(peersResponse2.getTerm(), is(updatedTerm)); } @@ -531,7 +531,7 @@ public PeersResponse read(StreamInput in) throws IOException { @Override public void handleResponse(PeersResponse response) { assertTrue(responseReceived.compareAndSet(false, true)); - assertFalse(response.getMasterNode().isPresent()); + assertFalse(response.getClusterManagerNode().isPresent()); assertThat(response.getKnownPeers(), empty()); // sourceNode is not yet known assertThat(response.getTerm(), is(0L)); } diff --git a/server/src/test/java/org/opensearch/gateway/GatewayServiceTests.java b/server/src/test/java/org/opensearch/gateway/GatewayServiceTests.java index 51ba096a86ae0..ba0268b627b95 100644 --- a/server/src/test/java/org/opensearch/gateway/GatewayServiceTests.java +++ b/server/src/test/java/org/opensearch/gateway/GatewayServiceTests.java @@ -135,7 +135,7 @@ public void testRecoverStateUpdateTask() throws Exception { nodeId ); ClusterState stateWithBlock = ClusterState.builder(ClusterName.DEFAULT) - .nodes(DiscoveryNodes.builder().localNodeId(nodeId).masterNodeId(nodeId).add(clusterManagerNode).build()) + .nodes(DiscoveryNodes.builder().localNodeId(nodeId).clusterManagerNodeId(nodeId).add(clusterManagerNode).build()) .blocks(ClusterBlocks.builder().addGlobalBlock(STATE_NOT_RECOVERED_BLOCK).build()) .build(); diff --git a/server/src/test/java/org/opensearch/gateway/IncrementalClusterStateWriterTests.java b/server/src/test/java/org/opensearch/gateway/IncrementalClusterStateWriterTests.java index 00ca35207620d..33a5bc5671894 100644 --- a/server/src/test/java/org/opensearch/gateway/IncrementalClusterStateWriterTests.java +++ b/server/src/test/java/org/opensearch/gateway/IncrementalClusterStateWriterTests.java @@ -188,7 +188,7 @@ private DiscoveryNodes.Builder generateDiscoveryNodes(boolean clusterManagerElig .add(newNode("node1", clusterManagerEligible ? CLUSTER_MANAGER_DATA_ROLES : dataOnlyRoles)) .add(newNode("cluster_manager_node", CLUSTER_MANAGER_DATA_ROLES)) .localNodeId("node1") - .masterNodeId(clusterManagerEligible ? "node1" : "cluster_manager_node"); + .clusterManagerNodeId(clusterManagerEligible ? "node1" : "cluster_manager_node"); } private IndexMetadata createIndexMetadata(String name) { diff --git a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java index d8d7be154b6b2..8ffd9af7e653d 100644 --- a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java @@ -2654,7 +2654,7 @@ public void testSeqNoAndCheckpoints() throws IOException, InterruptedException { ); ReplicationTracker gcpTracker = (ReplicationTracker) initialEngine.config().getGlobalCheckpointSupplier(); - gcpTracker.updateFromMaster( + gcpTracker.updateFromClusterManager( 1L, new HashSet<>(Collections.singletonList(primary.allocationId().getId())), new IndexShardRoutingTable.Builder(shardId).addShard(primary).build() @@ -2669,7 +2669,7 @@ public void testSeqNoAndCheckpoints() throws IOException, InterruptedException { ); countDownLatch.await(); } - gcpTracker.updateFromMaster( + gcpTracker.updateFromClusterManager( 2L, new HashSet<>(Collections.singletonList(primary.allocationId().getId())), new IndexShardRoutingTable.Builder(shardId).addShard(primary).addShard(initializingReplica).build() @@ -2677,7 +2677,7 @@ public void testSeqNoAndCheckpoints() throws IOException, InterruptedException { gcpTracker.initiateTracking(initializingReplica.allocationId().getId()); gcpTracker.markAllocationIdAsInSync(initializingReplica.allocationId().getId(), replicaLocalCheckpoint); final ShardRouting replica = initializingReplica.moveToStarted(); - gcpTracker.updateFromMaster( + gcpTracker.updateFromClusterManager( 3L, new HashSet<>(Arrays.asList(primary.allocationId().getId(), replica.allocationId().getId())), new IndexShardRoutingTable.Builder(shardId).addShard(primary).addShard(replica).build() diff --git a/server/src/test/java/org/opensearch/index/engine/NoOpEngineTests.java b/server/src/test/java/org/opensearch/index/engine/NoOpEngineTests.java index a015443979527..e2f6fa9489885 100644 --- a/server/src/test/java/org/opensearch/index/engine/NoOpEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/NoOpEngineTests.java @@ -99,7 +99,7 @@ public void testNoopAfterRegularEngine() throws IOException { allocationId ); IndexShardRoutingTable table = new IndexShardRoutingTable.Builder(shardId).addShard(routing).build(); - tracker.updateFromMaster(1L, Collections.singleton(allocationId.getId()), table); + tracker.updateFromClusterManager(1L, Collections.singleton(allocationId.getId()), table); tracker.activatePrimaryMode(SequenceNumbers.NO_OPS_PERFORMED); for (int i = 0; i < docs; i++) { ParsedDocument doc = testParsedDocument("" + i, null, testDocumentWithTextField(), B_1, null); @@ -203,7 +203,7 @@ public void testTrimUnreferencedTranslogFiles() throws Exception { allocationId ); IndexShardRoutingTable table = new IndexShardRoutingTable.Builder(shardId).addShard(routing).build(); - tracker.updateFromMaster(1L, Collections.singleton(allocationId.getId()), table); + tracker.updateFromClusterManager(1L, Collections.singleton(allocationId.getId()), table); tracker.activatePrimaryMode(SequenceNumbers.NO_OPS_PERFORMED); engine.onSettingsChanged(TimeValue.MINUS_ONE, ByteSizeValue.ZERO, randomNonNegativeLong()); final int numDocs = scaledRandomIntBetween(10, 3000); diff --git a/server/src/test/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseExpiryTests.java b/server/src/test/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseExpiryTests.java index 5a8b04bce24ca..b97b537d4280c 100644 --- a/server/src/test/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseExpiryTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/PeerRecoveryRetentionLeaseExpiryTests.java @@ -95,7 +95,7 @@ public void setUpReplicationTracker() throws InterruptedException { (leases, listener) -> {}, () -> safeCommitInfo ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( 1L, Collections.singleton(primaryAllocationId.getId()), routingTable(Collections.emptySet(), primaryAllocationId) @@ -107,7 +107,7 @@ public void setUpReplicationTracker() throws InterruptedException { Collections.singleton(replicaAllocationId), primaryAllocationId ); - replicationTracker.updateFromMaster(2L, Collections.singleton(primaryAllocationId.getId()), routingTableWithReplica); + replicationTracker.updateFromClusterManager(2L, Collections.singleton(primaryAllocationId.getId()), routingTableWithReplica); replicationTracker.addPeerRecoveryRetentionLease( routingTableWithReplica.getByAllocationId(replicaAllocationId.getId()).currentNodeId(), randomCheckpoint(), @@ -127,7 +127,7 @@ private void startReplica() { final IndexShardRoutingTable.Builder builder = new IndexShardRoutingTable.Builder(replicationTracker.routingTable); builder.removeShard(replicaShardRouting); builder.addShard(replicaShardRouting.moveToStarted()); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( replicationTracker.appliedClusterStateVersion + 1, replicationTracker.routingTable.shards().stream().map(sr -> sr.allocationId().getId()).collect(Collectors.toSet()), builder.build() diff --git a/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java b/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java index d94c1b919ad71..fc584ef90b54a 100644 --- a/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerRetentionLeaseTests.java @@ -86,7 +86,7 @@ public void testAddOrRenewRetentionLease() { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -134,7 +134,7 @@ public void testAddDuplicateRetentionLease() { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -166,7 +166,7 @@ public void testRenewNotFoundRetentionLease() { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -205,7 +205,7 @@ public void testAddRetentionLeaseCausesRetentionLeaseSync() { OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); reference.set(replicationTracker); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -243,7 +243,7 @@ public void testRemoveRetentionLease() { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -308,7 +308,7 @@ public void testCloneRetentionLease() { OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); replicationTrackerRef.set(replicationTracker); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -353,7 +353,7 @@ public void testCloneNonexistentRetentionLease() { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -382,7 +382,7 @@ public void testCloneDuplicateRetentionLease() { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -415,7 +415,7 @@ public void testRemoveNotFound() { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -454,7 +454,7 @@ public void testRemoveRetentionLeaseCausesRetentionLeaseSync() { OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); reference.set(replicationTracker); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -506,7 +506,7 @@ private void runExpirationTest(final boolean primaryMode) { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -585,7 +585,7 @@ public void testReplicaIgnoresOlderRetentionLeasesVersion() { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -638,7 +638,7 @@ public void testLoadAndPersistRetentionLeases() throws IOException { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -673,7 +673,7 @@ public void testUnnecessaryPersistenceOfRetentionLeases() throws IOException { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -726,7 +726,7 @@ public void testPersistRetentionLeasesUnderConcurrency() throws IOException { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) @@ -790,7 +790,7 @@ public void testRenewLeaseWithLowerRetainingSequenceNumber() throws Exception { (leases, listener) -> {}, OPS_BASED_RECOVERY_ALWAYS_REASONABLE ); - replicationTracker.updateFromMaster( + replicationTracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(allocationId.getId()), routingTable(Collections.emptySet(), allocationId) diff --git a/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerTests.java b/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerTests.java index 8fd8449108333..66c484cd40cce 100644 --- a/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerTests.java +++ b/server/src/test/java/org/opensearch/index/seqno/ReplicationTrackerTests.java @@ -137,7 +137,7 @@ public void testGlobalCheckpointUpdate() { logger.info(" - [{}], local checkpoint [{}], [{}]", aId, allocations.get(aId), type); }); - tracker.updateFromMaster(initialClusterStateVersion, ids(active), routingTable(initializing, primaryId)); + tracker.updateFromClusterManager(initialClusterStateVersion, ids(active), routingTable(initializing, primaryId)); tracker.activatePrimaryMode(NO_OPS_PERFORMED); assertThat(tracker.getReplicationGroup().getReplicationTargets().size(), equalTo(1)); initializing.forEach(aId -> markAsTrackingAndInSyncQuietly(tracker, aId.getId(), NO_OPS_PERFORMED)); @@ -167,7 +167,7 @@ public void testGlobalCheckpointUpdate() { Set newInitializing = new HashSet<>(initializing); newInitializing.add(extraId); - tracker.updateFromMaster(initialClusterStateVersion + 1, ids(active), routingTable(newInitializing, primaryId)); + tracker.updateFromClusterManager(initialClusterStateVersion + 1, ids(active), routingTable(newInitializing, primaryId)); addPeerRecoveryRetentionLease(tracker, extraId); tracker.initiateTracking(extraId.getId()); @@ -208,7 +208,7 @@ public void testMarkAllocationIdAsInSync() throws Exception { final AllocationId primaryId = active.iterator().next(); final AllocationId replicaId = initializing.iterator().next(); final ReplicationTracker tracker = newTracker(primaryId); - tracker.updateFromMaster(initialClusterStateVersion, ids(active), routingTable(initializing, primaryId)); + tracker.updateFromClusterManager(initialClusterStateVersion, ids(active), routingTable(initializing, primaryId)); final long localCheckpoint = randomLongBetween(0, Long.MAX_VALUE - 1); tracker.activatePrimaryMode(localCheckpoint); addPeerRecoveryRetentionLease(tracker, replicaId); @@ -249,7 +249,7 @@ public void testMissingActiveIdsPreventAdvance() { assigned.putAll(initializing); AllocationId primaryId = active.keySet().iterator().next(); final ReplicationTracker tracker = newTracker(primaryId); - tracker.updateFromMaster(randomNonNegativeLong(), ids(active.keySet()), routingTable(initializing.keySet(), primaryId)); + tracker.updateFromClusterManager(randomNonNegativeLong(), ids(active.keySet()), routingTable(initializing.keySet(), primaryId)); tracker.activatePrimaryMode(NO_OPS_PERFORMED); randomSubsetOf(initializing.keySet()).forEach(k -> markAsTrackingAndInSyncQuietly(tracker, k.getId(), NO_OPS_PERFORMED)); final AllocationId missingActiveID = randomFrom(active.keySet()); @@ -275,7 +275,7 @@ public void testMissingInSyncIdsPreventAdvance() { AllocationId primaryId = active.keySet().iterator().next(); final ReplicationTracker tracker = newTracker(primaryId); - tracker.updateFromMaster(randomNonNegativeLong(), ids(active.keySet()), routingTable(initializing.keySet(), primaryId)); + tracker.updateFromClusterManager(randomNonNegativeLong(), ids(active.keySet()), routingTable(initializing.keySet(), primaryId)); tracker.activatePrimaryMode(NO_OPS_PERFORMED); randomSubsetOf(randomIntBetween(1, initializing.size() - 1), initializing.keySet()).forEach( aId -> markAsTrackingAndInSyncQuietly(tracker, aId.getId(), NO_OPS_PERFORMED) @@ -298,7 +298,7 @@ public void testInSyncIdsAreIgnoredIfNotValidatedByClusterManager() { final Map nonApproved = randomAllocationsWithLocalCheckpoints(1, 5); final AllocationId primaryId = active.keySet().iterator().next(); final ReplicationTracker tracker = newTracker(primaryId); - tracker.updateFromMaster(randomNonNegativeLong(), ids(active.keySet()), routingTable(initializing.keySet(), primaryId)); + tracker.updateFromClusterManager(randomNonNegativeLong(), ids(active.keySet()), routingTable(initializing.keySet(), primaryId)); tracker.activatePrimaryMode(NO_OPS_PERFORMED); initializing.keySet().forEach(k -> markAsTrackingAndInSyncQuietly(tracker, k.getId(), NO_OPS_PERFORMED)); nonApproved.keySet() @@ -335,7 +335,7 @@ public void testInSyncIdsAreRemovedIfNotValidatedByClusterManager() { allocations.putAll(initializingToBeRemoved); } final ReplicationTracker tracker = newTracker(primaryId); - tracker.updateFromMaster(initialClusterStateVersion, ids(active), routingTable(initializing, primaryId)); + tracker.updateFromClusterManager(initialClusterStateVersion, ids(active), routingTable(initializing, primaryId)); tracker.activatePrimaryMode(NO_OPS_PERFORMED); if (randomBoolean()) { initializingToStay.keySet().forEach(k -> markAsTrackingAndInSyncQuietly(tracker, k.getId(), NO_OPS_PERFORMED)); @@ -348,7 +348,7 @@ public void testInSyncIdsAreRemovedIfNotValidatedByClusterManager() { // now remove shards if (randomBoolean()) { - tracker.updateFromMaster( + tracker.updateFromClusterManager( initialClusterStateVersion + 1, ids(activeToStay.keySet()), routingTable(initializingToStay.keySet(), primaryId) @@ -356,7 +356,7 @@ public void testInSyncIdsAreRemovedIfNotValidatedByClusterManager() { allocations.forEach((aid, ckp) -> updateLocalCheckpoint(tracker, aid.getId(), ckp + 10L)); } else { allocations.forEach((aid, ckp) -> updateLocalCheckpoint(tracker, aid.getId(), ckp + 10L)); - tracker.updateFromMaster( + tracker.updateFromClusterManager( initialClusterStateVersion + 2, ids(activeToStay.keySet()), routingTable(initializingToStay.keySet(), primaryId) @@ -378,7 +378,7 @@ public void testWaitForAllocationIdToBeInSync() throws Exception { final AllocationId trackingAllocationId = AllocationId.newInitializing(); final ReplicationTracker tracker = newTracker(inSyncAllocationId); final long clusterStateVersion = randomNonNegativeLong(); - tracker.updateFromMaster( + tracker.updateFromClusterManager( clusterStateVersion, Collections.singleton(inSyncAllocationId.getId()), routingTable(Collections.singleton(trackingAllocationId), inSyncAllocationId) @@ -422,7 +422,7 @@ public void testWaitForAllocationIdToBeInSync() throws Exception { assertTrue(tracker.getTrackedLocalCheckpointForShard(trackingAllocationId.getId()).inSync); } else { // cluster-manager changes its mind and cancels the allocation - tracker.updateFromMaster( + tracker.updateFromClusterManager( clusterStateVersion + 1, Collections.singleton(inSyncAllocationId.getId()), routingTable(emptySet(), inSyncAllocationId) @@ -449,7 +449,7 @@ public void testWaitForAllocationIdToBeInSyncCanBeInterrupted() throws BrokenBar final AllocationId inSyncAllocationId = AllocationId.newInitializing(); final AllocationId trackingAllocationId = AllocationId.newInitializing(); final ReplicationTracker tracker = newTracker(inSyncAllocationId); - tracker.updateFromMaster( + tracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(inSyncAllocationId.getId()), routingTable(Collections.singleton(trackingAllocationId), inSyncAllocationId) @@ -505,7 +505,7 @@ public void testUpdateAllocationIdsFromClusterManager() throws Exception { AllocationId primaryId = activeAllocationIds.iterator().next(); IndexShardRoutingTable routingTable = routingTable(initializingIds, primaryId); final ReplicationTracker tracker = newTracker(primaryId); - tracker.updateFromMaster(initialClusterStateVersion, ids(activeAllocationIds), routingTable); + tracker.updateFromClusterManager(initialClusterStateVersion, ids(activeAllocationIds), routingTable); tracker.activatePrimaryMode(NO_OPS_PERFORMED); assertThat(tracker.getReplicationGroup().getInSyncAllocationIds(), equalTo(ids(activeAllocationIds))); assertThat(tracker.getReplicationGroup().getRoutingTable(), equalTo(routingTable)); @@ -539,7 +539,7 @@ public void testUpdateAllocationIdsFromClusterManager() throws Exception { .filter(a -> !removingInitializingAllocationIds.contains(a)) .collect(Collectors.toSet()); routingTable = routingTable(newInitializingAllocationIds, primaryId); - tracker.updateFromMaster(initialClusterStateVersion + 1, ids(newActiveAllocationIds), routingTable); + tracker.updateFromClusterManager(initialClusterStateVersion + 1, ids(newActiveAllocationIds), routingTable); assertTrue(newActiveAllocationIds.stream().allMatch(a -> tracker.getTrackedLocalCheckpointForShard(a.getId()).inSync)); assertTrue(removingActiveAllocationIds.stream().allMatch(a -> tracker.getTrackedLocalCheckpointForShard(a.getId()) == null)); assertTrue(newInitializingAllocationIds.stream().noneMatch(a -> tracker.getTrackedLocalCheckpointForShard(a.getId()).inSync)); @@ -555,7 +555,7 @@ public void testUpdateAllocationIdsFromClusterManager() throws Exception { * than we have been using above ensures that we can not collide with a previous allocation ID */ newInitializingAllocationIds.add(AllocationId.newInitializing()); - tracker.updateFromMaster( + tracker.updateFromClusterManager( initialClusterStateVersion + 2, ids(newActiveAllocationIds), routingTable(newInitializingAllocationIds, primaryId) @@ -607,7 +607,7 @@ public void testUpdateAllocationIdsFromClusterManager() throws Exception { // using a different length than we have been using above ensures that we can not collide with a previous allocation ID final AllocationId newSyncingAllocationId = AllocationId.newInitializing(); newInitializingAllocationIds.add(newSyncingAllocationId); - tracker.updateFromMaster( + tracker.updateFromClusterManager( initialClusterStateVersion + 3, ids(newActiveAllocationIds), routingTable(newInitializingAllocationIds, primaryId) @@ -649,7 +649,7 @@ public void testUpdateAllocationIdsFromClusterManager() throws Exception { * the in-sync set even if we receive a cluster state update that does not reflect this. * */ - tracker.updateFromMaster( + tracker.updateFromClusterManager( initialClusterStateVersion + 4, ids(newActiveAllocationIds), routingTable(newInitializingAllocationIds, primaryId) @@ -678,7 +678,7 @@ public void testRaceUpdatingGlobalCheckpoint() throws InterruptedException, Brok final int activeLocalCheckpoint = randomIntBetween(0, Integer.MAX_VALUE - 1); final ReplicationTracker tracker = newTracker(active); - tracker.updateFromMaster( + tracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(active.getId()), routingTable(Collections.singleton(initializing), active) @@ -907,7 +907,7 @@ public void testIllegalStateExceptionIfUnknownAllocationId() { final AllocationId active = AllocationId.newInitializing(); final AllocationId initializing = AllocationId.newInitializing(); final ReplicationTracker tracker = newTracker(active); - tracker.updateFromMaster( + tracker.updateFromClusterManager( randomNonNegativeLong(), Collections.singleton(active.getId()), routingTable(Collections.singleton(initializing), active) @@ -938,7 +938,7 @@ public Set initializingIds() { } public void apply(ReplicationTracker gcp) { - gcp.updateFromMaster(version, ids(inSyncIds), routingTable); + gcp.updateFromClusterManager(version, ids(inSyncIds), routingTable); } } @@ -1114,7 +1114,7 @@ public void testPeerRecoveryRetentionLeaseCreationAndRenewal() { tracker.updateRetentionLeasesOnReplica(new RetentionLeases(randomNonNegativeLong(), randomNonNegativeLong(), initialLeases)); IndexShardRoutingTable routingTable = routingTable(initializingAllocationIds, primaryId); - tracker.updateFromMaster(initialClusterStateVersion, ids(activeAllocationIds), routingTable); + tracker.updateFromClusterManager(initialClusterStateVersion, ids(activeAllocationIds), routingTable); tracker.activatePrimaryMode(NO_OPS_PERFORMED); assertTrue( "primary's retention lease should exist", @@ -1184,7 +1184,7 @@ public void testPeerRecoveryRetentionLeaseCreationAndRenewal() { routingTable = routingTableBuilder.build(); activeAllocationIds.addAll(initializingAllocationIds); - tracker.updateFromMaster(initialClusterStateVersion + randomLongBetween(1, 10), ids(activeAllocationIds), routingTable); + tracker.updateFromClusterManager(initialClusterStateVersion + randomLongBetween(1, 10), ids(activeAllocationIds), routingTable); assertAsTimePasses.accept(() -> { // Leases still don't expire diff --git a/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java b/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java index c37a610b28bc9..769fdc220bec4 100644 --- a/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java +++ b/server/src/test/java/org/opensearch/indices/cluster/ClusterStateChanges.java @@ -397,15 +397,21 @@ public ClusterState addNodes(ClusterState clusterState, List node ); } - public ClusterState joinNodesAndBecomeMaster(ClusterState clusterState, List nodes) { + public ClusterState joinNodesAndBecomeClusterManager(ClusterState clusterState, List nodes) { List joinNodes = new ArrayList<>(); - joinNodes.add(JoinTaskExecutor.newBecomeMasterTask()); + joinNodes.add(JoinTaskExecutor.newBecomeClusterManagerTask()); joinNodes.add(JoinTaskExecutor.newFinishElectionTask()); joinNodes.addAll(nodes.stream().map(node -> new JoinTaskExecutor.Task(node, "dummy reason")).collect(Collectors.toList())); return runTasks(joinTaskExecutor, clusterState, joinNodes); } + /** @deprecated As of 2.2, because supporting inclusive language, replaced by {@link #joinNodesAndBecomeClusterManager(ClusterState, List)} */ + @Deprecated + public ClusterState joinNodesAndBecomeMaster(ClusterState clusterState, List nodes) { + return joinNodesAndBecomeClusterManager(clusterState, nodes); + } + public ClusterState removeNodes(ClusterState clusterState, List nodes) { return runTasks( nodeRemovalExecutor, diff --git a/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java b/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java index 616baa50b0b19..e08f6a92afa24 100644 --- a/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java +++ b/server/src/test/java/org/opensearch/indices/cluster/IndicesClusterStateServiceRandomUpdatesTests.java @@ -494,7 +494,7 @@ public ClusterState randomlyUpdateClusterState( // remove node if (state.nodes().getDataNodes().size() > 3) { DiscoveryNode discoveryNode = randomFrom(state.nodes().getNodes().values().toArray(DiscoveryNode.class)); - if (discoveryNode.equals(state.nodes().getMasterNode()) == false) { + if (discoveryNode.equals(state.nodes().getClusterManagerNode()) == false) { state = cluster.removeNodes(state, Collections.singletonList(discoveryNode)); updateNodes(state, clusterStateServiceMap, indicesServiceSupplier); } diff --git a/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java b/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java index 40ffa2eeb0aff..7e23e6ef3748c 100644 --- a/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java +++ b/server/src/test/java/org/opensearch/persistent/PersistentTasksClusterServiceTests.java @@ -153,7 +153,7 @@ public void testReassignmentRequiredOnMetadataChanges() { DiscoveryNodes nodes = DiscoveryNodes.builder() .add(new DiscoveryNode("_node", buildNewFakeTransportAddress(), Version.CURRENT)) .localNodeId("_node") - .masterNodeId("_node") + .clusterManagerNodeId("_node") .build(); boolean unassigned = randomBoolean(); @@ -536,7 +536,7 @@ public void testPeriodicRecheckOffClusterManager() { builder = ClusterState.builder(clusterState); nodes = DiscoveryNodes.builder(clusterState.nodes()); nodes.add(DiscoveryNode.createLocal(Settings.EMPTY, buildNewFakeTransportAddress(), "a_new_cluster_manager_node")); - nodes.masterNodeId("a_new_cluster_manager_node"); + nodes.clusterManagerNodeId("a_new_cluster_manager_node"); ClusterState nonMasterClusterState = builder.nodes(nodes).build(); event = new ClusterChangedEvent("test", nonMasterClusterState, clusterState); service.clusterChanged(event); @@ -554,7 +554,7 @@ public void testUnassignTask() { DiscoveryNodes.Builder nodes = DiscoveryNodes.builder() .add(new DiscoveryNode("_node_1", buildNewFakeTransportAddress(), Version.CURRENT)) .localNodeId("_node_1") - .masterNodeId("_node_1") + .clusterManagerNodeId("_node_1") .add(new DiscoveryNode("_node_2", buildNewFakeTransportAddress(), Version.CURRENT)); String unassignedId = addTask(tasks, "unassign", "_node_2"); @@ -579,7 +579,7 @@ public void testUnassignNonExistentTask() { DiscoveryNodes.Builder nodes = DiscoveryNodes.builder() .add(new DiscoveryNode("_node_1", buildNewFakeTransportAddress(), Version.CURRENT)) .localNodeId("_node_1") - .masterNodeId("_node_1") + .clusterManagerNodeId("_node_1") .add(new DiscoveryNode("_node_2", buildNewFakeTransportAddress(), Version.CURRENT)); Metadata.Builder metadata = Metadata.builder(clusterState.metadata()).putCustom(PersistentTasksCustomMetadata.TYPE, tasks.build()); @@ -902,7 +902,7 @@ private ClusterState initialState() { DiscoveryNodes.Builder nodes = DiscoveryNodes.builder(); nodes.add(DiscoveryNode.createLocal(Settings.EMPTY, buildNewFakeTransportAddress(), "this_node")); nodes.localNodeId("this_node"); - nodes.masterNodeId("this_node"); + nodes.clusterManagerNodeId("this_node"); return ClusterState.builder(ClusterName.DEFAULT).nodes(nodes).metadata(metadata).routingTable(routingTable.build()).build(); } diff --git a/server/src/test/java/org/opensearch/persistent/PersistentTasksCustomMetadataTests.java b/server/src/test/java/org/opensearch/persistent/PersistentTasksCustomMetadataTests.java index 873176f5d42be..a0604a9385fb4 100644 --- a/server/src/test/java/org/opensearch/persistent/PersistentTasksCustomMetadataTests.java +++ b/server/src/test/java/org/opensearch/persistent/PersistentTasksCustomMetadataTests.java @@ -330,7 +330,7 @@ public void testDisassociateDeadNodes_givenAssignedPersistentTask() { DiscoveryNodes nodes = DiscoveryNodes.builder() .add(new DiscoveryNode("node1", buildNewFakeTransportAddress(), Version.CURRENT)) .localNodeId("node1") - .masterNodeId("node1") + .clusterManagerNodeId("node1") .build(); String taskName = "test/task"; @@ -358,7 +358,7 @@ public void testDisassociateDeadNodes() { DiscoveryNodes nodes = DiscoveryNodes.builder() .add(new DiscoveryNode("node1", buildNewFakeTransportAddress(), Version.CURRENT)) .localNodeId("node1") - .masterNodeId("node1") + .clusterManagerNodeId("node1") .build(); String taskName = "test/task"; diff --git a/server/src/test/java/org/opensearch/snapshots/InternalSnapshotsInfoServiceTests.java b/server/src/test/java/org/opensearch/snapshots/InternalSnapshotsInfoServiceTests.java index f0e283e6dde6d..483b5c268d3f9 100644 --- a/server/src/test/java/org/opensearch/snapshots/InternalSnapshotsInfoServiceTests.java +++ b/server/src/test/java/org/opensearch/snapshots/InternalSnapshotsInfoServiceTests.java @@ -495,7 +495,7 @@ private ClusterState demoteClusterManagerNode(final ClusterState currentState) { assertThat(currentState.nodes().get(node.getId()), nullValue()); return ClusterState.builder(currentState) - .nodes(DiscoveryNodes.builder(currentState.nodes()).add(node).masterNodeId(node.getId())) + .nodes(DiscoveryNodes.builder(currentState.nodes()).add(node).clusterManagerNodeId(node.getId())) .build(); } diff --git a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java index 60333203b7bfb..e2a8c8e08607b 100644 --- a/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java +++ b/server/src/test/java/org/opensearch/snapshots/SnapshotResiliencyTests.java @@ -1340,13 +1340,13 @@ private void startCluster() { testClusterNodes.nodes.values() .stream() .map(n -> n.node) - .filter(DiscoveryNode::isMasterNode) + .filter(DiscoveryNode::isClusterManagerNode) .map(DiscoveryNode::getId) .collect(Collectors.toSet()) ); testClusterNodes.nodes.values() .stream() - .filter(n -> n.node.isMasterNode()) + .filter(n -> n.node.isClusterManagerNode()) .forEach(testClusterNode -> testClusterNode.coordinator.setInitialConfiguration(votingConfiguration)); // Connect all nodes to each other testClusterNodes.nodes.values() @@ -1375,7 +1375,7 @@ private void stabilize() { .map(node -> node.clusterService.state()) .collect(Collectors.toList()); final Set clusterManagerNodeIds = clusterStates.stream() - .map(clusterState -> clusterState.nodes().getMasterNodeId()) + .map(clusterState -> clusterState.nodes().getClusterManagerNodeId()) .collect(Collectors.toSet()); final Set terms = clusterStates.stream().map(ClusterState::term).collect(Collectors.toSet()); final List versions = clusterStates.stream().map(ClusterState::version).distinct().collect(Collectors.toList()); @@ -1535,7 +1535,7 @@ public Optional randomClusterManagerNode() { // Select from sorted list of data-nodes here to not have deterministic behaviour final List clusterManagerNodes = testClusterNodes.nodes.values() .stream() - .filter(n -> n.node.isMasterNode()) + .filter(n -> n.node.isClusterManagerNode()) .filter(n -> disconnectedNodes.contains(n.node.getName()) == false) .sorted(Comparator.comparing(n -> n.node.getName())) .collect(Collectors.toList()); @@ -1606,9 +1606,9 @@ public DiscoveryNodes discoveryNodes() { * @return Cluster Manager Node */ public TestClusterNode currentClusterManager(ClusterState state) { - TestClusterNode clusterManager = nodes.get(state.nodes().getMasterNode().getName()); + TestClusterNode clusterManager = nodes.get(state.nodes().getClusterManagerNode().getName()); assertNotNull(clusterManager); - assertTrue(clusterManager.node.isMasterNode()); + assertTrue(clusterManager.node.isClusterManagerNode()); return clusterManager; } @@ -2200,7 +2200,7 @@ public void start(ClusterState initialState) { () -> persistedState, hostsResolver -> nodes.values() .stream() - .filter(n -> n.node.isMasterNode()) + .filter(n -> n.node.isClusterManagerNode()) .map(n -> n.node.getAddress()) .collect(Collectors.toList()), clusterService.getClusterApplierService(), diff --git a/test/framework/src/main/java/org/opensearch/action/support/replication/ClusterStateCreationUtils.java b/test/framework/src/main/java/org/opensearch/action/support/replication/ClusterStateCreationUtils.java index 18f8f4e584748..5089368776ad6 100644 --- a/test/framework/src/main/java/org/opensearch/action/support/replication/ClusterStateCreationUtils.java +++ b/test/framework/src/main/java/org/opensearch/action/support/replication/ClusterStateCreationUtils.java @@ -107,7 +107,7 @@ public static ClusterState state( unassignedNodes.add(node.getId()); } discoBuilder.localNodeId(newNode(0).getId()); - discoBuilder.masterNodeId(newNode(1).getId()); // we need a non-local cluster-manager to test shard failures + discoBuilder.clusterManagerNodeId(newNode(1).getId()); // we need a non-local cluster-manager to test shard failures final int primaryTerm = 1 + randomInt(200); IndexMetadata indexMetadata = IndexMetadata.builder(index) .settings( @@ -198,7 +198,7 @@ public static ClusterState state(String index, final int numberOfNodes, final in nodes.add(node.getId()); } discoBuilder.localNodeId(newNode(0).getId()); - discoBuilder.masterNodeId(randomFrom(nodes)); + discoBuilder.clusterManagerNodeId(randomFrom(nodes)); IndexMetadata indexMetadata = IndexMetadata.builder(index) .settings( Settings.builder() @@ -240,7 +240,7 @@ public static ClusterState state(final int numberOfNodes, final String[] indices nodes.add(node.getId()); } discoBuilder.localNodeId(newNode(0).getId()); - discoBuilder.masterNodeId(newNode(0).getId()); + discoBuilder.clusterManagerNodeId(newNode(0).getId()); Metadata.Builder metadata = Metadata.builder(); RoutingTable.Builder routingTable = RoutingTable.builder(); List nodesList = new ArrayList<>(nodes); @@ -291,7 +291,7 @@ public static ClusterState stateWithAssignedPrimariesAndOneReplica(String index, discoBuilder = discoBuilder.add(node); } discoBuilder.localNodeId(newNode(0).getId()); - discoBuilder.masterNodeId(newNode(1).getId()); // we need a non-local cluster-manager to test shard failures + discoBuilder.clusterManagerNodeId(newNode(1).getId()); // we need a non-local cluster-manager to test shard failures IndexMetadata indexMetadata = IndexMetadata.builder(index) .settings( Settings.builder() @@ -332,7 +332,7 @@ public static ClusterState stateWithAssignedPrimariesAndReplicas(String[] indice discoBuilder = discoBuilder.add(node); } discoBuilder.localNodeId(newNode(0).getId()); - discoBuilder.masterNodeId(newNode(numberOfDataNodes + 1).getId()); + discoBuilder.clusterManagerNodeId(newNode(numberOfDataNodes + 1).getId()); ClusterState.Builder state = ClusterState.builder(new ClusterName("test")); state.nodes(discoBuilder); Builder routingTableBuilder = RoutingTable.builder(); @@ -417,7 +417,7 @@ public static ClusterState stateWithActivePrimary( public static ClusterState stateWithNoShard() { DiscoveryNodes.Builder discoBuilder = DiscoveryNodes.builder(); discoBuilder.localNodeId(newNode(0).getId()); - discoBuilder.masterNodeId(newNode(1).getId()); + discoBuilder.clusterManagerNodeId(newNode(1).getId()); ClusterState.Builder state = ClusterState.builder(new ClusterName("test")); state.nodes(discoBuilder); state.metadata(Metadata.builder().generateClusterUuidIfNeeded()); @@ -439,7 +439,7 @@ public static ClusterState state(DiscoveryNode localNode, DiscoveryNode clusterM discoBuilder.add(node); } if (clusterManagerNode != null) { - discoBuilder.masterNodeId(clusterManagerNode.getId()); + discoBuilder.clusterManagerNodeId(clusterManagerNode.getId()); } discoBuilder.localNodeId(localNode.getId()); diff --git a/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java b/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java index 19551b0adecb2..36469b2ee1999 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java +++ b/test/framework/src/main/java/org/opensearch/cluster/coordination/AbstractCoordinatorTestCase.java @@ -311,7 +311,7 @@ class Cluster implements Releasable { nodeHealthService ); clusterNodes.add(clusterNode); - if (clusterNode.getLocalNode().isMasterNode()) { + if (clusterNode.getLocalNode().isClusterManagerNode()) { clusterManagerEligibleNodeIds.add(clusterNode.getId()); } } @@ -617,7 +617,7 @@ void stabilise(long stabilisationDurationMillis) { assertTrue(nodeId + " has been bootstrapped", clusterNode.coordinator.isInitialConfigurationSet()); assertThat( nodeId + " has correct cluster-manager", - clusterNode.getLastAppliedClusterState().nodes().getMasterNode(), + clusterNode.getLastAppliedClusterState().nodes().getClusterManagerNode(), equalTo(leader.getLocalNode()) ); assertThat( @@ -634,7 +634,7 @@ void stabilise(long stabilisationDurationMillis) { assertThat(nodeId + " is not following " + leaderId, clusterNode.coordinator.getMode(), is(CANDIDATE)); assertThat( nodeId + " has no cluster-manager", - clusterNode.getLastAppliedClusterState().nodes().getMasterNode(), + clusterNode.getLastAppliedClusterState().nodes().getClusterManagerNode(), nullValue() ); assertThat( @@ -784,7 +784,7 @@ boolean nodeExists(DiscoveryNode node) { ClusterNode getAnyBootstrappableNode() { return randomFrom( clusterNodes.stream() - .filter(n -> n.getLocalNode().isMasterNode()) + .filter(n -> n.getLocalNode().isClusterManagerNode()) .filter(n -> initialConfiguration.getNodeIds().contains(n.getLocalNode().getId())) .collect(Collectors.toList()) ); @@ -899,7 +899,8 @@ class MockPersistedState implements CoordinationState.PersistedState { final long persistedCurrentTerm; if ( // node is cluster-manager-ineligible either before or after the restart ... - (oldState.getLastAcceptedState().nodes().getLocalNode().isMasterNode() && newLocalNode.isMasterNode()) == false + (oldState.getLastAcceptedState().nodes().getLocalNode().isClusterManagerNode() + && newLocalNode.isClusterManagerNode()) == false // ... and it's accepted some non-initial state so we can roll back ... && (oldState.getLastAcceptedState().term() > 0L || oldState.getLastAcceptedState().version() > 0L) // ... and we're feeling lucky ... @@ -1194,7 +1195,9 @@ ClusterNode restartedNode( address.getAddress(), address, Collections.emptyMap(), - localNode.isMasterNode() && DiscoveryNode.isMasterNode(nodeSettings) ? DiscoveryNodeRole.BUILT_IN_ROLES : emptySet(), + localNode.isClusterManagerNode() && DiscoveryNode.isClusterManagerNode(nodeSettings) + ? DiscoveryNodeRole.BUILT_IN_ROLES + : emptySet(), Version.CURRENT ); return new ClusterNode( @@ -1291,7 +1294,7 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { // in this case, we know for sure that event was not processed by the system and will not change history // remove event to help avoid bloated history and state space explosion in linearizability checker history.remove(eventId); @@ -1346,9 +1349,9 @@ public void onFailure(String source, Exception e) { } @Override - public void onNoLongerMaster(String source) { + public void onNoLongerClusterManager(String source) { logger.trace("no longer cluster-manager: [{}]", source); - taskListener.onNoLongerMaster(source); + taskListener.onNoLongerClusterManager(source); } @Override @@ -1427,7 +1430,7 @@ void applyInitialConfiguration() { } private boolean isNotUsefullyBootstrapped() { - return getLocalNode().isMasterNode() == false || coordinator.isInitialConfigurationSet() == false; + return getLocalNode().isClusterManagerNode() == false || coordinator.isInitialConfigurationSet() == false; } void allowClusterStateApplicationFailure() { diff --git a/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java b/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java index ca4a33fa677c6..5ef7fb192b054 100644 --- a/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/cluster/coordination/CoordinationStateTestCluster.java @@ -148,7 +148,7 @@ static class ClusterNode { } void reboot() { - if (localNode.isMasterNode() == false && rarely()) { + if (localNode.isClusterManagerNode() == false && rarely()) { // cluster-manager-ineligible nodes can't be trusted to persist the cluster state properly, // but will not lose the fact that they were bootstrapped final CoordinationMetadata.VotingConfiguration votingConfiguration = persistedState.getLastAcceptedState() diff --git a/test/framework/src/main/java/org/opensearch/repositories/blobstore/BlobStoreTestUtil.java b/test/framework/src/main/java/org/opensearch/repositories/blobstore/BlobStoreTestUtil.java index 89d5f6f95bc5a..50158c6ecf053 100644 --- a/test/framework/src/main/java/org/opensearch/repositories/blobstore/BlobStoreTestUtil.java +++ b/test/framework/src/main/java/org/opensearch/repositories/blobstore/BlobStoreTestUtil.java @@ -414,7 +414,9 @@ private static ClusterService mockClusterService(ClusterState initialState) { final DiscoveryNode localNode = new DiscoveryNode("", buildNewFakeTransportAddress(), Version.CURRENT); final AtomicReference currentState = new AtomicReference<>( ClusterState.builder(initialState) - .nodes(DiscoveryNodes.builder().add(localNode).masterNodeId(localNode.getId()).localNodeId(localNode.getId()).build()) + .nodes( + DiscoveryNodes.builder().add(localNode).clusterManagerNodeId(localNode.getId()).localNodeId(localNode.getId()).build() + ) .build() ); when(clusterService.state()).then(invocationOnMock -> currentState.get()); diff --git a/test/framework/src/main/java/org/opensearch/test/ClusterServiceUtils.java b/test/framework/src/main/java/org/opensearch/test/ClusterServiceUtils.java index 99f9b86fb6479..55ae70df9892c 100644 --- a/test/framework/src/main/java/org/opensearch/test/ClusterServiceUtils.java +++ b/test/framework/src/main/java/org/opensearch/test/ClusterServiceUtils.java @@ -79,7 +79,7 @@ public static MasterService createMasterService(ThreadPool threadPool, ClusterSt public static MasterService createMasterService(ThreadPool threadPool, DiscoveryNode localNode) { ClusterState initialClusterState = ClusterState.builder(new ClusterName(ClusterServiceUtils.class.getSimpleName())) - .nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId()).masterNodeId(localNode.getId())) + .nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId()).clusterManagerNodeId(localNode.getId())) .blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK) .build(); return createMasterService(threadPool, initialClusterState); @@ -160,7 +160,7 @@ public static ClusterService createClusterService(ThreadPool threadPool, Discove ClusterService clusterService = new ClusterService(settings, clusterSettings, threadPool); clusterService.setNodeConnectionsService(createNoOpNodeConnectionsService()); ClusterState initialClusterState = ClusterState.builder(new ClusterName(ClusterServiceUtils.class.getSimpleName())) - .nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId()).masterNodeId(localNode.getId())) + .nodes(DiscoveryNodes.builder().add(localNode).localNodeId(localNode.getId()).clusterManagerNodeId(localNode.getId())) .blocks(ClusterBlocks.EMPTY_CLUSTER_BLOCK) .build(); clusterService.getClusterApplierService().setInitialState(initialClusterState); diff --git a/test/framework/src/main/java/org/opensearch/test/ExternalTestCluster.java b/test/framework/src/main/java/org/opensearch/test/ExternalTestCluster.java index 6dec5858b398a..33147447bd469 100644 --- a/test/framework/src/main/java/org/opensearch/test/ExternalTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/test/ExternalTestCluster.java @@ -148,7 +148,7 @@ public ExternalTestCluster( if (DiscoveryNode.isDataNode(nodeInfo.getSettings())) { dataNodes++; clusterManagerAndDataNodes++; - } else if (DiscoveryNode.isMasterNode(nodeInfo.getSettings())) { + } else if (DiscoveryNode.isClusterManagerNode(nodeInfo.getSettings())) { clusterManagerAndDataNodes++; } } diff --git a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java index 70a306eda0ff8..1a4ff06fa7bbc 100644 --- a/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java +++ b/test/framework/src/main/java/org/opensearch/test/InternalTestCluster.java @@ -199,11 +199,11 @@ public final class InternalTestCluster extends TestCluster { nodeAndClient.node.settings() ); - private static final Predicate NO_DATA_NO_CLUSTER_MANAGER_PREDICATE = nodeAndClient -> DiscoveryNode.isMasterNode( - nodeAndClient.node.settings() - ) == false && DiscoveryNode.isDataNode(nodeAndClient.node.settings()) == false; + private static final Predicate NO_DATA_NO_CLUSTER_MANAGER_PREDICATE = nodeAndClient -> DiscoveryNode + .isClusterManagerNode(nodeAndClient.node.settings()) == false + && DiscoveryNode.isDataNode(nodeAndClient.node.settings()) == false; - private static final Predicate CLUSTER_MANAGER_NODE_PREDICATE = nodeAndClient -> DiscoveryNode.isMasterNode( + private static final Predicate CLUSTER_MANAGER_NODE_PREDICATE = nodeAndClient -> DiscoveryNode.isClusterManagerNode( nodeAndClient.node.settings() ); @@ -792,13 +792,13 @@ private static String getRoleSuffix(Settings settings) { String suffix = ""; // only add the suffixes if roles are explicitly defined if (settings.hasValue("nodes.roles")) { - if (DiscoveryNode.isMasterNode(settings)) { + if (DiscoveryNode.isClusterManagerNode(settings)) { suffix = suffix + DiscoveryNodeRole.CLUSTER_MANAGER_ROLE.roleNameAbbreviation(); } if (DiscoveryNode.isDataNode(settings)) { suffix = suffix + DiscoveryNodeRole.DATA_ROLE.roleNameAbbreviation(); } - if (!DiscoveryNode.isMasterNode(settings) && !DiscoveryNode.isDataNode(settings)) { + if (!DiscoveryNode.isClusterManagerNode(settings) && !DiscoveryNode.isDataNode(settings)) { suffix = suffix + "c"; } } @@ -936,7 +936,7 @@ public String getName() { } public boolean isMasterEligible() { - return DiscoveryNode.isMasterNode(node.settings()); + return DiscoveryNode.isClusterManagerNode(node.settings()); } Client client() { @@ -1164,7 +1164,7 @@ private synchronized void reset(boolean wipeData) throws IOException { int autoBootstrapClusterManagerNodeIndex = -1; final List clusterManagerNodeNames = settings.stream() - .filter(DiscoveryNode::isMasterNode) + .filter(DiscoveryNode::isClusterManagerNode) .map(Node.NODE_NAME_SETTING::get) .collect(Collectors.toList()); @@ -1222,7 +1222,10 @@ public synchronized void validateClusterFormed() { .collect(Collectors.toList()); final String debugString = ", expected nodes: " + expectedNodes + " and actual cluster states " + states; // all nodes have a cluster-manager - assertTrue("Missing cluster-manager" + debugString, states.stream().allMatch(cs -> cs.nodes().getMasterNodeId() != null)); + assertTrue( + "Missing cluster-manager" + debugString, + states.stream().allMatch(cs -> cs.nodes().getClusterManagerNodeId() != null) + ); // all nodes have the same cluster-manager (in same term) assertEquals( "Not all cluster-managers in same term" + debugString, @@ -1742,7 +1745,7 @@ private void rebuildUnicastHostFiles(List newNodes) { .filter(Objects::nonNull) .map(TransportService::getLocalNode) .filter(Objects::nonNull) - .filter(DiscoveryNode::isMasterNode) + .filter(DiscoveryNode::isClusterManagerNode) .map(n -> n.getAddress().toString()) .distinct() .collect(Collectors.toList()); @@ -1964,7 +1967,7 @@ public String getMasterName() { public String getMasterName(@Nullable String viaNode) { try { Client client = viaNode != null ? client(viaNode) : client(); - return client.admin().cluster().prepareState().get().getState().nodes().getMasterNode().getName(); + return client.admin().cluster().prepareState().get().getState().nodes().getClusterManagerNode().getName(); } catch (Exception e) { logger.warn("Can't fetch cluster state", e); throw new RuntimeException("Can't get cluster-manager node " + e.getMessage(), e); @@ -2022,7 +2025,7 @@ private List bootstrapClusterManagerNodeWithSpecifiedIndex(List newSettings = new ArrayList<>(); for (Settings settings : allNodesSettings) { - if (DiscoveryNode.isMasterNode(settings) == false) { + if (DiscoveryNode.isClusterManagerNode(settings) == false) { newSettings.add(settings); } else { currentNodeId++; @@ -2032,13 +2035,13 @@ private List bootstrapClusterManagerNodeWithSpecifiedIndex(List nodeNames = new ArrayList<>(); for (Settings nodeSettings : getDataOrMasterNodeInstances(Settings.class)) { - if (DiscoveryNode.isMasterNode(nodeSettings)) { + if (DiscoveryNode.isClusterManagerNode(nodeSettings)) { nodeNames.add(Node.NODE_NAME_SETTING.get(nodeSettings)); } } for (Settings nodeSettings : allNodesSettings) { - if (DiscoveryNode.isMasterNode(nodeSettings)) { + if (DiscoveryNode.isClusterManagerNode(nodeSettings)) { nodeNames.add(Node.NODE_NAME_SETTING.get(nodeSettings)); } } @@ -2097,7 +2100,7 @@ public List startNodes(int numOfNodes, Settings settings) { * Starts multiple nodes with the given settings and returns their names */ public synchronized List startNodes(Settings... extraSettings) { - final int newClusterManagerCount = Math.toIntExact(Stream.of(extraSettings).filter(DiscoveryNode::isMasterNode).count()); + final int newClusterManagerCount = Math.toIntExact(Stream.of(extraSettings).filter(DiscoveryNode::isClusterManagerNode).count()); final int defaultMinClusterManagerNodes; if (autoManageClusterManagerNodes) { defaultMinClusterManagerNodes = getMinClusterManagerNodes(getClusterManagerNodesCount() + newClusterManagerCount); @@ -2110,7 +2113,7 @@ public synchronized List startNodes(Settings... extraSettings) { && prevClusterManagerCount == 0 && newClusterManagerCount > 0 && Arrays.stream(extraSettings) - .allMatch(s -> DiscoveryNode.isMasterNode(s) == false || ZEN2_DISCOVERY_TYPE.equals(DISCOVERY_TYPE_SETTING.get(s))) + .allMatch(s -> DiscoveryNode.isClusterManagerNode(s) == false || ZEN2_DISCOVERY_TYPE.equals(DISCOVERY_TYPE_SETTING.get(s))) ? RandomNumbers.randomIntBetween(random, 0, newClusterManagerCount - 1) : -1; @@ -2123,7 +2126,7 @@ public synchronized List startNodes(Settings... extraSettings) { nextNodeId.set(firstNodeId + numOfNodes); final List initialClusterManagerNodes = settings.stream() - .filter(DiscoveryNode::isMasterNode) + .filter(DiscoveryNode::isClusterManagerNode) .map(Node.NODE_NAME_SETTING::get) .collect(Collectors.toList()); @@ -2132,7 +2135,7 @@ public synchronized List startNodes(Settings... extraSettings) { for (int i = 0; i < numOfNodes; i++) { final Settings nodeSettings = updatedSettings.get(i); final Builder builder = Settings.builder(); - if (DiscoveryNode.isMasterNode(nodeSettings)) { + if (DiscoveryNode.isClusterManagerNode(nodeSettings)) { if (autoBootstrapClusterManagerNodeIndex == 0) { builder.putList(INITIAL_CLUSTER_MANAGER_NODES_SETTING.getKey(), initialClusterManagerNodes); } @@ -2176,7 +2179,7 @@ private static int getMinClusterManagerNodes(int eligibleClusterManagerNodes) { } private int getClusterManagerNodesCount() { - return (int) nodes.values().stream().filter(n -> DiscoveryNode.isMasterNode(n.node().settings())).count(); + return (int) nodes.values().stream().filter(n -> DiscoveryNode.isClusterManagerNode(n.node().settings())).count(); } public String startClusterManagerOnlyNode() { diff --git a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java index 3fcc0635f090e..e5c246fc79216 100644 --- a/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java +++ b/test/framework/src/main/java/org/opensearch/test/OpenSearchIntegTestCase.java @@ -1100,7 +1100,7 @@ protected void ensureClusterStateConsistency() throws IOException { clusterManagerClusterState = ClusterState.Builder.fromBytes(masterClusterStateBytes, null, namedWriteableRegistry); Map clusterManagerStateMap = convertToMap(clusterManagerClusterState); int clusterManagerClusterStateSize = clusterManagerClusterState.toString().length(); - String clusterManagerId = clusterManagerClusterState.nodes().getMasterNodeId(); + String clusterManagerId = clusterManagerClusterState.nodes().getClusterManagerNodeId(); for (Client client : cluster().getClients()) { ClusterState localClusterState = client.admin().cluster().prepareState().all().setLocal(true).get().getState(); byte[] localClusterStateBytes = ClusterState.Builder.toBytes(localClusterState); @@ -1112,7 +1112,7 @@ protected void ensureClusterStateConsistency() throws IOException { // that the cluster-manager node matches the cluster-manager (otherwise there is no requirement for the cluster state to // match) if (clusterManagerClusterState.version() == localClusterState.version() - && clusterManagerId.equals(localClusterState.nodes().getMasterNodeId())) { + && clusterManagerId.equals(localClusterState.nodes().getClusterManagerNodeId())) { try { assertEquals( "cluster state UUID does not match", diff --git a/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java b/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java index 262008507753e..a0b392f3fa669 100644 --- a/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java +++ b/test/framework/src/test/java/org/opensearch/test/test/InternalTestClusterTests.java @@ -439,7 +439,7 @@ public Path nodeConfigPath(int nodeOrdinal) { for (String name : cluster.getNodeNames()) { DiscoveryNode node = cluster.getInstance(ClusterService.class, name).localNode(); List paths = Arrays.stream(getNodePaths(cluster, name)).map(Path::toString).collect(Collectors.toList()); - if (node.isMasterNode()) { + if (node.isClusterManagerNode()) { result.computeIfAbsent(clusterManagerRole, k -> new HashSet<>()).addAll(paths); } else if (node.isDataNode()) { result.computeIfAbsent(DiscoveryNodeRole.DATA_ROLE, k -> new HashSet<>()).addAll(paths);