Search in sources :

Example 16 with Builder

use of org.opensearch.cluster.node.DiscoveryNodes.Builder in project OpenSearch by opensearch-project.

the class TransportClearVotingConfigExclusionsActionTests method testSucceedsIfNodesAreRemovedWhileWaiting.

public void testSucceedsIfNodesAreRemovedWhileWaiting() throws InterruptedException {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final SetOnce<ClearVotingConfigExclusionsResponse> responseHolder = new SetOnce<>();
    transportService.sendRequest(localNode, ClearVotingConfigExclusionsAction.NAME, new ClearVotingConfigExclusionsRequest(), expectSuccess(r -> {
        responseHolder.set(r);
        countDownLatch.countDown();
    }));
    final ClusterState.Builder builder = builder(clusterService.state());
    builder.nodes(DiscoveryNodes.builder(clusterService.state().nodes()).remove(otherNode1).remove(otherNode2));
    setState(clusterService, builder);
    assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
    assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(), empty());
}
Also used : DiscoveryNodes(org.opensearch.cluster.node.DiscoveryNodes) VotingConfigExclusion(org.opensearch.cluster.coordination.CoordinationMetadata.VotingConfigExclusion) Metadata(org.opensearch.cluster.metadata.Metadata) BeforeClass(org.junit.BeforeClass) ThreadPool(org.opensearch.threadpool.ThreadPool) TestThreadPool(org.opensearch.threadpool.TestThreadPool) Version(org.opensearch.Version) ClusterServiceUtils.setState(org.opensearch.test.ClusterServiceUtils.setState) ThreadContext(org.opensearch.common.util.concurrent.ThreadContext) CoordinationMetadata(org.opensearch.cluster.coordination.CoordinationMetadata) ClusterState(org.opensearch.cluster.ClusterState) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) MockTransport(org.opensearch.test.transport.MockTransport) Before(org.junit.Before) StreamInput(org.opensearch.common.io.stream.StreamInput) Collections.emptyMap(java.util.Collections.emptyMap) AfterClass(org.junit.AfterClass) Matchers.empty(org.hamcrest.Matchers.empty) TimeValue(org.opensearch.common.unit.TimeValue) ClusterServiceUtils.createClusterService(org.opensearch.test.ClusterServiceUtils.createClusterService) SetOnce(org.apache.lucene.util.SetOnce) Collections.emptySet(java.util.Collections.emptySet) OpenSearchTestCase(org.opensearch.test.OpenSearchTestCase) TransportResponseHandler(org.opensearch.transport.TransportResponseHandler) Settings(org.opensearch.common.settings.Settings) IOException(java.io.IOException) ClusterState.builder(org.opensearch.cluster.ClusterState.builder) TransportService(org.opensearch.transport.TransportService) Matchers.startsWith(org.hamcrest.Matchers.startsWith) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) ActionFilters(org.opensearch.action.support.ActionFilters) CountDownLatch(java.util.concurrent.CountDownLatch) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) OpenSearchTimeoutException(org.opensearch.OpenSearchTimeoutException) ClusterService(org.opensearch.cluster.service.ClusterService) ClusterName(org.opensearch.cluster.ClusterName) Builder(org.opensearch.cluster.node.DiscoveryNodes.Builder) TransportException(org.opensearch.transport.TransportException) IndexNameExpressionResolver(org.opensearch.cluster.metadata.IndexNameExpressionResolver) Names(org.opensearch.threadpool.ThreadPool.Names) ClusterState(org.opensearch.cluster.ClusterState) SetOnce(org.apache.lucene.util.SetOnce) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

Builder (org.opensearch.cluster.node.DiscoveryNodes.Builder)16 ClusterState (org.opensearch.cluster.ClusterState)15 ClusterName (org.opensearch.cluster.ClusterName)13 VotingConfigExclusion (org.opensearch.cluster.coordination.CoordinationMetadata.VotingConfigExclusion)13 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)13 CoordinationMetadata (org.opensearch.cluster.coordination.CoordinationMetadata)9 Metadata (org.opensearch.cluster.metadata.Metadata)9 IOException (java.io.IOException)8 Collections.emptyMap (java.util.Collections.emptyMap)8 Collections.emptySet (java.util.Collections.emptySet)8 CountDownLatch (java.util.concurrent.CountDownLatch)8 TimeUnit (java.util.concurrent.TimeUnit)8 Consumer (java.util.function.Consumer)8 SetOnce (org.apache.lucene.util.SetOnce)8 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)8 Matchers.instanceOf (org.hamcrest.Matchers.instanceOf)8 Matchers.startsWith (org.hamcrest.Matchers.startsWith)8 AfterClass (org.junit.AfterClass)8 Before (org.junit.Before)8 BeforeClass (org.junit.BeforeClass)8