use of org.elasticsearch.cluster.ClusterState.Builder in project crate by crate.
the class TransportAddVotingConfigExclusionsActionTests method testSucceedsEvenIfAllExclusionsAlreadyAdded.
public void testSucceedsEvenIfAllExclusionsAlreadyAdded() throws InterruptedException {
final ClusterState state = clusterService.state();
final ClusterState.Builder builder = builder(state);
builder.metadata(Metadata.builder(state.metadata()).coordinationMetadata(CoordinationMetadata.builder(state.coordinationMetadata()).addVotingConfigExclusion(otherNode1Exclusion).build()));
setState(clusterService, builder);
final CountDownLatch countDownLatch = new CountDownLatch(1);
transportService.sendRequest(localNode, AddVotingConfigExclusionsAction.NAME, new AddVotingConfigExclusionsRequest(new String[] { "other1" }), expectSuccess(r -> {
assertNotNull(r);
countDownLatch.countDown();
}));
assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(), contains(otherNode1Exclusion));
}
use of org.elasticsearch.cluster.ClusterState.Builder in project crate by crate.
the class TransportClearVotingConfigExclusionsActionTests method setupForTest.
@Before
public void setupForTest() {
final MockTransport transport = new MockTransport();
transportService = transport.createTransportService(Settings.EMPTY, threadPool, boundTransportAddress -> localNode, null);
new TransportClearVotingConfigExclusionsAction(transportService, clusterService, threadPool, // registers action
new IndexNameExpressionResolver());
transportService.start();
transportService.acceptIncomingRequests();
final ClusterState.Builder builder = builder(new ClusterName("cluster")).nodes(new Builder().add(localNode).add(otherNode1).add(otherNode2).localNodeId(localNode.getId()).masterNodeId(localNode.getId()));
builder.metadata(Metadata.builder().coordinationMetadata(CoordinationMetadata.builder().addVotingConfigExclusion(otherNode1Exclusion).addVotingConfigExclusion(otherNode2Exclusion).build()));
setState(clusterService, builder);
}
use of org.elasticsearch.cluster.ClusterState.Builder in project crate by crate.
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());
}
Aggregations