ClusterBlocks blocks = clusterBlocksBuilder.build();
protected void rejoin(String reason) { assert Thread.holdsLock(stateMutex); ClusterState clusterState = committedState.get(); logger.warn("{}, current nodes: {}", reason, clusterState.nodes()); nodesFD.stop(); masterFD.stop(reason); // TODO: do we want to force a new thread if we actively removed the master? this is to give a full pinging cycle // before a decision is made. joinThreadControl.startNewThreadIfNotRunning(); if (clusterState.nodes().getMasterNodeId() != null) { // remove block if it already exists before adding new one assert clusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock().id()) == false : "NO_MASTER_BLOCK should only be added by ZenDiscovery"; ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(clusterState.blocks()) .addGlobalBlock(discoverySettings.getNoMasterBlock()) .build(); DiscoveryNodes discoveryNodes = new DiscoveryNodes.Builder(clusterState.nodes()).masterNodeId(null).build(); clusterState = ClusterState.builder(clusterState) .blocks(clusterBlocks) .nodes(discoveryNodes) .build(); committedState.set(clusterState); clusterApplier.onNewClusterState(reason, this::clusterState, (source, e) -> {}); // don't wait for state to be applied } }
ClusterBlocks blocks = clusterBlocksBuilder.build();
ClusterBlocks blocks = clusterBlocksBuilder.build(); RoutingAllocation.Result routingResult = allocationService.reroute( ClusterState.builder(currentState).routingTable(routingTableBuilder.build()).metaData(newMetaData).build(),
ClusterBlocks blocks = clusterBlocksBuilder.build();
ClusterBlocks blocks = clusterBlocksBuilder.build();
ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(previousClusterState.blocks()) .addGlobalBlock(discoverySettings.getNoMasterBlock()) .build();
@Override public ClusterState execute(ClusterState currentState) { // Rebuild state ClusterState.Builder stateBuilder = ClusterState.builder(currentState); // Rebuild nodes DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder() .localNodeId(localNode.id()) .masterNodeId(singleton.master().getNode().id()) .put(singleton.master().getNode()); for (ESNode node : singleton.slaves()) { nodesBuilder.put(node.getNode()); } latestDiscoNodes = nodesBuilder.build(); stateBuilder.nodes(latestDiscoNodes); for (DiscoveryNode node : latestDiscoNodes) { if (!currentState.nodes().nodeExists(node.id())) { transportService.connectToNode(node); } } // update the fact that we are the master... if (!localNode().id().equals(currentState.nodes().masterNodeId())) { ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(NO_MASTER_BLOCK).build(); stateBuilder.blocks(clusterBlocks); } return stateBuilder.build(); }
protected void rejoin(String reason) { assert Thread.holdsLock(stateMutex); ClusterState clusterState = committedState.get(); logger.warn("{}, current nodes: {}", reason, clusterState.nodes()); nodesFD.stop(); masterFD.stop(reason); // TODO: do we want to force a new thread if we actively removed the master? this is to give a full pinging cycle // before a decision is made. joinThreadControl.startNewThreadIfNotRunning(); if (clusterState.nodes().getMasterNodeId() != null) { // remove block if it already exists before adding new one assert clusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock().id()) == false : "NO_MASTER_BLOCK should only be added by ZenDiscovery"; ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(clusterState.blocks()) .addGlobalBlock(discoverySettings.getNoMasterBlock()) .build(); DiscoveryNodes discoveryNodes = new DiscoveryNodes.Builder(clusterState.nodes()).masterNodeId(null).build(); clusterState = ClusterState.builder(clusterState) .blocks(clusterBlocks) .nodes(discoveryNodes) .build(); committedState.set(clusterState); clusterApplier.onNewClusterState(reason, this::clusterState, (source, e) -> {}); // don't wait for state to be applied } }
@Override public ClusterState execute(ClusterState currentState) { // Rebuild state ClusterState.Builder stateBuilder = ClusterState.builder(currentState); // Rebuild nodes DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder() .localNodeId(localNode.id()) .masterNodeId(singleton.master().getNode().id()) .put(singleton.master().getNode()); for (ESNode node : singleton.slaves()) { nodesBuilder.put(node.getNode()); } latestDiscoNodes = nodesBuilder.build(); stateBuilder.nodes(latestDiscoNodes); for (DiscoveryNode node : latestDiscoNodes) { if (!currentState.nodes().nodeExists(node.id())) { transportService.connectToNode(node); } } // update the fact that we are the master... if (!localNode().id().equals(currentState.nodes().masterNodeId())) { ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(NO_MASTER_BLOCK).build(); stateBuilder.blocks(clusterBlocks); } return stateBuilder.build(); }
@Override public ClusterState execute(ClusterState currentState) { // Rebuild state ClusterState.Builder stateBuilder = newClusterStateBuilder().state(currentState); // Rebuild nodes DiscoveryNodes.Builder nodesBuilder = newNodesBuilder() .localNodeId(localNode.id()) .masterNodeId(singleton.master().get().node().id()) .put(singleton.master().get().node); for (ESNode node : JavaConversions$.MODULE$.asJavaCollection(singleton.slaves())) { nodesBuilder.put(node.node()); } latestDiscoNodes = nodesBuilder.build(); stateBuilder.nodes(latestDiscoNodes); for (DiscoveryNode node : latestDiscoNodes) { if (!currentState.nodes().nodeExists(node.id())) { transportService.connectToNode(node); } } // update the fact that we are the master... if (!localNode().id().equals(currentState.nodes().masterNodeId())) { ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(NO_MASTER_BLOCK).build(); stateBuilder.blocks(clusterBlocks); } return stateBuilder.build(); }
protected void rejoin(String reason) { assert Thread.holdsLock(stateMutex); ClusterState clusterState = committedState.get(); logger.warn("{}, current nodes: {}", reason, clusterState.nodes()); nodesFD.stop(); masterFD.stop(reason); // TODO: do we want to force a new thread if we actively removed the master? this is to give a full pinging cycle // before a decision is made. joinThreadControl.startNewThreadIfNotRunning(); if (clusterState.nodes().getMasterNodeId() != null) { // remove block if it already exists before adding new one assert clusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock().id()) == false : "NO_MASTER_BLOCK should only be added by ZenDiscovery"; ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(clusterState.blocks()) .addGlobalBlock(discoverySettings.getNoMasterBlock()) .build(); DiscoveryNodes discoveryNodes = new DiscoveryNodes.Builder(clusterState.nodes()).masterNodeId(null).build(); clusterState = ClusterState.builder(clusterState) .blocks(clusterBlocks) .nodes(discoveryNodes) .build(); committedState.set(clusterState); clusterApplier.onNewClusterState(reason, this::clusterState, (source, e) -> {}); // don't wait for state to be applied } }
@Override public ClusterState execute(ClusterState currentState) { // Rebuild state ClusterState.Builder stateBuilder = ClusterState.builder(currentState); // Rebuild nodes DiscoveryNodes.Builder nodesBuilder = DiscoveryNodes.builder() .localNodeId(localNode.id()) .masterNodeId(singleton.master().getNode().id()) .put(singleton.master().getNode()); for (ESNode node : singleton.slaves()) { nodesBuilder.put(node.getNode()); } latestDiscoNodes = nodesBuilder.build(); stateBuilder.nodes(latestDiscoNodes); for (DiscoveryNode node : latestDiscoNodes) { if (!currentState.nodes().nodeExists(node.id())) { transportService.connectToNode(node); } } // update the fact that we are the master... if (!localNode().id().equals(currentState.nodes().masterNodeId())) { ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(NO_MASTER_BLOCK).build(); stateBuilder.blocks(clusterBlocks); } return stateBuilder.build(); }
@Override public ClusterState execute(ClusterState currentState) { // 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) { // 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()); throw new NotMasterException("Node [" + clusterService.localNode() + "] not master for join request"); } DiscoveryNodes.Builder builder = new DiscoveryNodes.Builder(currentState.nodes()).masterNodeId(currentState.nodes().localNode().id()); // update the fact that we are the master... ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(currentState.blocks()).removeGlobalBlock(discoverySettings.getNoMasterBlock()).build(); currentState = ClusterState.builder(currentState).nodes(builder).blocks(clusterBlocks).build(); // reroute now to remove any dead nodes (master may have stepped down when they left and didn't update the routing table) RoutingAllocation.Result result = routingService.getAllocationService().reroute(currentState, "nodes joined"); if (result.changed()) { currentState = ClusterState.builder(currentState).routingResult(result).build(); } // Add the incoming join requests. // Note: we only do this now (after the reroute) to avoid assigning shards to these nodes. return super.execute(currentState); }
protected ClusterState rejoin(ClusterState clusterState, String reason) { // *** called from within an cluster state update task *** // assert Thread.currentThread().getName().contains(InternalClusterService.UPDATE_THREAD_NAME); logger.warn(reason + ", current nodes: {}", clusterState.nodes()); nodesFD.stop(); masterFD.stop(reason); ClusterBlocks clusterBlocks = ClusterBlocks.builder().blocks(clusterState.blocks()) .addGlobalBlock(discoverySettings.getNoMasterBlock()) .build(); // clean the nodes, we are now not connected to anybody, since we try and reform the cluster DiscoveryNodes discoveryNodes = new DiscoveryNodes.Builder(clusterState.nodes()).masterNodeId(null).build(); // TODO: do we want to force a new thread if we actively removed the master? this is to give a full pinging cycle // before a decision is made. joinThreadControl.startNewThreadIfNotRunning(); return ClusterState.builder(clusterState) .blocks(clusterBlocks) .nodes(discoveryNodes) .build(); }
public Builder blocks(ClusterBlocks.Builder blocksBuilder) { return blocks(blocksBuilder.build()); }
public Builder blocks(ClusterBlocks.Builder blocksBuilder) { return blocks(blocksBuilder.build()); }
public Builder blocks(ClusterBlocks.Builder blocksBuilder) { return blocks(blocksBuilder.build()); }
public Builder blocks(ClusterBlocks blocks) { this.blocks = blocks; return this; }
public Builder blocks(ClusterBlocks.Builder blocksBuilder) { return blocks(blocksBuilder.build()); }