Skip to content

Commit

Permalink
return mutex to package-private, replace with test infra helper metho…
Browse files Browse the repository at this point in the history
…d; slight comment improvement
  • Loading branch information
DiannaHohensee committed Mar 27, 2024
1 parent f20dbcf commit 27ad24f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public class Coordinator extends AbstractLifecycleComponent implements ClusterSt
private final MasterServiceTaskQueue<NodeLeftExecutor.Task> nodeLeftQueue;
private final Supplier<CoordinationState.PersistedState> persistedStateSupplier;
private final NoMasterBlockService noMasterBlockService;
public final Object mutex = new Object(); // public to allow tests to call methods that assert that the mutex is held
final Object mutex = new Object(); // package-private to allow tests to call methods that assert that the mutex is held
private final SetOnce<CoordinationState> coordinationState = new SetOnce<>(); // initialized on start-up (see doStart)
private volatile ClusterState applierState; // the state that should be exposed to the cluster state applier

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,6 @@ public NodeEligibility nodeMayWinElection(ClusterState lastAcceptedState, Discov
return new NodeEligibility(true, "");
}

return new NodeEligibility(false, "node is ineligible for election, not part of the voting configuration");
return new NodeEligibility(false, "node is ineligible for election, not a voting node in the voting configuration");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ List<ClusterNode> addNodes(int newNodesCount) {
return addedNodes;
}

public static void becomeCandidate(ClusterNode node, String reason) {
synchronized (node.coordinator.mutex) {
node.coordinator.becomeCandidate(reason);
}
}

public int size() {
return clusterNodes.size();
}
Expand Down

0 comments on commit 27ad24f

Please sign in to comment.