Java Code Examples for org.elasticsearch.discovery.DiscoveryModule#SINGLE_NODE_DISCOVERY_TYPE

The following examples show how to use org.elasticsearch.discovery.DiscoveryModule#SINGLE_NODE_DISCOVERY_TYPE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Coordinator.java    From crate with Apache License 2.0 6 votes vote down vote up
@Override
protected void doStart() {
    synchronized (mutex) {
        CoordinationState.PersistedState persistedState = persistedStateSupplier.get();
        coordinationState.set(new CoordinationState(settings, getLocalNode(), persistedState));
        peerFinder.setCurrentTerm(getCurrentTerm());
        configuredHostsResolver.start();
        VotingConfiguration votingConfiguration = coordinationState.get().getLastAcceptedState().getLastCommittedConfiguration();
        if (singleNodeDiscovery &&
            votingConfiguration.isEmpty() == false &&
            votingConfiguration.hasQuorum(Collections.singleton(getLocalNode().getId())) == false) {
            throw new IllegalStateException("cannot start with [" + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() + "] set to [" +
                DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE + "] when local node " + getLocalNode() +
                " does not have quorum in voting configuration " + votingConfiguration);
        }
        ClusterState initialState = ClusterState.builder(ClusterName.CLUSTER_NAME_SETTING.get(settings))
            .blocks(ClusterBlocks.builder()
                .addGlobalBlock(STATE_NOT_RECOVERED_BLOCK)
                .addGlobalBlock(noMasterBlockService.getNoMasterBlock()))
            .nodes(DiscoveryNodes.builder().add(getLocalNode()).localNodeId(getLocalNode().getId()))
            .build();
        applierState = initialState;
        clusterApplier.setInitialState(initialState);
    }
}
 
Example 2
Source File: ClusterBootstrapService.java    From crate with Apache License 2.0 5 votes vote down vote up
public ClusterBootstrapService(Settings settings, TransportService transportService,
                               Supplier<Iterable<DiscoveryNode>> discoveredNodesSupplier, BooleanSupplier isBootstrappedSupplier,
                               Consumer<VotingConfiguration> votingConfigurationConsumer) {
    if (DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE.equals(DiscoveryModule.DISCOVERY_TYPE_SETTING.get(settings))) {
        if (INITIAL_MASTER_NODES_SETTING.exists(settings)) {
            throw new IllegalArgumentException("setting [" + INITIAL_MASTER_NODES_SETTING.getKey() +
                "] is not allowed when [" + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() + "] is set to [" +
                DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE + "]");
        }
        if (DiscoveryNode.isMasterNode(settings) == false) {
            throw new IllegalArgumentException("node with [" + DiscoveryModule.DISCOVERY_TYPE_SETTING.getKey() + "] set to [" +
                DiscoveryModule.SINGLE_NODE_DISCOVERY_TYPE + "] must be master-eligible");
        }
        bootstrapRequirements = Collections.singleton(Node.NODE_NAME_SETTING.get(settings));
        unconfiguredBootstrapTimeout = null;
    } else {
        final List<String> initialMasterNodes = INITIAL_MASTER_NODES_SETTING.get(settings);
        bootstrapRequirements = unmodifiableSet(new LinkedHashSet<>(initialMasterNodes));
        if (bootstrapRequirements.size() != initialMasterNodes.size()) {
            throw new IllegalArgumentException(
                "setting [" + INITIAL_MASTER_NODES_SETTING.getKey() + "] contains duplicates: " + initialMasterNodes);
        }
        unconfiguredBootstrapTimeout = discoveryIsConfigured(settings) ? null : UNCONFIGURED_BOOTSTRAP_TIMEOUT_SETTING.get(settings);
    }

    this.transportService = transportService;
    this.discoveredNodesSupplier = discoveredNodesSupplier;
    this.isBootstrappedSupplier = isBootstrappedSupplier;
    this.votingConfigurationConsumer = votingConfigurationConsumer;
}