Skip to content

Commit

Permalink
Changed master nomenclature to cluster_manager (#116)
Browse files Browse the repository at this point in the history
Signed-off-by: Dhrubajyoti Das <dhruvdas@amazon.com>

Co-authored-by: Dhrubajyoti Das <dhruvdas@amazon.com>
  • Loading branch information
dhruv16dhr and Dhrubajyoti Das committed Mar 22, 2022
1 parent e9a7982 commit 1c28a08
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@

/**
* The service takes care of cancelling ongoing searches which have been running past their expiration time and
* cleaning up asynchronous search responses from disk by scheduling delete-by-query on master to be delegated to the least loaded node
* cleaning up asynchronous search responses from disk by scheduling delete-by-query on cluster_manager to be
* delegated to the least loaded node
*/
public class AsynchronousSearchManagementService extends AbstractLifecycleComponent implements ClusterStateListener {

Expand Down Expand Up @@ -128,8 +129,8 @@ private void performPersistedResponseCleanUpAction(AsynchronousSearchCleanUpRequ
@Override
public void clusterChanged(ClusterChangedEvent event) {
if (event.localNodeMaster() && persistedResponseCleanUpRunnable.get() == null) {
logger.trace("elected as master, triggering response cleanup tasks");
triggerCleanUp(event.state(), "became master");
logger.trace("elected as cluster_manager, triggering response cleanup tasks");
triggerCleanUp(event.state(), "became cluster_manager");

final PersistedResponseCleanUpAndRescheduleRunnable newRunnable = new PersistedResponseCleanUpAndRescheduleRunnable();
persistedResponseCleanUpRunnable.set(newRunnable);
Expand Down Expand Up @@ -274,7 +275,7 @@ protected void doRun() {
if (this == persistedResponseCleanUpRunnable.get()) {
super.doRun();
} else {
logger.trace("master changed, scheduled cleanup job is stale");
logger.trace("cluster_manager changed, scheduled cleanup job is stale");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ private static ClusterState createSimpleClusterState() {
}

// Create a basic cluster state with a given set of indices
private static ClusterState createState(final int numNodes, final boolean isLocalMaster, final List<Index> indices) {
private static ClusterState createState(final int numNodes, final boolean isLocalClusterManager, final List<Index> indices) {
final Metadata metadata = createMetadata(indices);
return ClusterState.builder(TEST_CLUSTER_NAME)
.nodes(createDiscoveryNodes(numNodes, isLocalMaster))
.nodes(createDiscoveryNodes(numNodes, isLocalClusterManager))
.metadata(metadata)
.routingTable(createRoutingTable(1, metadata))
.build();
Expand Down Expand Up @@ -204,13 +204,15 @@ private static RoutingTable createRoutingTable(final long version, final Metadat
}

// Create the discovery nodes for a cluster state. For our testing purposes, we want
// the first to be master, the second to be master eligible, the third to be a data node,
// and the remainder can be any kinds of nodes (master eligible, data, or both).
private static DiscoveryNodes createDiscoveryNodes(final int numNodes, final boolean isLocalMaster) {
// the first to be cluster_manager, the second to be cluster_manager eligible, the third to be a data node,
// and the remainder can be any kinds of nodes (cluster_manager eligible, data, or both).
private static DiscoveryNodes createDiscoveryNodes(final int numNodes, final boolean isLocalClusterManager) {
assert (numNodes >= 3) : "the initial cluster state for event change tests should have a minimum of 3 nodes " +
"so there are a minimum of 2 master nodes for testing master change events.";
"so there are a minimum of 2 cluster_manager nodes for testing cluster_manager change events.";
final DiscoveryNodes.Builder builder = DiscoveryNodes.builder();
final int masterNodeIndex = isLocalMaster ? 0 : randomIntBetween(1, numNodes - 1); // randomly assign the local node if not master

// randomly assign the local node if not cluster_manager
final int clusterManagerNodeIndex = isLocalClusterManager ? 0 : randomIntBetween(1, numNodes - 1);
for (int i = 0; i < numNodes; i++) {
final String nodeId = NODE_ID_PREFIX + i;
Set<DiscoveryNodeRole> roles = new HashSet<>();
Expand All @@ -219,13 +221,13 @@ private static DiscoveryNodes createDiscoveryNodes(final int numNodes, final boo
builder.localNodeId(nodeId);
roles.add(DiscoveryNodeRole.MASTER_ROLE);
} else if (i == 1) {
// the alternate master node
// the alternate cluster_manager node
roles.add(DiscoveryNodeRole.MASTER_ROLE);
} else if (i == 2) {
// we need at least one data node
roles.add(DiscoveryNodeRole.DATA_ROLE);
} else {
// remaining nodes can be anything (except for master)
// remaining nodes can be anything (except for cluster_manager)
if (randomBoolean()) {
roles.add(DiscoveryNodeRole.MASTER_ROLE);
}
Expand All @@ -235,7 +237,7 @@ private static DiscoveryNodes createDiscoveryNodes(final int numNodes, final boo
}
final DiscoveryNode node = newNode(nodeId, roles);
builder.add(node);
if (i == masterNodeIndex) {
if (i == clusterManagerNodeIndex) {
builder.masterNodeId(nodeId);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ Params withFields(String[] fields) {
return this;
}

Params withMasterTimeout(TimeValue masterTimeout) {
return putParam("master_timeout", masterTimeout);
Params withClusterManagerTimeout(TimeValue clusterManagerTimeout) {
return putParam("cluster_manager_timeout", clusterManagerTimeout);
}

Params withPipeline(String pipeline) {
Expand Down

0 comments on commit 1c28a08

Please sign in to comment.