Skip to content

Commit e65aaca

Browse files
author
Tianli Feng
authored
Deprecate public methods and variables that contain 'master' terminology in class 'NoMasterBlockService' and 'MasterService' (#4006)
Deprecates public methods and variables that contain 'master' terminology in class NoMasterBlockService and MasterService. Unit tests are also added to ensure consistency with the new naming. Signed-off-by: Tianli Feng <[email protected]>
1 parent fb7d81a commit e65aaca

24 files changed

+159
-93
lines changed

modules/rank-eval/src/test/java/org/opensearch/index/rankeval/RankEvalResponseTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
public class RankEvalResponseTests extends OpenSearchTestCase {
7777

7878
private static final Exception[] RANDOM_EXCEPTIONS = new Exception[] {
79-
new ClusterBlockException(singleton(NoClusterManagerBlockService.NO_MASTER_BLOCK_WRITES)),
79+
new ClusterBlockException(singleton(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_WRITES)),
8080
new CircuitBreakingException("Data too large", 123, 456, CircuitBreaker.Durability.PERMANENT),
8181
new SearchParseException(SHARD_TARGET, "Parse failure", new XContentLocation(12, 98)),
8282
new IllegalArgumentException("Closed resource", new RuntimeException("Resource")),

server/src/internalClusterTest/java/org/opensearch/cluster/ClusterStateDiffIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,9 @@ private ClusterState.Builder randomBlocks(ClusterState clusterState) {
396396
private ClusterBlock randomGlobalBlock() {
397397
switch (randomInt(2)) {
398398
case 0:
399-
return NoClusterManagerBlockService.NO_MASTER_BLOCK_ALL;
399+
return NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ALL;
400400
case 1:
401-
return NoClusterManagerBlockService.NO_MASTER_BLOCK_WRITES;
401+
return NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_WRITES;
402402
default:
403403
return GatewayService.STATE_NOT_RECOVERED_BLOCK;
404404
}

server/src/internalClusterTest/java/org/opensearch/cluster/MinimumClusterManagerNodesIT.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public void testTwoNodesNoClusterManagerBlock() throws Exception {
9393

9494
logger.info("--> should be blocked, no cluster-manager...");
9595
ClusterState state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
96-
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(true));
96+
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID), equalTo(true));
9797
assertThat(state.nodes().getSize(), equalTo(1)); // verify that we still see the local node in the cluster state
9898

9999
logger.info("--> start second node, cluster should be formed");
@@ -109,9 +109,9 @@ public void testTwoNodesNoClusterManagerBlock() throws Exception {
109109
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
110110

111111
state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
112-
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
112+
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID), equalTo(false));
113113
state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
114-
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
114+
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID), equalTo(false));
115115

116116
state = client().admin().cluster().prepareState().execute().actionGet().getState();
117117
assertThat(state.nodes().getSize(), equalTo(2));
@@ -161,11 +161,11 @@ public void testTwoNodesNoClusterManagerBlock() throws Exception {
161161

162162
assertBusy(() -> {
163163
ClusterState clusterState = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
164-
assertTrue(clusterState.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID));
164+
assertTrue(clusterState.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID));
165165
});
166166

167167
state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
168-
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(true));
168+
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID), equalTo(true));
169169
// verify that both nodes are still in the cluster state but there is no cluster-manager
170170
assertThat(state.nodes().getSize(), equalTo(2));
171171
assertThat(state.nodes().getClusterManagerNode(), equalTo(null));
@@ -184,9 +184,9 @@ public void testTwoNodesNoClusterManagerBlock() throws Exception {
184184
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
185185

186186
state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
187-
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
187+
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID), equalTo(false));
188188
state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
189-
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
189+
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID), equalTo(false));
190190

191191
state = client().admin().cluster().prepareState().execute().actionGet().getState();
192192
assertThat(state.nodes().getSize(), equalTo(2));
@@ -214,7 +214,7 @@ public void testTwoNodesNoClusterManagerBlock() throws Exception {
214214

215215
assertBusy(() -> {
216216
ClusterState state1 = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
217-
assertThat(state1.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(true));
217+
assertThat(state1.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID), equalTo(true));
218218
});
219219

220220
logger.info("--> starting the previous cluster-manager node again...");
@@ -232,9 +232,9 @@ public void testTwoNodesNoClusterManagerBlock() throws Exception {
232232
assertThat(clusterHealthResponse.isTimedOut(), equalTo(false));
233233

234234
state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
235-
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
235+
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID), equalTo(false));
236236
state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
237-
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(false));
237+
assertThat(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID), equalTo(false));
238238

239239
state = client().admin().cluster().prepareState().execute().actionGet().getState();
240240
assertThat(state.nodes().getSize(), equalTo(2));
@@ -262,7 +262,7 @@ public void testThreeNodesNoClusterManagerBlock() throws Exception {
262262
assertBusy(() -> {
263263
for (Client client : clients()) {
264264
ClusterState state1 = client.admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
265-
assertThat(state1.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(true));
265+
assertThat(state1.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID), equalTo(true));
266266
}
267267
});
268268

@@ -324,7 +324,7 @@ public void testThreeNodesNoClusterManagerBlock() throws Exception {
324324
// spin here to wait till the state is set
325325
assertBusy(() -> {
326326
ClusterState st = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
327-
assertThat(st.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID), equalTo(true));
327+
assertThat(st.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID), equalTo(true));
328328
});
329329

330330
logger.info("--> start back the 2 nodes ");

server/src/internalClusterTest/java/org/opensearch/cluster/NoClusterManagerNodeIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public void testNoClusterManagerActions() throws Exception {
117117
.execute()
118118
.actionGet()
119119
.getState();
120-
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID));
120+
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID));
121121
});
122122

123123
assertRequestBuilderThrows(
@@ -288,7 +288,7 @@ public void testNoClusterManagerActionsWriteClusterManagerBlock() throws Excepti
288288

289289
assertBusy(() -> {
290290
ClusterState state = clientToClusterManagerlessNode.admin().cluster().prepareState().setLocal(true).get().getState();
291-
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID));
291+
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID));
292292
});
293293

294294
GetResponse getResponse = clientToClusterManagerlessNode.prepareGet("test1", "1").get();
@@ -387,7 +387,7 @@ public void testNoClusterManagerActionsMetadataWriteClusterManagerBlock() throws
387387
assertBusy(() -> {
388388
for (String node : nodesWithShards) {
389389
ClusterState state = client(node).admin().cluster().prepareState().setLocal(true).get().getState();
390-
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID));
390+
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID));
391391
}
392392
});
393393

server/src/internalClusterTest/java/org/opensearch/cluster/coordination/UnsafeBootstrapAndDetachCommandIT.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public void testBootstrapNotBootstrappedCluster() throws Exception {
220220
);
221221
assertBusy(() -> {
222222
ClusterState state = client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
223-
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID));
223+
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID));
224224
});
225225

226226
Settings dataPathSettings = internalCluster().dataPathSettings(node);
@@ -338,7 +338,7 @@ public void test3ClusterManagerNodes2Failed() throws Exception {
338338
.execute()
339339
.actionGet()
340340
.getState();
341-
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID));
341+
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID));
342342
});
343343

344344
logger.info("--> try to unsafely bootstrap 1st cluster-manager-eligible node, while node lock is held");
@@ -394,7 +394,7 @@ public void test3ClusterManagerNodes2Failed() throws Exception {
394394
.execute()
395395
.actionGet()
396396
.getState();
397-
assertFalse(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID));
397+
assertFalse(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID));
398398
assertTrue(
399399
state.metadata().persistentSettings().getAsBoolean(UnsafeBootstrapClusterManagerCommand.UNSAFE_BOOTSTRAP.getKey(), false)
400400
);
@@ -508,7 +508,7 @@ public void testNoInitialBootstrapAfterDetach() throws Exception {
508508
);
509509

510510
ClusterState state = internalCluster().client().admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
511-
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID));
511+
assertTrue(state.blocks().hasGlobalBlockWithId(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID));
512512

513513
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(node));
514514
}

server/src/internalClusterTest/java/org/opensearch/discovery/ClusterManagerDisruptionIT.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,11 @@ public void testVerifyApiBlocksDuringPartition() throws Exception {
234234
// continuously ping until network failures have been resolved. However
235235
// It may a take a bit before the node detects it has been cut off from the elected cluster-manager
236236
logger.info("waiting for isolated node [{}] to have no cluster-manager", isolatedNode);
237-
assertNoClusterManager(isolatedNode, NoClusterManagerBlockService.NO_MASTER_BLOCK_METADATA_WRITES, TimeValue.timeValueSeconds(30));
237+
assertNoClusterManager(
238+
isolatedNode,
239+
NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_METADATA_WRITES,
240+
TimeValue.timeValueSeconds(30)
241+
);
238242

239243
logger.info("wait until elected cluster-manager has been removed and a new 2 node cluster was from (via [{}])", isolatedNode);
240244
ensureStableCluster(2, nonIsolatedNode);
@@ -280,7 +284,7 @@ public void testVerifyApiBlocksDuringPartition() throws Exception {
280284
// continuously ping until network failures have been resolved. However
281285
// It may a take a bit before the node detects it has been cut off from the elected cluster-manager
282286
logger.info("waiting for isolated node [{}] to have no cluster-manager", isolatedNode);
283-
assertNoClusterManager(isolatedNode, NoClusterManagerBlockService.NO_MASTER_BLOCK_ALL, TimeValue.timeValueSeconds(30));
287+
assertNoClusterManager(isolatedNode, NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ALL, TimeValue.timeValueSeconds(30));
284288

285289
// make sure we have stable cluster & cross partition recoveries are canceled by the removal of the missing node
286290
// the unresponsive partition causes recoveries to only time out after 15m (default) and these will cause

server/src/main/java/org/opensearch/cluster/coordination/Coordinator.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
import java.util.stream.Stream;
106106
import java.util.stream.StreamSupport;
107107

108-
import static org.opensearch.cluster.coordination.NoClusterManagerBlockService.NO_MASTER_BLOCK_ID;
108+
import static org.opensearch.cluster.coordination.NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID;
109109
import static org.opensearch.gateway.ClusterStateUpdaters.hideStateIfNotRecovered;
110110
import static org.opensearch.gateway.GatewayService.STATE_NOT_RECOVERED_BLOCK;
111111
import static org.opensearch.monitor.StatusInfo.Status.UNHEALTHY;
@@ -839,7 +839,7 @@ protected void doStart() {
839839
.blocks(
840840
ClusterBlocks.builder()
841841
.addGlobalBlock(STATE_NOT_RECOVERED_BLOCK)
842-
.addGlobalBlock(noClusterManagerBlockService.getNoMasterBlock())
842+
.addGlobalBlock(noClusterManagerBlockService.getNoClusterManagerBlock())
843843
)
844844
.nodes(DiscoveryNodes.builder().add(getLocalNode()).localNodeId(getLocalNode().getId()))
845845
.build();
@@ -886,7 +886,7 @@ public void invariant() {
886886
assert followersChecker.getFastResponseState().term == getCurrentTerm() : followersChecker.getFastResponseState();
887887
assert followersChecker.getFastResponseState().mode == getMode() : followersChecker.getFastResponseState();
888888
assert (applierState.nodes().getClusterManagerNodeId() == null) == applierState.blocks()
889-
.hasGlobalBlockWithId(NO_MASTER_BLOCK_ID);
889+
.hasGlobalBlockWithId(NO_CLUSTER_MANAGER_BLOCK_ID);
890890
assert preVoteCollector.getPreVoteResponse().equals(getPreVoteResponse()) : preVoteCollector + " vs " + getPreVoteResponse();
891891

892892
assert lagDetector.getTrackedNodes().contains(getLocalNode()) == false : lagDetector.getTrackedNodes();
@@ -1221,11 +1221,11 @@ ClusterState getStateForClusterManagerService() {
12211221
private ClusterState clusterStateWithNoClusterManagerBlock(ClusterState clusterState) {
12221222
if (clusterState.nodes().getClusterManagerNodeId() != null) {
12231223
// remove block if it already exists before adding new one
1224-
assert clusterState.blocks().hasGlobalBlockWithId(NO_MASTER_BLOCK_ID) == false
1224+
assert clusterState.blocks().hasGlobalBlockWithId(NO_CLUSTER_MANAGER_BLOCK_ID) == false
12251225
: "NO_MASTER_BLOCK should only be added by Coordinator";
12261226
final ClusterBlocks clusterBlocks = ClusterBlocks.builder()
12271227
.blocks(clusterState.blocks())
1228-
.addGlobalBlock(noClusterManagerBlockService.getNoMasterBlock())
1228+
.addGlobalBlock(noClusterManagerBlockService.getNoClusterManagerBlock())
12291229
.build();
12301230
final DiscoveryNodes discoveryNodes = new DiscoveryNodes.Builder(clusterState.nodes()).clusterManagerNodeId(null).build();
12311231
return ClusterState.builder(clusterState).blocks(clusterBlocks).nodes(discoveryNodes).build();

server/src/main/java/org/opensearch/cluster/coordination/JoinTaskExecutor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ protected ClusterState.Builder becomeClusterManagerAndTrimConflictingNodes(Clust
285285
ClusterState tmpState = ClusterState.builder(currentState)
286286
.nodes(nodesBuilder)
287287
.blocks(
288-
ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(NoClusterManagerBlockService.NO_MASTER_BLOCK_ID)
288+
ClusterBlocks.builder()
289+
.blocks(currentState.blocks())
290+
.removeGlobalBlock(NoClusterManagerBlockService.NO_CLUSTER_MANAGER_BLOCK_ID)
289291
)
290292
.build();
291293
logger.trace("becomeClusterManagerAndTrimConflictingNodes: {}", tmpState.nodes());

0 commit comments

Comments
 (0)