public PingResponse(DiscoveryNode node, DiscoveryNode master, ClusterState state) { this(node, master, state.getClusterName(), state.blocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK) ? ElectMasterService.MasterCandidate.UNRECOVERED_CLUSTER_VERSION : state.version()); }
/** * Returns the indices deleted in this event */ public List<Index> indicesDeleted() { if (previousState.blocks().hasGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK)) { // working off of a non-initialized previous state, so use the tombstones for index deletions return indicesDeletedFromTombstones(); } else { // examine the diffs in index metadata between the previous and new cluster states to get the deleted indices return indicesDeletedFromClusterState(); } }
void handleJoinRequest(final DiscoveryNode node, final ClusterState state, final MembershipAction.JoinCallback callback) { if (nodeJoinController == null) { throw new IllegalStateException("discovery module is not yet started"); } else { // we do this in a couple of places including the cluster update thread. This one here is really just best effort // to ensure we fail as fast as possible. onJoinValidators.stream().forEach(a -> a.accept(node, state)); if (state.getBlocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK) == false) { MembershipAction.ensureMajorVersionBarrier(node.getVersion(), state.getNodes().getMinNodeVersion()); } // try and connect to the node, if it fails, we can raise an exception back to the client... transportService.connectToNode(node); // validate the join request, will throw a failure if it fails, which will get back to the // node calling the join request try { membership.sendValidateJoinRequestBlocking(node, state, joinTimeout); } catch (Exception e) { logger.warn(() -> new ParameterizedMessage("failed to validate incoming join request from node [{}]", node), e); callback.onFailure(new IllegalStateException("failure when sending a validation request to node", e)); return; } nodeJoinController.handleJoinRequest(node, callback); } }
@Override public void clusterChanged(ClusterChangedEvent event) { ClusterState state = event.state(); if (state.blocks().hasGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK)) {
private void innerUpdatePipelines(ClusterState previousState, ClusterState state) { if (state.blocks().hasGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK)) { return; } IngestMetadata ingestMetadata = state.getMetaData().custom(IngestMetadata.TYPE); IngestMetadata previousIngestMetadata = previousState.getMetaData().custom(IngestMetadata.TYPE); if (Objects.equals(ingestMetadata, previousIngestMetadata)) { return; } Map<String, Pipeline> pipelines = new HashMap<>(); List<ElasticsearchParseException> exceptions = new ArrayList<>(); for (PipelineConfiguration pipeline : ingestMetadata.getPipelines().values()) { try { pipelines.put( pipeline.getId(), Pipeline.create(pipeline.getId(), pipeline.getConfigAsMap(), processorFactories, scriptService) ); } catch (ElasticsearchParseException e) { pipelines.put(pipeline.getId(), substitutePipeline(pipeline.getId(), e)); exceptions.add(e); } catch (Exception e) { ElasticsearchParseException parseException = new ElasticsearchParseException( "Error updating pipeline with id [" + pipeline.getId() + "]", e); pipelines.put(pipeline.getId(), substitutePipeline(pipeline.getId(), parseException)); exceptions.add(parseException); } } this.pipelines = Collections.unmodifiableMap(pipelines); ExceptionsHelper.rethrowAndSuppress(exceptions); }
@Override protected void doExecute(MainRequest request, ActionListener<MainResponse> listener) { ClusterState clusterState = clusterService.state(); final boolean available = clusterState.getBlocks().hasGlobalBlock(RestStatus.SERVICE_UNAVAILABLE) == false; listener.onResponse( new MainResponse(nodeName, Version.CURRENT, clusterState.getClusterName(), clusterState.metaData().clusterUUID(), Build.CURRENT, available)); } }
@Override public void clusterChanged(ClusterChangedEvent event) { if (event.state().blocks().hasGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK)) {
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 } }
assert !newClusterState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock()) : "received a cluster state with a master block"; if (currentState.blocks().hasGlobalBlock(discoverySettings.getNoMasterBlock())) {
assert previousState.blocks().hasGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK); final IndexMetaData metaData = indicesService.verifyIndexIsDeleted(index, event.state()); if (metaData != null) {
if (clusterState.blocks().hasGlobalBlock(RestStatus.SERVICE_UNAVAILABLE)) { computeStatus = ClusterHealthStatus.RED;
if (state.blocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK) == false) {
Version maxClusterNodeVersion = newState.nodes().getMaxNodeVersion(); final boolean enforceMajorVersion = currentState.getBlocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK) == false;
public PingResponse(DiscoveryNode node, DiscoveryNode master, ClusterState state) { this(node, master, state.getClusterName(), state.blocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK) ? ElectMasterService.MasterCandidate.UNRECOVERED_CLUSTER_VERSION : state.version()); }
public PingResponse(DiscoveryNode node, DiscoveryNode master, ClusterState state) { this(node, master, state.getClusterName(), state.blocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK) ? ElectMasterService.MasterCandidate.UNRECOVERED_CLUSTER_VERSION : state.version()); }
public PingResponse(DiscoveryNode node, DiscoveryNode master, ClusterState state) { this(node, master, state.getClusterName(), state.blocks().hasGlobalBlock(STATE_NOT_RECOVERED_BLOCK) ? ElectMasterService.MasterCandidate.UNRECOVERED_CLUSTER_VERSION : state.version()); }
/** * Returns the indices deleted in this event */ public List<Index> indicesDeleted() { if (previousState.blocks().hasGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK)) { // working off of a non-initialized previous state, so use the tombstones for index deletions return indicesDeletedFromTombstones(); } else { // examine the diffs in index metadata between the previous and new cluster states to get the deleted indices return indicesDeletedFromClusterState(); } }
/** * Returns the indices deleted in this event */ public List<Index> indicesDeleted() { if (previousState.blocks().hasGlobalBlock(GatewayService.STATE_NOT_RECOVERED_BLOCK)) { // working off of a non-initialized previous state, so use the tombstones for index deletions return indicesDeletedFromTombstones(); } else { // examine the diffs in index metadata between the previous and new cluster states to get the deleted indices return indicesDeletedFromClusterState(); } }
@Override protected void doExecute(MainRequest request, ActionListener<MainResponse> listener) { ClusterState clusterState = clusterService.state(); assert Node.NODE_NAME_SETTING.exists(settings); final boolean available = clusterState.getBlocks().hasGlobalBlock(RestStatus.SERVICE_UNAVAILABLE) == false; listener.onResponse( new MainResponse(Node.NODE_NAME_SETTING.get(settings), Version.CURRENT, clusterState.getClusterName(), clusterState.metaData().clusterUUID(), Build.CURRENT, available)); } }
@Override protected void doExecute(MainRequest request, ActionListener<MainResponse> listener) { ClusterState clusterState = clusterService.state(); assert Node.NODE_NAME_SETTING.exists(settings); final boolean available = clusterState.getBlocks().hasGlobalBlock(RestStatus.SERVICE_UNAVAILABLE) == false; listener.onResponse( new MainResponse(Node.NODE_NAME_SETTING.get(settings), Version.CURRENT, clusterState.getClusterName(), clusterState.metaData().clusterUUID(), Build.CURRENT, available)); } }