Remove DiscoveryNodes#masterNode in favour of existing DiscoveryNodes#getMasterNode
This commit is contained in:
parent
7ebc094353
commit
62ac7d219f
|
@ -168,12 +168,12 @@ public abstract class TransportMasterNodeAction<Request extends MasterNodeReques
|
|||
});
|
||||
}
|
||||
} else {
|
||||
if (nodes.masterNode() == null) {
|
||||
if (nodes.getMasterNode() == null) {
|
||||
logger.debug("no known master node, scheduling a retry");
|
||||
retry(null, MasterNodeChangePredicate.INSTANCE);
|
||||
} else {
|
||||
taskManager.registerChildTask(task, nodes.masterNode().getId());
|
||||
transportService.sendRequest(nodes.masterNode(), actionName, request, new ActionListenerResponseHandler<Response>(listener) {
|
||||
taskManager.registerChildTask(task, nodes.getMasterNode().getId());
|
||||
transportService.sendRequest(nodes.getMasterNode(), actionName, request, new ActionListenerResponseHandler<Response>(listener) {
|
||||
@Override
|
||||
public Response newInstance() {
|
||||
return newResponse();
|
||||
|
@ -185,7 +185,7 @@ public abstract class TransportMasterNodeAction<Request extends MasterNodeReques
|
|||
if (cause instanceof ConnectTransportException) {
|
||||
// we want to retry here a bit to see if a new master is elected
|
||||
logger.debug("connection exception while trying to forward request with action name [{}] to master node [{}], scheduling a retry. Error: [{}]",
|
||||
actionName, nodes.masterNode(), exp.getDetailedMessage());
|
||||
actionName, nodes.getMasterNode(), exp.getDetailedMessage());
|
||||
retry(cause, MasterNodeChangePredicate.INSTANCE);
|
||||
} else {
|
||||
listener.onFailure(exp);
|
||||
|
|
|
@ -78,7 +78,7 @@ public class NodeIndexDeletedAction extends AbstractComponent {
|
|||
|
||||
public void nodeIndexDeleted(final ClusterState clusterState, final Index index, final IndexSettings indexSettings, final String nodeId) {
|
||||
final DiscoveryNodes nodes = clusterState.nodes();
|
||||
transportService.sendRequest(clusterState.nodes().masterNode(),
|
||||
transportService.sendRequest(clusterState.nodes().getMasterNode(),
|
||||
INDEX_DELETED_ACTION_NAME, new NodeIndexDeletedMessage(index, nodeId), EmptyTransportResponseHandler.INSTANCE_SAME);
|
||||
if (nodes.getLocalNode().isDataNode() == false) {
|
||||
logger.trace("[{}] not acking store deletion (not a data node)", index);
|
||||
|
@ -104,7 +104,7 @@ public class NodeIndexDeletedAction extends AbstractComponent {
|
|||
// due to a "currently canceled recovery" or so. The shard will delete itself BEFORE the lock is released so it's guaranteed to be
|
||||
// deleted by the time we get the lock
|
||||
indicesService.processPendingDeletes(indexSettings.getIndex(), indexSettings, new TimeValue(30, TimeUnit.MINUTES));
|
||||
transportService.sendRequest(clusterState.nodes().masterNode(),
|
||||
transportService.sendRequest(clusterState.nodes().getMasterNode(),
|
||||
INDEX_STORE_DELETED_ACTION_NAME, new NodeIndexStoreDeletedMessage(index, nodeId), EmptyTransportResponseHandler.INSTANCE_SAME);
|
||||
} catch (LockObtainFailedException exc) {
|
||||
logger.warn("[{}] failed to lock all shards for index - timed out after 30 seconds", index);
|
||||
|
|
|
@ -60,11 +60,11 @@ public class NodeMappingRefreshAction extends AbstractComponent {
|
|||
|
||||
public void nodeMappingRefresh(final ClusterState state, final NodeMappingRefreshRequest request) {
|
||||
final DiscoveryNodes nodes = state.nodes();
|
||||
if (nodes.masterNode() == null) {
|
||||
if (nodes.getMasterNode() == null) {
|
||||
logger.warn("can't send mapping refresh for [{}], no master known.", request.index());
|
||||
return;
|
||||
}
|
||||
transportService.sendRequest(nodes.masterNode(), ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME);
|
||||
transportService.sendRequest(nodes.getMasterNode(), ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME);
|
||||
}
|
||||
|
||||
private class NodeMappingRefreshTransportHandler implements TransportRequestHandler<NodeMappingRefreshRequest> {
|
||||
|
|
|
@ -92,7 +92,7 @@ public class ShardStateAction extends AbstractComponent {
|
|||
}
|
||||
|
||||
private void sendShardAction(final String actionName, final ClusterStateObserver observer, final ShardRoutingEntry shardRoutingEntry, final Listener listener) {
|
||||
DiscoveryNode masterNode = observer.observedState().nodes().masterNode();
|
||||
DiscoveryNode masterNode = observer.observedState().nodes().getMasterNode();
|
||||
if (masterNode == null) {
|
||||
logger.warn("{} no master known for action [{}] for shard [{}]", shardRoutingEntry.getShardRouting().shardId(), actionName, shardRoutingEntry.getShardRouting());
|
||||
waitForNewMasterAndRetry(actionName, observer, shardRoutingEntry, listener);
|
||||
|
|
|
@ -197,22 +197,13 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
|||
return nodes.get(localNodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the master node
|
||||
*
|
||||
* @return master node
|
||||
*/
|
||||
public DiscoveryNode masterNode() {
|
||||
return nodes.get(masterNodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the master node
|
||||
*
|
||||
* @return master node
|
||||
*/
|
||||
public DiscoveryNode getMasterNode() {
|
||||
return masterNode();
|
||||
return nodes.get(masterNodeId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -383,8 +374,8 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
|||
DiscoveryNode newMasterNode = null;
|
||||
if (masterNodeId != null) {
|
||||
if (other.masterNodeId == null || !other.masterNodeId.equals(masterNodeId)) {
|
||||
previousMasterNode = other.masterNode();
|
||||
newMasterNode = masterNode();
|
||||
previousMasterNode = other.getMasterNode();
|
||||
newMasterNode = getMasterNode();
|
||||
}
|
||||
}
|
||||
return new Delta(previousMasterNode, newMasterNode, localNodeId, Collections.unmodifiableList(removed), Collections.unmodifiableList(added));
|
||||
|
@ -409,7 +400,7 @@ public class DiscoveryNodes extends AbstractDiffable<DiscoveryNodes> implements
|
|||
if (node == getLocalNode()) {
|
||||
sb.append(", local");
|
||||
}
|
||||
if (node == masterNode()) {
|
||||
if (node == getMasterNode()) {
|
||||
sb.append(", master");
|
||||
}
|
||||
sb.append("\n");
|
||||
|
|
|
@ -973,7 +973,7 @@ public class ClusterService extends AbstractLifecycleComponent<ClusterService> {
|
|||
public void onNodeAck(DiscoveryNode node, @Nullable Throwable t) {
|
||||
if (!ackedTaskListener.mustAck(node)) {
|
||||
//we always wait for the master ack anyway
|
||||
if (!node.equals(nodes.masterNode())) {
|
||||
if (!node.equals(nodes.getMasterNode())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -340,7 +340,7 @@ public class LocalDiscovery extends AbstractLifecycleComponent<Discovery> implem
|
|||
nodeSpecificClusterState.status(ClusterState.ClusterStateStatus.RECEIVED);
|
||||
// ignore cluster state messages that do not include "me", not in the game yet...
|
||||
if (nodeSpecificClusterState.nodes().getLocalNode() != null) {
|
||||
assert nodeSpecificClusterState.nodes().masterNode() != null : "received a cluster state without a master";
|
||||
assert nodeSpecificClusterState.nodes().getMasterNode() != null : "received a cluster state without a master";
|
||||
assert !nodeSpecificClusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock()) : "received a cluster state with a master block";
|
||||
|
||||
discovery.clusterService.submitStateUpdateTask("local-disco-receive(from master)", new ClusterStateUpdateTask() {
|
||||
|
|
|
@ -240,9 +240,9 @@ public class NodeJoinController extends AbstractComponent {
|
|||
// Take into account the previous known nodes, if they happen not to be available
|
||||
// then fault detection will remove these nodes.
|
||||
|
||||
if (currentState.nodes().masterNode() != null) {
|
||||
if (currentState.nodes().getMasterNode() != null) {
|
||||
// TODO can we tie break here? we don't have a remote master cluster state version to decide on
|
||||
logger.trace("join thread elected local node as master, but there is already a master in place: {}", currentState.nodes().masterNode());
|
||||
logger.trace("join thread elected local node as master, but there is already a master in place: {}", currentState.nodes().getMasterNode());
|
||||
throw new NotMasterException("Node [" + clusterService.localNode() + "] not master for join request");
|
||||
}
|
||||
|
||||
|
|
|
@ -242,13 +242,13 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
nodesFD.stop();
|
||||
DiscoveryNodes nodes = nodes();
|
||||
if (sendLeaveRequest) {
|
||||
if (nodes.masterNode() == null) {
|
||||
if (nodes.getMasterNode() == null) {
|
||||
// if we don't know who the master is, nothing to do here
|
||||
} else if (!nodes.localNodeMaster()) {
|
||||
try {
|
||||
membership.sendLeaveRequestBlocking(nodes.masterNode(), nodes.getLocalNode(), TimeValue.timeValueSeconds(1));
|
||||
membership.sendLeaveRequestBlocking(nodes.getMasterNode(), nodes.getLocalNode(), TimeValue.timeValueSeconds(1));
|
||||
} catch (Exception e) {
|
||||
logger.debug("failed to send leave request to master [{}]", e, nodes.masterNode());
|
||||
logger.debug("failed to send leave request to master [{}]", e, nodes.getMasterNode());
|
||||
}
|
||||
} else {
|
||||
// we're master -> let other potential master we left and start a master election now rather then wait for masterFD
|
||||
|
@ -260,7 +260,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
try {
|
||||
membership.sendLeaveRequest(nodes.getLocalNode(), possibleMaster);
|
||||
} catch (Exception e) {
|
||||
logger.debug("failed to send leave request from master [{}] to possible master [{}]", e, nodes.masterNode(), possibleMaster);
|
||||
logger.debug("failed to send leave request from master [{}] to possible master [{}]", e, nodes.getMasterNode(), possibleMaster);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -419,7 +419,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
return currentState;
|
||||
}
|
||||
|
||||
if (currentState.getNodes().masterNode() == null) {
|
||||
if (currentState.getNodes().getMasterNode() == null) {
|
||||
// Post 1.3.0, the master should publish a new cluster state before acking our join request. we now should have
|
||||
// a valid master.
|
||||
logger.debug("no master node is set, despite of join request completing. retrying pings.");
|
||||
|
@ -427,7 +427,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
return currentState;
|
||||
}
|
||||
|
||||
if (!currentState.getNodes().masterNode().equals(finalMasterNode)) {
|
||||
if (!currentState.getNodes().getMasterNode().equals(finalMasterNode)) {
|
||||
return joinThreadControl.stopRunningThreadAndRejoin(currentState, "master_switched_while_finalizing_join");
|
||||
}
|
||||
|
||||
|
@ -524,7 +524,7 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
logger.error("unexpected failure during [{}]", t, source);
|
||||
}
|
||||
});
|
||||
} else if (node.equals(nodes().masterNode())) {
|
||||
} else if (node.equals(nodes().getMasterNode())) {
|
||||
handleMasterGone(node, null, "shut_down");
|
||||
}
|
||||
}
|
||||
|
@ -680,11 +680,11 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
return currentState;
|
||||
}
|
||||
|
||||
assert newClusterState.nodes().masterNode() != null : "received a cluster state without a master";
|
||||
assert newClusterState.nodes().getMasterNode() != null : "received a cluster state without a master";
|
||||
assert !newClusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock()) : "received a cluster state with a master block";
|
||||
|
||||
if (currentState.nodes().localNodeMaster()) {
|
||||
return handleAnotherMaster(currentState, newClusterState.nodes().masterNode(), newClusterState.version(), "via a new cluster state");
|
||||
return handleAnotherMaster(currentState, newClusterState.nodes().getMasterNode(), newClusterState.version(), "via a new cluster state");
|
||||
}
|
||||
|
||||
if (shouldIgnoreOrRejectNewClusterState(logger, currentState, newClusterState)) {
|
||||
|
@ -692,8 +692,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
}
|
||||
|
||||
// check to see that we monitor the correct master of the cluster
|
||||
if (masterFD.masterNode() == null || !masterFD.masterNode().equals(newClusterState.nodes().masterNode())) {
|
||||
masterFD.restart(newClusterState.nodes().masterNode(), "new cluster state received and we are monitoring the wrong master [" + masterFD.masterNode() + "]");
|
||||
if (masterFD.masterNode() == null || !masterFD.masterNode().equals(newClusterState.nodes().getMasterNode())) {
|
||||
masterFD.restart(newClusterState.nodes().getMasterNode(), "new cluster state received and we are monitoring the wrong master [" + masterFD.masterNode() + "]");
|
||||
}
|
||||
|
||||
if (currentState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock())) {
|
||||
|
@ -787,8 +787,8 @@ public class ZenDiscovery extends AbstractLifecycleComponent<Discovery> implemen
|
|||
return;
|
||||
}
|
||||
if (!currentNodes.getMasterNodeId().equals(newClusterState.nodes().getMasterNodeId())) {
|
||||
logger.warn("received a cluster state from a different master than the current one, rejecting (received {}, current {})", newClusterState.nodes().masterNode(), currentNodes.masterNode());
|
||||
throw new IllegalStateException("cluster state from a different master than the current one, rejecting (received " + newClusterState.nodes().masterNode() + ", current " + currentNodes.masterNode() + ")");
|
||||
logger.warn("received a cluster state from a different master than the current one, rejecting (received {}, current {})", newClusterState.nodes().getMasterNode(), currentNodes.getMasterNode());
|
||||
throw new IllegalStateException("cluster state from a different master than the current one, rejecting (received " + newClusterState.nodes().getMasterNode() + ", current " + currentNodes.getMasterNode() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -565,7 +565,7 @@ public class UnicastZenPing extends AbstractLifecycleComponent<ZenPing> implemen
|
|||
}
|
||||
|
||||
private PingResponse createPingResponse(DiscoveryNodes discoNodes) {
|
||||
return new PingResponse(discoNodes.getLocalNode(), discoNodes.masterNode(), clusterName, contextProvider.nodeHasJoinedClusterOnce());
|
||||
return new PingResponse(discoNodes.getLocalNode(), discoNodes.getMasterNode(), clusterName, contextProvider.nodeHasJoinedClusterOnce());
|
||||
}
|
||||
|
||||
static class UnicastPingResponse extends TransportResponse {
|
||||
|
|
|
@ -138,7 +138,7 @@ public class PendingClusterStatesQueue {
|
|||
if (findState(state.stateUUID()) == null) {
|
||||
throw new IllegalStateException("can't resolve processed cluster state with uuid [" + state.stateUUID() + "], version [" + state.version() + "]");
|
||||
}
|
||||
final DiscoveryNode currentMaster = state.nodes().masterNode();
|
||||
final DiscoveryNode currentMaster = state.nodes().getMasterNode();
|
||||
assert currentMaster != null : "processed cluster state mast have a master. " + state;
|
||||
|
||||
// fail or remove any incoming state from a different master
|
||||
|
@ -147,7 +147,7 @@ public class PendingClusterStatesQueue {
|
|||
for (int index = 0; index < pendingStates.size(); index++) {
|
||||
final ClusterStateContext pendingContext = pendingStates.get(index);
|
||||
final ClusterState pendingState = pendingContext.state;
|
||||
final DiscoveryNode pendingMasterNode = pendingState.nodes().masterNode();
|
||||
final DiscoveryNode pendingMasterNode = pendingState.nodes().getMasterNode();
|
||||
if (Objects.equals(currentMaster, pendingMasterNode) == false) {
|
||||
contextsToRemove.add(pendingContext);
|
||||
if (pendingContext.committed()) {
|
||||
|
|
|
@ -391,13 +391,13 @@ public class PublishClusterStateAction extends AbstractComponent {
|
|||
void validateIncomingState(ClusterState incomingState, ClusterState lastSeenClusterState) {
|
||||
final ClusterName incomingClusterName = incomingState.getClusterName();
|
||||
if (!incomingClusterName.equals(this.clusterName)) {
|
||||
logger.warn("received cluster state from [{}] which is also master but with a different cluster name [{}]", incomingState.nodes().masterNode(), incomingClusterName);
|
||||
logger.warn("received cluster state from [{}] which is also master but with a different cluster name [{}]", incomingState.nodes().getMasterNode(), incomingClusterName);
|
||||
throw new IllegalStateException("received state from a node that is not part of the cluster");
|
||||
}
|
||||
final DiscoveryNodes currentNodes = nodesProvider.nodes();
|
||||
|
||||
if (currentNodes.getLocalNode().equals(incomingState.nodes().getLocalNode()) == false) {
|
||||
logger.warn("received a cluster state from [{}] and not part of the cluster, should not happen", incomingState.nodes().masterNode());
|
||||
logger.warn("received a cluster state from [{}] and not part of the cluster, should not happen", incomingState.nodes().getMasterNode());
|
||||
throw new IllegalStateException("received state from a node that is not part of the cluster");
|
||||
}
|
||||
|
||||
|
@ -427,7 +427,7 @@ public class PublishClusterStateAction extends AbstractComponent {
|
|||
}
|
||||
});
|
||||
if (state != null) {
|
||||
newPendingClusterStatelistener.onNewClusterState("master " + state.nodes().masterNode() + " committed version [" + state.version() + "]");
|
||||
newPendingClusterStatelistener.onNewClusterState("master " + state.nodes().getMasterNode() + " committed version [" + state.version() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ public class LocalAllocateDangledIndices extends AbstractComponent {
|
|||
|
||||
public void allocateDangled(Collection<IndexMetaData> indices, final Listener listener) {
|
||||
ClusterState clusterState = clusterService.state();
|
||||
DiscoveryNode masterNode = clusterState.nodes().masterNode();
|
||||
DiscoveryNode masterNode = clusterState.nodes().getMasterNode();
|
||||
if (masterNode == null) {
|
||||
listener.onFailure(new MasterNotDiscoveredException("no master to send allocate dangled request"));
|
||||
return;
|
||||
|
|
|
@ -483,14 +483,14 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
|||
|
||||
if (!indexService.hasShard(shardId) && shardRouting.started()) {
|
||||
if (failedShards.containsKey(shardRouting.shardId())) {
|
||||
if (nodes.masterNode() != null) {
|
||||
String message = "master " + nodes.masterNode() + " marked shard as started, but shard has previous failed. resending shard failure";
|
||||
if (nodes.getMasterNode() != null) {
|
||||
String message = "master " + nodes.getMasterNode() + " marked shard as started, but shard has previous failed. resending shard failure";
|
||||
logger.trace("[{}] re-sending failed shard [{}], reason [{}]", shardRouting.shardId(), shardRouting, message);
|
||||
shardStateAction.shardFailed(shardRouting, shardRouting, message, null, SHARD_STATE_ACTION_LISTENER);
|
||||
}
|
||||
} else {
|
||||
// the master thinks we are started, but we don't have this shard at all, mark it as failed
|
||||
sendFailShard(shardRouting, "master [" + nodes.masterNode() + "] marked shard as started, but shard has not been created, mark shard as failed", null);
|
||||
sendFailShard(shardRouting, "master [" + nodes.getMasterNode() + "] marked shard as started, but shard has not been created, mark shard as failed", null);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -547,11 +547,11 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
|||
// we managed to tell the master we started), mark us as started
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("{} master marked shard as initializing, but shard has state [{}], resending shard started to {}",
|
||||
indexShard.shardId(), indexShard.state(), nodes.masterNode());
|
||||
indexShard.shardId(), indexShard.state(), nodes.getMasterNode());
|
||||
}
|
||||
if (nodes.masterNode() != null) {
|
||||
if (nodes.getMasterNode() != null) {
|
||||
shardStateAction.shardStarted(shardRouting,
|
||||
"master " + nodes.masterNode() + " marked shard as initializing, but shard state is [" + indexShard.state() + "], mark shard as started",
|
||||
"master " + nodes.getMasterNode() + " marked shard as initializing, but shard state is [" + indexShard.state() + "], mark shard as started",
|
||||
SHARD_STATE_ACTION_LISTENER);
|
||||
}
|
||||
return;
|
||||
|
@ -576,8 +576,8 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
|||
// if there is no shard, create it
|
||||
if (!indexService.hasShard(shardId)) {
|
||||
if (failedShards.containsKey(shardRouting.shardId())) {
|
||||
if (nodes.masterNode() != null) {
|
||||
String message = "master " + nodes.masterNode() + " marked shard as initializing, but shard is marked as failed, resend shard failure";
|
||||
if (nodes.getMasterNode() != null) {
|
||||
String message = "master " + nodes.getMasterNode() + " marked shard as initializing, but shard is marked as failed, resend shard failure";
|
||||
logger.trace("[{}] re-sending failed shard [{}], reason [{}]", shardRouting.shardId(), shardRouting, message);
|
||||
shardStateAction.shardFailed(shardRouting, shardRouting, message, null, SHARD_STATE_ACTION_LISTENER);
|
||||
}
|
||||
|
|
|
@ -487,7 +487,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
|
|||
logger.trace("[{}] successfully restored shard [{}]", snapshotId, shardId);
|
||||
UpdateIndexShardRestoreStatusRequest request = new UpdateIndexShardRestoreStatusRequest(snapshotId, shardId,
|
||||
new ShardRestoreStatus(clusterService.state().nodes().getLocalNodeId(), RestoreInProgress.State.SUCCESS));
|
||||
transportService.sendRequest(clusterService.state().nodes().masterNode(),
|
||||
transportService.sendRequest(clusterService.state().nodes().getMasterNode(),
|
||||
UPDATE_RESTORE_ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME);
|
||||
}
|
||||
|
||||
|
@ -761,7 +761,7 @@ public class RestoreService extends AbstractComponent implements ClusterStateLis
|
|||
logger.debug("[{}] failed to restore shard [{}]", snapshotId, shardId);
|
||||
UpdateIndexShardRestoreStatusRequest request = new UpdateIndexShardRestoreStatusRequest(snapshotId, shardId,
|
||||
new ShardRestoreStatus(clusterService.state().nodes().getLocalNodeId(), RestoreInProgress.State.FAILURE));
|
||||
transportService.sendRequest(clusterService.state().nodes().masterNode(),
|
||||
transportService.sendRequest(clusterService.state().nodes().getMasterNode(),
|
||||
UPDATE_RESTORE_ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME);
|
||||
}
|
||||
|
||||
|
|
|
@ -480,7 +480,7 @@ public class SnapshotShardsService extends AbstractLifecycleComponent<SnapshotSh
|
|||
if (clusterService.state().nodes().localNodeMaster()) {
|
||||
innerUpdateSnapshotState(request);
|
||||
} else {
|
||||
transportService.sendRequest(clusterService.state().nodes().masterNode(),
|
||||
transportService.sendRequest(clusterService.state().nodes().getMasterNode(),
|
||||
UPDATE_SNAPSHOT_ACTION_NAME, request, EmptyTransportResponseHandler.INSTANCE_SAME);
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
|
|
|
@ -318,7 +318,7 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase {
|
|||
Request request = new Request(new String[]{TEST_INDEX});
|
||||
PlainActionFuture<Response> listener = new PlainActionFuture<>();
|
||||
|
||||
DiscoveryNode masterNode = clusterService.state().nodes().masterNode();
|
||||
DiscoveryNode masterNode = clusterService.state().nodes().getMasterNode();
|
||||
DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes());
|
||||
builder.remove(masterNode.getId());
|
||||
|
||||
|
@ -403,7 +403,7 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase {
|
|||
final boolean simulateFailedMasterNode = rarely();
|
||||
DiscoveryNode failedMasterNode = null;
|
||||
if (simulateFailedMasterNode) {
|
||||
failedMasterNode = clusterService.state().nodes().masterNode();
|
||||
failedMasterNode = clusterService.state().nodes().getMasterNode();
|
||||
DiscoveryNodes.Builder builder = DiscoveryNodes.builder(clusterService.state().getNodes());
|
||||
builder.remove(failedMasterNode.getId());
|
||||
builder.masterNodeId(null);
|
||||
|
|
|
@ -449,7 +449,7 @@ public class BasicBackwardsCompatibilityIT extends ESBackcompatTestCase {
|
|||
|
||||
|
||||
public Version getMasterVersion() {
|
||||
return client().admin().cluster().prepareState().get().getState().nodes().masterNode().getVersion();
|
||||
return client().admin().cluster().prepareState().get().getState().nodes().getMasterNode().getVersion();
|
||||
}
|
||||
|
||||
public void testDeleteRoutingRequired() throws ExecutionException, InterruptedException, IOException {
|
||||
|
|
|
@ -409,7 +409,7 @@ public class MinimumMasterNodesIT extends ESIntegTestCase {
|
|||
assertBusy(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
assertThat(masterClusterService.state().nodes().masterNode(), nullValue());
|
||||
assertThat(masterClusterService.state().nodes().getMasterNode(), nullValue());
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ public class SpecificMasterNodesIT extends ESIntegTestCase {
|
|||
}
|
||||
logger.info("--> start master node");
|
||||
final String masterNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true));
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName));
|
||||
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName));
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
|
||||
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
|
||||
|
||||
logger.info("--> stop master node");
|
||||
internalCluster().stopCurrentMasterNode();
|
||||
|
@ -68,8 +68,8 @@ public class SpecificMasterNodesIT extends ESIntegTestCase {
|
|||
|
||||
logger.info("--> start master node");
|
||||
final String nextMasterEligibleNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true));
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligibleNodeName));
|
||||
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligibleNodeName));
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligibleNodeName));
|
||||
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligibleNodeName));
|
||||
}
|
||||
|
||||
public void testElectOnlyBetweenMasterNodes() throws IOException {
|
||||
|
@ -83,19 +83,19 @@ public class SpecificMasterNodesIT extends ESIntegTestCase {
|
|||
}
|
||||
logger.info("--> start master node (1)");
|
||||
final String masterNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true));
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName));
|
||||
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName));
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
|
||||
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
|
||||
|
||||
logger.info("--> start master node (2)");
|
||||
final String nextMasterEligableNodeName = internalCluster().startNode(settingsBuilder().put(Node.NODE_DATA_SETTING.getKey(), false).put(Node.NODE_MASTER_SETTING.getKey(), true));
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName));
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName));
|
||||
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(masterNodeName));
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
|
||||
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(masterNodeName));
|
||||
|
||||
logger.info("--> closing master node (1)");
|
||||
internalCluster().stopCurrentMasterNode();
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligableNodeName));
|
||||
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().masterNode().getName(), equalTo(nextMasterEligableNodeName));
|
||||
assertThat(internalCluster().nonMasterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligableNodeName));
|
||||
assertThat(internalCluster().masterClient().admin().cluster().prepareState().execute().actionGet().getState().nodes().getMasterNode().getName(), equalTo(nextMasterEligableNodeName));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -162,7 +162,7 @@ public class ShardStateActionTests extends ESTestCase {
|
|||
// for the right shard
|
||||
assertEquals(shardRouting, shardRoutingEntry.getShardRouting());
|
||||
// sent to the master
|
||||
assertEquals(clusterService.state().nodes().masterNode().getId(), capturedRequests[0].node.getId());
|
||||
assertEquals(clusterService.state().nodes().getMasterNode().getId(), capturedRequests[0].node.getId());
|
||||
|
||||
transport.handleResponse(capturedRequests[0].requestId, TransportResponse.Empty.INSTANCE);
|
||||
|
||||
|
|
|
@ -518,7 +518,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
|||
assertThat(clusterHealth.isTimedOut(), equalTo(false));
|
||||
|
||||
// the first node should be a master as the minimum required is 1
|
||||
assertThat(clusterService.state().nodes().masterNode(), notNullValue());
|
||||
assertThat(clusterService.state().nodes().getMasterNode(), notNullValue());
|
||||
assertThat(clusterService.state().nodes().localNodeMaster(), is(true));
|
||||
assertThat(testService.master(), is(true));
|
||||
|
||||
|
@ -554,7 +554,7 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
|||
internalCluster().stopRandomNonMasterNode();
|
||||
|
||||
// there should not be any master as the minimum number of required eligible masters is not met
|
||||
awaitBusy(() -> clusterService1.state().nodes().masterNode() == null &&
|
||||
awaitBusy(() -> clusterService1.state().nodes().getMasterNode() == null &&
|
||||
clusterService1.state().status() == ClusterState.ClusterStateStatus.APPLIED);
|
||||
assertThat(testService1.master(), is(false));
|
||||
|
||||
|
@ -571,8 +571,8 @@ public class ClusterServiceIT extends ESIntegTestCase {
|
|||
.setWaitForNodes("2").get().isTimedOut(), is(false));
|
||||
|
||||
// now that we started node1 again, a new master should be elected
|
||||
assertThat(clusterService2.state().nodes().masterNode(), is(notNullValue()));
|
||||
if (node_2.equals(clusterService2.state().nodes().masterNode().getName())) {
|
||||
assertThat(clusterService2.state().nodes().getMasterNode(), is(notNullValue()));
|
||||
if (node_2.equals(clusterService2.state().nodes().getMasterNode().getName())) {
|
||||
assertThat(testService1.master(), is(false));
|
||||
assertThat(testService2.master(), is(true));
|
||||
} else {
|
||||
|
|
|
@ -846,7 +846,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
|
|||
|
||||
DiscoveryNodes discoveryNodes = internalCluster().getInstance(ClusterService.class, nonMasterNode).state().nodes();
|
||||
|
||||
TransportService masterTranspotService = internalCluster().getInstance(TransportService.class, discoveryNodes.masterNode().getName());
|
||||
TransportService masterTranspotService = internalCluster().getInstance(TransportService.class, discoveryNodes.getMasterNode().getName());
|
||||
|
||||
logger.info("blocking requests from non master [{}] to master [{}]", nonMasterNode, masterNode);
|
||||
MockTransportService nonMasterTransportService = (MockTransportService) internalCluster().getInstance(TransportService.class, nonMasterNode);
|
||||
|
@ -1175,7 +1175,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
|
|||
@Override
|
||||
public void run() {
|
||||
ClusterState state = getNodeClusterState(node);
|
||||
assertNull("node [" + node + "] still has [" + state.nodes().masterNode() + "] as master", state.nodes().masterNode());
|
||||
assertNull("node [" + node + "] still has [" + state.nodes().getMasterNode() + "] as master", state.nodes().getMasterNode());
|
||||
if (expectedBlocks != null) {
|
||||
for (ClusterBlockLevel level : expectedBlocks.levels()) {
|
||||
assertTrue("node [" + node + "] does have level [" + level + "] in it's blocks", state.getBlocks().hasGlobalBlock(level));
|
||||
|
@ -1191,10 +1191,10 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
|
|||
public void run() {
|
||||
ClusterState state = getNodeClusterState(node);
|
||||
String masterNode = null;
|
||||
if (state.nodes().masterNode() != null) {
|
||||
masterNode = state.nodes().masterNode().getName();
|
||||
if (state.nodes().getMasterNode() != null) {
|
||||
masterNode = state.nodes().getMasterNode().getName();
|
||||
}
|
||||
logger.trace("[{}] master is [{}]", node, state.nodes().masterNode());
|
||||
logger.trace("[{}] master is [{}]", node, state.nodes().getMasterNode());
|
||||
assertThat("node [" + node + "] still has [" + masterNode + "] as master",
|
||||
oldMasterNode, not(equalTo(masterNode)));
|
||||
}
|
||||
|
@ -1206,7 +1206,7 @@ public class DiscoveryWithServiceDisruptionsIT extends ESIntegTestCase {
|
|||
ClusterState state = getNodeClusterState(node);
|
||||
String failMsgSuffix = "cluster_state:\n" + state.prettyPrint();
|
||||
assertThat("wrong node count on [" + node + "]. " + failMsgSuffix, state.nodes().getSize(), equalTo(nodes.size()));
|
||||
String otherMasterNodeName = state.nodes().masterNode() != null ? state.nodes().masterNode().getName() : null;
|
||||
String otherMasterNodeName = state.nodes().getMasterNode() != null ? state.nodes().getMasterNode().getName() : null;
|
||||
assertThat("wrong master on node [" + node + "]. " + failMsgSuffix, otherMasterNodeName, equalTo(masterNode));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,9 +94,9 @@ public class ZenUnicastDiscoveryIT extends ESIntegTestCase {
|
|||
ClusterState state = internalCluster().client(node).admin().cluster().prepareState().setLocal(true).execute().actionGet().getState();
|
||||
assertThat(state.nodes().getSize(), equalTo(currentNumNodes));
|
||||
if (masterDiscoNode == null) {
|
||||
masterDiscoNode = state.nodes().masterNode();
|
||||
masterDiscoNode = state.nodes().getMasterNode();
|
||||
} else {
|
||||
assertThat(masterDiscoNode.equals(state.nodes().masterNode()), equalTo(true));
|
||||
assertThat(masterDiscoNode.equals(state.nodes().getMasterNode()), equalTo(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ public class PublishClusterStateActionTests extends ESTestCase {
|
|||
ClusterChangedEvent event = new ClusterChangedEvent("", newClusterState, clusterState);
|
||||
listener.clusterChanged(event);
|
||||
}
|
||||
if (clusterState.nodes().masterNode() == null || newClusterState.supersedes(clusterState)) {
|
||||
if (clusterState.nodes().getMasterNode() == null || newClusterState.supersedes(clusterState)) {
|
||||
clusterState = newClusterState;
|
||||
}
|
||||
action.pendingStatesQueue().markAsProcessed(newClusterState);
|
||||
|
|
|
@ -234,7 +234,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
|
|||
|
||||
// Check routing tables
|
||||
ClusterState state = client().admin().cluster().prepareState().get().getState();
|
||||
assertEquals(master, state.nodes().masterNode().getName());
|
||||
assertEquals(master, state.nodes().getMasterNode().getName());
|
||||
List<ShardRouting> shards = state.routingTable().allShards("index");
|
||||
assertThat(shards, hasSize(1));
|
||||
for (ShardRouting shard : shards) {
|
||||
|
@ -352,7 +352,7 @@ public class RareClusterStateIT extends ESIntegTestCase {
|
|||
|
||||
// Check routing tables
|
||||
ClusterState state = client().admin().cluster().prepareState().get().getState();
|
||||
assertEquals(master, state.nodes().masterNode().getName());
|
||||
assertEquals(master, state.nodes().getMasterNode().getName());
|
||||
List<ShardRouting> shards = state.routingTable().allShards("index");
|
||||
assertThat(shards, hasSize(2));
|
||||
for (ShardRouting shard : shards) {
|
||||
|
|
|
@ -1363,7 +1363,7 @@ public final class InternalTestCluster extends TestCluster {
|
|||
try {
|
||||
Client client = viaNode != null ? client(viaNode) : client();
|
||||
ClusterState state = client.admin().cluster().prepareState().execute().actionGet().getState();
|
||||
return state.nodes().masterNode().getName();
|
||||
return state.nodes().getMasterNode().getName();
|
||||
} catch (Throwable e) {
|
||||
logger.warn("Can't fetch cluster state", e);
|
||||
throw new RuntimeException("Can't get master node " + e.getMessage(), e);
|
||||
|
|
Loading…
Reference in New Issue