Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename BecomeMasterTask to BecomeClusterManagerTask in JoinTaskExecutor #3099

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,19 @@ public String toString() {
}

public boolean isBecomeMasterTask() {
return reason.equals(BECOME_MASTER_TASK_REASON);
return reason.equals(BECOME_MASTER_TASK_REASON) || reason.equals(BECOME_CLUSTER_MANAGER_TASK_REASON);
}

public boolean isFinishElectionTask() {
return reason.equals(FINISH_ELECTION_TASK_REASON);
}

/**
* @deprecated As of 2.0, because supporting inclusive language, replaced by {@link #BECOME_CLUSTER_MANAGER_TASK_REASON}
*/
@Deprecated
private static final String BECOME_MASTER_TASK_REASON = "_BECOME_MASTER_TASK_";
private static final String BECOME_CLUSTER_MANAGER_TASK_REASON = "_BECOME_CLUSTER_MANAGER_TASK_";
private static final String FINISH_ELECTION_TASK_REASON = "_FINISH_ELECTION_";
}

Expand Down Expand Up @@ -331,10 +336,22 @@ public boolean runOnlyOnMaster() {
return false;
}

/**
* a task indicates that the current node should become master
* @deprecated As of 2.0, because supporting inclusive language, replaced by {@link #newBecomeClusterManagerTask()}
*/
@Deprecated
public static Task newBecomeMasterTask() {
return new Task(null, Task.BECOME_MASTER_TASK_REASON);
}

/**
* a task indicates that the current node should become cluster-manager
*/
public static Task newBecomeClusterManagerTask() {
return new Task(null, Task.BECOME_CLUSTER_MANAGER_TASK_REASON);
}

/**
* 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()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@

import java.util.HashSet;

import static org.hamcrest.Matchers.is;
import static org.opensearch.test.VersionUtils.allVersions;
import static org.opensearch.test.VersionUtils.maxCompatibleVersion;
import static org.opensearch.test.VersionUtils.randomCompatibleVersion;
Expand Down Expand Up @@ -198,4 +199,14 @@ public void testUpdatesNodeWithNewRoles() throws Exception {

assertThat(result.resultingState.getNodes().get(actualNode.getId()).getRoles(), equalTo(actualNode.getRoles()));
}

/**
* Validate isBecomeMasterTask() can identify "become cluster manager task" properly
*/
public void testIsBecomeClusterManagerTask() {
JoinTaskExecutor.Task joinTaskOfMaster = JoinTaskExecutor.newBecomeMasterTask();
assertThat(joinTaskOfMaster.isBecomeMasterTask(), is(true));
JoinTaskExecutor.Task joinTaskOfClusterManager = JoinTaskExecutor.newBecomeClusterManagerTask();
assertThat(joinTaskOfClusterManager.isBecomeMasterTask(), is(true));
}
}