Search in sources :

Example 6 with ClusterState.builder

use of org.opensearch.cluster.ClusterState.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

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 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)6 Matchers.instanceOf (org.hamcrest.Matchers.instanceOf)6 Matchers.startsWith (org.hamcrest.Matchers.startsWith)6 AfterClass (org.junit.AfterClass)6 Before (org.junit.Before)6 BeforeClass (org.junit.BeforeClass)6 OpenSearchTimeoutException (org.opensearch.OpenSearchTimeoutException)6 Version (org.opensearch.Version)6 ActionFilters (org.opensearch.action.support.ActionFilters)6 ClusterName (org.opensearch.cluster.ClusterName)6 ClusterState (org.opensearch.cluster.ClusterState)6 ClusterState.builder (org.opensearch.cluster.ClusterState.builder)6 CoordinationMetadata (org.opensearch.cluster.coordination.CoordinationMetadata)6