Search in sources :

Example 11 with Builder

use of org.elasticsearch.cluster.node.DiscoveryNodes.Builder in project elasticsearch by elastic.

the class PrimaryTermsTests method initPrimaries.

/**
     * puts primary shard routings into initializing state
     */
private void initPrimaries() {
    logger.info("adding {} nodes and performing rerouting", this.numberOfReplicas + 1);
    Builder discoBuilder = DiscoveryNodes.builder();
    for (int i = 0; i < this.numberOfReplicas + 1; i++) {
        discoBuilder = discoBuilder.add(newNode("node" + i));
    }
    this.clusterState = ClusterState.builder(clusterState).nodes(discoBuilder).build();
    ClusterState rerouteResult = allocationService.reroute(clusterState, "reroute");
    assertThat(rerouteResult, not(equalTo(this.clusterState)));
    applyRerouteResult(rerouteResult);
    primaryTermsPerIndex.keySet().forEach(this::incrementPrimaryTerm);
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) Builder(org.elasticsearch.cluster.node.DiscoveryNodes.Builder)

Example 12 with Builder

use of org.elasticsearch.cluster.node.DiscoveryNodes.Builder in project crate by crate.

the class PeerFinderTests method updateLastAcceptedNodes.

private void updateLastAcceptedNodes(Consumer<DiscoveryNodes.Builder> onBuilder) {
    final Builder builder = DiscoveryNodes.builder(lastAcceptedNodes);
    onBuilder.accept(builder);
    lastAcceptedNodes = builder.build();
}
Also used : Builder(org.elasticsearch.cluster.node.DiscoveryNodes.Builder)

Aggregations

Builder (org.elasticsearch.cluster.node.DiscoveryNodes.Builder)12 ClusterState (org.elasticsearch.cluster.ClusterState)11 ClusterName (org.elasticsearch.cluster.ClusterName)8 VotingConfigExclusion (org.elasticsearch.cluster.coordination.CoordinationMetadata.VotingConfigExclusion)8 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)8 TimeValue (io.crate.common.unit.TimeValue)6 IOException (java.io.IOException)6 Collections.emptyMap (java.util.Collections.emptyMap)6 Collections.emptySet (java.util.Collections.emptySet)6 CountDownLatch (java.util.concurrent.CountDownLatch)6 TimeUnit (java.util.concurrent.TimeUnit)6 Consumer (java.util.function.Consumer)6 SetOnce (org.apache.lucene.util.SetOnce)6 ElasticsearchTimeoutException (org.elasticsearch.ElasticsearchTimeoutException)6 Version (org.elasticsearch.Version)6 ClusterState.builder (org.elasticsearch.cluster.ClusterState.builder)6 CoordinationMetadata (org.elasticsearch.cluster.coordination.CoordinationMetadata)6 IndexNameExpressionResolver (org.elasticsearch.cluster.metadata.IndexNameExpressionResolver)6 Metadata (org.elasticsearch.cluster.metadata.Metadata)6 ClusterService (org.elasticsearch.cluster.service.ClusterService)6