Search in sources :

Example 41 with TransportException

use of org.elasticsearch.transport.TransportException in project crate by crate.

the class PublicationTransportHandler method sendClusterStateToNode.

private void sendClusterStateToNode(ClusterState clusterState, BytesReference bytes, DiscoveryNode node, ActionListener<PublishWithJoinResponse> responseActionListener, boolean sendDiffs, Map<Version, BytesReference> serializedStates) {
    try {
        final BytesTransportRequest request = new BytesTransportRequest(bytes, node.getVersion());
        final Consumer<TransportException> transportExceptionHandler = exp -> {
            if (sendDiffs && exp.unwrapCause() instanceof IncompatibleClusterStateVersionException) {
                LOGGER.debug("resending full cluster state to node {} reason {}", node, exp.getDetailedMessage());
                sendFullClusterState(clusterState, serializedStates, node, responseActionListener);
            } else {
                LOGGER.debug(() -> new ParameterizedMessage("failed to send cluster state to {}", node), exp);
                responseActionListener.onFailure(exp);
            }
        };
        final TransportResponseHandler<PublishWithJoinResponse> publishWithJoinResponseHandler = new TransportResponseHandler<PublishWithJoinResponse>() {

            @Override
            public PublishWithJoinResponse read(StreamInput in) throws IOException {
                return new PublishWithJoinResponse(in);
            }

            @Override
            public void handleResponse(PublishWithJoinResponse response) {
                responseActionListener.onResponse(response);
            }

            @Override
            public void handleException(TransportException exp) {
                transportExceptionHandler.accept(exp);
            }

            @Override
            public String executor() {
                return ThreadPool.Names.GENERIC;
            }
        };
        transportService.sendRequest(node, PUBLISH_STATE_ACTION_NAME, request, stateRequestOptions, publishWithJoinResponseHandler);
    } catch (Exception e) {
        LOGGER.warn(() -> new ParameterizedMessage("error sending cluster state to {}", node), e);
        responseActionListener.onFailure(e);
    }
}
Also used : ElasticsearchException(org.elasticsearch.ElasticsearchException) StreamOutput(org.elasticsearch.common.io.stream.StreamOutput) TransportChannel(org.elasticsearch.transport.TransportChannel) IncompatibleClusterStateVersionException(org.elasticsearch.cluster.IncompatibleClusterStateVersionException) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) HashMap(java.util.HashMap) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) Diff(org.elasticsearch.cluster.Diff) ClusterState(org.elasticsearch.cluster.ClusterState) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) Map(java.util.Map) BiConsumer(java.util.function.BiConsumer) ThreadPool(org.elasticsearch.threadpool.ThreadPool) TransportResponse(org.elasticsearch.transport.TransportResponse) TransportService(org.elasticsearch.transport.TransportService) BytesTransportRequest(org.elasticsearch.transport.BytesTransportRequest) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) Compressor(org.elasticsearch.common.compress.Compressor) IOUtils(io.crate.common.io.IOUtils) IOException(java.io.IOException) BytesReference(org.elasticsearch.common.bytes.BytesReference) ClusterChangedEvent(org.elasticsearch.cluster.ClusterChangedEvent) CompressorFactory(org.elasticsearch.common.compress.CompressorFactory) Consumer(java.util.function.Consumer) AtomicLong(java.util.concurrent.atomic.AtomicLong) NamedWriteableAwareStreamInput(org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput) Logger(org.apache.logging.log4j.Logger) Version(org.elasticsearch.Version) StreamInput(org.elasticsearch.common.io.stream.StreamInput) TransportResponseHandler(org.elasticsearch.transport.TransportResponseHandler) TransportRequestOptions(org.elasticsearch.transport.TransportRequestOptions) LogManager(org.apache.logging.log4j.LogManager) TransportException(org.elasticsearch.transport.TransportException) ActionListener(org.elasticsearch.action.ActionListener) BytesTransportRequest(org.elasticsearch.transport.BytesTransportRequest) TransportResponseHandler(org.elasticsearch.transport.TransportResponseHandler) NamedWriteableAwareStreamInput(org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput) StreamInput(org.elasticsearch.common.io.stream.StreamInput) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) IncompatibleClusterStateVersionException(org.elasticsearch.cluster.IncompatibleClusterStateVersionException) TransportException(org.elasticsearch.transport.TransportException) ElasticsearchException(org.elasticsearch.ElasticsearchException) IncompatibleClusterStateVersionException(org.elasticsearch.cluster.IncompatibleClusterStateVersionException) IOException(java.io.IOException) TransportException(org.elasticsearch.transport.TransportException)

Example 42 with TransportException

use of org.elasticsearch.transport.TransportException in project crate by crate.

the class RetentionLeaseBackgroundSyncAction method backgroundSync.

final void backgroundSync(ShardId shardId, String primaryAllocationId, long primaryTerm, RetentionLeases retentionLeases) {
    final Request request = new Request(shardId, retentionLeases);
    transportService.sendChildRequest(clusterService.localNode(), transportPrimaryAction, new ConcreteShardRequest<>(request, primaryAllocationId, primaryTerm), transportOptions, new TransportResponseHandler<ReplicationResponse>() {

        @Override
        public ReplicationResponse read(StreamInput in) throws IOException {
            return newResponseInstance(in);
        }

        @Override
        public String executor() {
            return ThreadPool.Names.SAME;
        }

        @Override
        public void handleResponse(ReplicationResponse response) {
        }

        @Override
        public void handleException(TransportException e) {
            if (ExceptionsHelper.unwrap(e, NodeClosedException.class) != null) {
                // node shutting down
                return;
            }
            if (ExceptionsHelper.unwrap(e, AlreadyClosedException.class, IndexShardClosedException.class) != null) {
                // the shard is closed
                return;
            }
            getLogger().warn(new ParameterizedMessage("{} retention lease background sync failed", shardId), e);
        }
    });
}
Also used : ReplicationRequest(org.elasticsearch.action.support.replication.ReplicationRequest) StreamInput(org.elasticsearch.common.io.stream.StreamInput) ParameterizedMessage(org.apache.logging.log4j.message.ParameterizedMessage) IOException(java.io.IOException) TransportException(org.elasticsearch.transport.TransportException) ReplicationResponse(org.elasticsearch.action.support.replication.ReplicationResponse)

Example 43 with TransportException

use of org.elasticsearch.transport.TransportException in project crate by crate.

the class TransportReplicationAllPermitsAcquisitionTests method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    globalBlock = randomBoolean();
    RestStatus restStatus = randomFrom(RestStatus.values());
    block = new ClusterBlock(randomIntBetween(1, 10), randomAlphaOfLength(5), false, true, false, restStatus, ClusterBlockLevel.ALL);
    clusterService = createClusterService(threadPool);
    final ClusterState.Builder state = ClusterState.builder(clusterService.state());
    Set<DiscoveryNodeRole> roles = new HashSet<>(DiscoveryNodeRole.BUILT_IN_ROLES);
    DiscoveryNode node1 = new DiscoveryNode("_name1", "_node1", buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT);
    DiscoveryNode node2 = new DiscoveryNode("_name2", "_node2", buildNewFakeTransportAddress(), emptyMap(), roles, Version.CURRENT);
    state.nodes(DiscoveryNodes.builder().add(node1).add(node2).localNodeId(node1.getId()).masterNodeId(node1.getId()));
    shardId = new ShardId("index", UUID.randomUUID().toString(), 0);
    ShardRouting shardRouting = newShardRouting(shardId, node1.getId(), true, ShardRoutingState.INITIALIZING, RecoverySource.EmptyStoreRecoverySource.INSTANCE);
    Settings indexSettings = Settings.builder().put(SETTING_VERSION_CREATED, Version.CURRENT).put(SETTING_INDEX_UUID, shardId.getIndex().getUUID()).put(SETTING_NUMBER_OF_SHARDS, 1).put(SETTING_NUMBER_OF_REPLICAS, 1).put(SETTING_CREATION_DATE, System.currentTimeMillis()).build();
    primary = newStartedShard(p -> newShard(shardRouting, indexSettings, new InternalEngineFactory()), true);
    for (int i = 0; i < 10; i++) {
        final String id = Integer.toString(i);
        indexDoc(primary, id, "{\"value\":" + id + "}");
    }
    IndexMetadata indexMetadata = IndexMetadata.builder(shardId.getIndexName()).settings(indexSettings).primaryTerm(shardId.id(), primary.getOperationPrimaryTerm()).putMapping("default", "{ \"properties\": { \"value\":  { \"type\": \"short\"}}}").build();
    state.metadata(Metadata.builder().put(indexMetadata, false).generateClusterUuidIfNeeded());
    replica = newShard(primary.shardId(), false, node2.getId(), indexMetadata, null);
    recoverReplica(replica, primary, true);
    IndexRoutingTable.Builder routing = IndexRoutingTable.builder(indexMetadata.getIndex());
    routing.addIndexShard(new IndexShardRoutingTable.Builder(shardId).addShard(primary.routingEntry()).build());
    state.routingTable(RoutingTable.builder().add(routing.build()).build());
    setState(clusterService, state.build());
    final Settings transportSettings = Settings.builder().put("node.name", node1.getId()).build();
    MockTransport transport = new MockTransport() {

        @Override
        protected void onSendRequest(long requestId, String action, TransportRequest request, DiscoveryNode node) {
            assertThat(action, allOf(startsWith("cluster:admin/test/"), endsWith("[r]")));
            assertThat(node, equalTo(node2));
            // node2 doesn't really exist, but we are performing some trickery in mockIndicesService() to pretend that node1 holds both
            // the primary and the replica, so redirect the request back to node1.
            transportService.sendRequest(transportService.getLocalNode(), action, request, new TransportResponseHandler<TransportReplicationAction.ReplicaResponse>() {

                @Override
                public ReplicaResponse read(StreamInput in) throws IOException {
                    return new ReplicaResponse(in);
                }

                @SuppressWarnings("unchecked")
                private TransportResponseHandler<TransportReplicationAction.ReplicaResponse> getResponseHandler() {
                    return (TransportResponseHandler<TransportReplicationAction.ReplicaResponse>) getResponseHandlers().onResponseReceived(requestId, TransportMessageListener.NOOP_LISTENER);
                }

                @Override
                public void handleResponse(TransportReplicationAction.ReplicaResponse response) {
                    getResponseHandler().handleResponse(response);
                }

                @Override
                public void handleException(TransportException exp) {
                    getResponseHandler().handleException(exp);
                }

                @Override
                public String executor() {
                    return ThreadPool.Names.SAME;
                }
            });
        }
    };
    transportService = transport.createTransportService(transportSettings, threadPool, bta -> node1, null);
    transportService.start();
    transportService.acceptIncomingRequests();
    shardStateAction = new ShardStateAction(clusterService, transportService, null, null);
}
Also used : ShardId(org.elasticsearch.index.shard.ShardId) TransportRequest(org.elasticsearch.transport.TransportRequest) SETTING_VERSION_CREATED(org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_VERSION_CREATED) ClusterServiceUtils.createClusterService(org.elasticsearch.test.ClusterServiceUtils.createClusterService) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) ClusterBlocks(org.elasticsearch.cluster.block.ClusterBlocks) ClusterState(org.elasticsearch.cluster.ClusterState) TransportMessageListener(org.elasticsearch.transport.TransportMessageListener) Settings(org.elasticsearch.common.settings.Settings) ClusterBlock(org.elasticsearch.cluster.block.ClusterBlock) After(org.junit.After) Matchers.nullValue(org.hamcrest.Matchers.nullValue) ThreadPool(org.elasticsearch.threadpool.ThreadPool) InternalEngineFactory(org.elasticsearch.index.engine.InternalEngineFactory) Releasable(org.elasticsearch.common.lease.Releasable) CyclicBarrier(java.util.concurrent.CyclicBarrier) Matchers.notNullValue(org.hamcrest.Matchers.notNullValue) Matchers.allOf(org.hamcrest.Matchers.allOf) PlainActionFuture(org.elasticsearch.action.support.PlainActionFuture) Set(java.util.Set) IndexShardRoutingTable(org.elasticsearch.cluster.routing.IndexShardRoutingTable) UUID(java.util.UUID) Matchers.startsWith(org.hamcrest.Matchers.startsWith) Objects(java.util.Objects) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) RecoverySource(org.elasticsearch.cluster.routing.RecoverySource) List(java.util.List) Version(org.elasticsearch.Version) IndexRoutingTable(org.elasticsearch.cluster.routing.IndexRoutingTable) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) RestStatus(org.elasticsearch.rest.RestStatus) Matchers.equalTo(org.hamcrest.Matchers.equalTo) TimeValue(io.crate.common.unit.TimeValue) TransportResponseHandler(org.elasticsearch.transport.TransportResponseHandler) Matchers.greaterThan(org.hamcrest.Matchers.greaterThan) Matchers.is(org.hamcrest.Matchers.is) DiscoveryNodeRole(org.elasticsearch.cluster.node.DiscoveryNodeRole) SETTING_INDEX_UUID(org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_INDEX_UUID) TransportException(org.elasticsearch.transport.TransportException) Matchers.endsWith(org.hamcrest.Matchers.endsWith) Mockito.mock(org.mockito.Mockito.mock) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting) SETTING_NUMBER_OF_SHARDS(org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_SHARDS) TransportChannel(org.elasticsearch.transport.TransportChannel) ClusterService(org.elasticsearch.cluster.service.ClusterService) ShardRoutingState(org.elasticsearch.cluster.routing.ShardRoutingState) ArrayList(java.util.ArrayList) TestShardRouting.newShardRouting(org.elasticsearch.cluster.routing.TestShardRouting.newShardRouting) HashSet(java.util.HashSet) Metadata(org.elasticsearch.cluster.metadata.Metadata) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) ClusterBlockException(org.elasticsearch.cluster.block.ClusterBlockException) SETTING_NUMBER_OF_REPLICAS(org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_NUMBER_OF_REPLICAS) ReplicaResponse(org.elasticsearch.action.support.replication.TransportReplicationAction.ReplicaResponse) TransportResponse(org.elasticsearch.transport.TransportResponse) IndicesService(org.elasticsearch.indices.IndicesService) TransportService(org.elasticsearch.transport.TransportService) ClusterBlockLevel(org.elasticsearch.cluster.block.ClusterBlockLevel) Before(org.junit.Before) Collections.emptyMap(java.util.Collections.emptyMap) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) SetOnce(org.apache.lucene.util.SetOnce) IndexService(org.elasticsearch.index.IndexService) IndexShard(org.elasticsearch.index.shard.IndexShard) MockTransport(org.elasticsearch.test.transport.MockTransport) Test(org.junit.Test) IOException(java.io.IOException) BrokenBarrierException(java.util.concurrent.BrokenBarrierException) SETTING_CREATION_DATE(org.elasticsearch.cluster.metadata.IndexMetadata.SETTING_CREATION_DATE) Mockito.when(org.mockito.Mockito.when) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) IndexShardTestCase(org.elasticsearch.index.shard.IndexShardTestCase) Matchers.hasItem(org.hamcrest.Matchers.hasItem) RoutingTable(org.elasticsearch.cluster.routing.RoutingTable) StreamInput(org.elasticsearch.common.io.stream.StreamInput) ClusterServiceUtils.setState(org.elasticsearch.test.ClusterServiceUtils.setState) ActionListener(org.elasticsearch.action.ActionListener) IndexRoutingTable(org.elasticsearch.cluster.routing.IndexRoutingTable) IndexShardRoutingTable(org.elasticsearch.cluster.routing.IndexShardRoutingTable) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) DiscoveryNodeRole(org.elasticsearch.cluster.node.DiscoveryNodeRole) ShardStateAction(org.elasticsearch.cluster.action.shard.ShardStateAction) ClusterBlock(org.elasticsearch.cluster.block.ClusterBlock) ShardId(org.elasticsearch.index.shard.ShardId) InternalEngineFactory(org.elasticsearch.index.engine.InternalEngineFactory) MockTransport(org.elasticsearch.test.transport.MockTransport) IndexMetadata(org.elasticsearch.cluster.metadata.IndexMetadata) Settings(org.elasticsearch.common.settings.Settings) HashSet(java.util.HashSet) ClusterState(org.elasticsearch.cluster.ClusterState) TransportRequest(org.elasticsearch.transport.TransportRequest) TransportResponseHandler(org.elasticsearch.transport.TransportResponseHandler) IOException(java.io.IOException) TransportException(org.elasticsearch.transport.TransportException) RestStatus(org.elasticsearch.rest.RestStatus) StreamInput(org.elasticsearch.common.io.stream.StreamInput) ReplicaResponse(org.elasticsearch.action.support.replication.TransportReplicationAction.ReplicaResponse) ShardRouting(org.elasticsearch.cluster.routing.ShardRouting) TestShardRouting.newShardRouting(org.elasticsearch.cluster.routing.TestShardRouting.newShardRouting) ReplicaResponse(org.elasticsearch.action.support.replication.TransportReplicationAction.ReplicaResponse) Before(org.junit.Before)

Example 44 with TransportException

use of org.elasticsearch.transport.TransportException in project crate by crate.

the class TransportClearVotingConfigExclusionsActionTests method testTimesOutIfWaitingForNodesThatAreNotRemoved.

public void testTimesOutIfWaitingForNodesThatAreNotRemoved() throws InterruptedException {
    final CountDownLatch countDownLatch = new CountDownLatch(1);
    final SetOnce<TransportException> responseHolder = new SetOnce<>();
    final ClearVotingConfigExclusionsRequest clearVotingConfigExclusionsRequest = new ClearVotingConfigExclusionsRequest();
    clearVotingConfigExclusionsRequest.setTimeout(TimeValue.timeValueMillis(100));
    transportService.sendRequest(localNode, ClearVotingConfigExclusionsAction.NAME, clearVotingConfigExclusionsRequest, expectError(e -> {
        responseHolder.set(e);
        countDownLatch.countDown();
    }));
    assertTrue(countDownLatch.await(30, TimeUnit.SECONDS));
    assertThat(clusterService.getClusterApplierService().state().getVotingConfigExclusions(), containsInAnyOrder(otherNode1Exclusion, otherNode2Exclusion));
    final Throwable rootCause = responseHolder.get().getRootCause();
    assertThat(rootCause, instanceOf(ElasticsearchTimeoutException.class));
    assertThat(rootCause.getMessage(), startsWith("timed out waiting for removal of nodes; if nodes should not be removed, set waitForRemoval to false. ["));
}
Also used : Builder(org.elasticsearch.cluster.node.DiscoveryNodes.Builder) BeforeClass(org.junit.BeforeClass) ClusterServiceUtils.createClusterService(org.elasticsearch.test.ClusterServiceUtils.createClusterService) ClusterService(org.elasticsearch.cluster.service.ClusterService) ClusterState.builder(org.elasticsearch.cluster.ClusterState.builder) CoordinationMetadata(org.elasticsearch.cluster.coordination.CoordinationMetadata) Names(org.elasticsearch.threadpool.ThreadPool.Names) ElasticsearchTimeoutException(org.elasticsearch.ElasticsearchTimeoutException) ClusterState(org.elasticsearch.cluster.ClusterState) Metadata(org.elasticsearch.cluster.metadata.Metadata) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) Settings(org.elasticsearch.common.settings.Settings) VotingConfigExclusion(org.elasticsearch.cluster.coordination.CoordinationMetadata.VotingConfigExclusion) ThreadPool(org.elasticsearch.threadpool.ThreadPool) ClusterName(org.elasticsearch.cluster.ClusterName) ESTestCase(org.elasticsearch.test.ESTestCase) TransportService(org.elasticsearch.transport.TransportService) Before(org.junit.Before) Collections.emptyMap(java.util.Collections.emptyMap) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) AfterClass(org.junit.AfterClass) Matchers.empty(org.hamcrest.Matchers.empty) SetOnce(org.apache.lucene.util.SetOnce) Collections.emptySet(java.util.Collections.emptySet) MockTransport(org.elasticsearch.test.transport.MockTransport) IOException(java.io.IOException) Matchers.startsWith(org.hamcrest.Matchers.startsWith) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) Matchers.instanceOf(org.hamcrest.Matchers.instanceOf) CountDownLatch(java.util.concurrent.CountDownLatch) Version(org.elasticsearch.Version) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) StreamInput(org.elasticsearch.common.io.stream.StreamInput) TimeValue(io.crate.common.unit.TimeValue) TransportResponseHandler(org.elasticsearch.transport.TransportResponseHandler) IndexNameExpressionResolver(org.elasticsearch.cluster.metadata.IndexNameExpressionResolver) TransportException(org.elasticsearch.transport.TransportException) ClusterServiceUtils.setState(org.elasticsearch.test.ClusterServiceUtils.setState) ElasticsearchTimeoutException(org.elasticsearch.ElasticsearchTimeoutException) SetOnce(org.apache.lucene.util.SetOnce) CountDownLatch(java.util.concurrent.CountDownLatch) TransportException(org.elasticsearch.transport.TransportException)

Example 45 with TransportException

use of org.elasticsearch.transport.TransportException in project crate by crate.

the class PublicationTests method testClusterStatePublishingFailsOrTimesOutBeforeCommit.

public void testClusterStatePublishingFailsOrTimesOutBeforeCommit() throws InterruptedException {
    VotingConfiguration config = new VotingConfiguration(Set.of(n1.getId(), n2.getId()));
    initializeCluster(config);
    AssertingAckListener ackListener = new AssertingAckListener(nodes.size());
    DiscoveryNodes discoveryNodes = DiscoveryNodes.builder().add(n1).add(n2).add(n3).localNodeId(n1.getId()).build();
    MockPublication publication = node1.publish(CoordinationStateTests.clusterState(1L, 2L, discoveryNodes, config, config, 42L), ackListener, Collections.emptySet());
    boolean timeOut = randomBoolean();
    publication.pendingPublications.entrySet().stream().collect(shuffle()).forEach(e -> {
        if (e.getKey().equals(n2)) {
            if (timeOut) {
                publication.cancel("timed out");
            } else {
                e.getValue().onFailure(new TransportException(new Exception("dummy failure")));
            }
            assertTrue(publication.completed);
            assertFalse(publication.committed);
        } else if (randomBoolean()) {
            PublishResponse publishResponse = nodeResolver.apply(e.getKey()).coordinationState.handlePublishRequest(publication.publishRequest);
            e.getValue().onResponse(new PublishWithJoinResponse(publishResponse, Optional.empty()));
        }
    });
    assertThat(publication.pendingCommits.keySet(), equalTo(Collections.emptySet()));
    assertNull(publication.applyCommit);
    assertTrue(publication.completed);
    assertFalse(publication.committed);
    List<Tuple<DiscoveryNode, Throwable>> errors = ackListener.awaitErrors(0L, TimeUnit.SECONDS);
    assertThat(errors.size(), equalTo(3));
    assertThat(errors.stream().map(Tuple::v1).collect(Collectors.toList()), containsInAnyOrder(n1, n2, n3));
    errors.stream().forEach(tuple -> assertThat(tuple.v2().getMessage(), containsString(timeOut ? "timed out" : tuple.v1().equals(n2) ? "dummy failure" : "non-failed nodes do not form a quorum")));
}
Also used : TransportException(org.elasticsearch.transport.TransportException) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) TransportException(org.elasticsearch.transport.TransportException) Tuple(io.crate.common.collections.Tuple) VotingConfiguration(org.elasticsearch.cluster.coordination.CoordinationMetadata.VotingConfiguration)

Aggregations

TransportException (org.elasticsearch.transport.TransportException)46 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)30 IOException (java.io.IOException)28 StreamInput (org.elasticsearch.common.io.stream.StreamInput)17 ElasticsearchException (org.elasticsearch.ElasticsearchException)16 ClusterState (org.elasticsearch.cluster.ClusterState)16 ParameterizedMessage (org.apache.logging.log4j.message.ParameterizedMessage)15 TransportResponse (org.elasticsearch.transport.TransportResponse)14 TransportResponseHandler (org.elasticsearch.transport.TransportResponseHandler)12 TransportService (org.elasticsearch.transport.TransportService)12 Settings (org.elasticsearch.common.settings.Settings)10 ClusterService (org.elasticsearch.cluster.service.ClusterService)9 ConnectTransportException (org.elasticsearch.transport.ConnectTransportException)9 EmptyTransportResponseHandler (org.elasticsearch.transport.EmptyTransportResponseHandler)9 Version (org.elasticsearch.Version)8 DiscoveryNodes (org.elasticsearch.cluster.node.DiscoveryNodes)8 TimeValue (io.crate.common.unit.TimeValue)7 ArrayList (java.util.ArrayList)7 Consumer (java.util.function.Consumer)7 ClusterStateObserver (org.elasticsearch.cluster.ClusterStateObserver)7