Search in sources :

Example 11 with ConnectTransportException

use of org.elasticsearch.transport.ConnectTransportException in project elasticsearch by elastic.

the class Netty4Transport method connectToChannels.

@Override
protected NodeChannels connectToChannels(DiscoveryNode node, ConnectionProfile profile) {
    final Channel[] channels = new Channel[profile.getNumConnections()];
    final NodeChannels nodeChannels = new NodeChannels(node, channels, profile);
    boolean success = false;
    try {
        final TimeValue connectTimeout;
        final Bootstrap bootstrap;
        final TimeValue defaultConnectTimeout = defaultConnectionProfile.getConnectTimeout();
        if (profile.getConnectTimeout() != null && profile.getConnectTimeout().equals(defaultConnectTimeout) == false) {
            bootstrap = this.bootstrap.clone(this.bootstrap.config().group());
            bootstrap.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, Math.toIntExact(profile.getConnectTimeout().millis()));
            connectTimeout = profile.getConnectTimeout();
        } else {
            connectTimeout = defaultConnectTimeout;
            bootstrap = this.bootstrap;
        }
        final ArrayList<ChannelFuture> connections = new ArrayList<>(channels.length);
        final InetSocketAddress address = node.getAddress().address();
        for (int i = 0; i < channels.length; i++) {
            connections.add(bootstrap.connect(address));
        }
        final Iterator<ChannelFuture> iterator = connections.iterator();
        try {
            for (int i = 0; i < channels.length; i++) {
                assert iterator.hasNext();
                ChannelFuture future = iterator.next();
                future.awaitUninterruptibly((long) (connectTimeout.millis() * 1.5));
                if (!future.isSuccess()) {
                    throw new ConnectTransportException(node, "connect_timeout[" + connectTimeout + "]", future.cause());
                }
                channels[i] = future.channel();
                channels[i].closeFuture().addListener(new ChannelCloseListener(node));
            }
            assert iterator.hasNext() == false : "not all created connection have been consumed";
        } catch (final RuntimeException e) {
            for (final ChannelFuture future : Collections.unmodifiableList(connections)) {
                FutureUtils.cancel(future);
                if (future.channel() != null && future.channel().isOpen()) {
                    try {
                        future.channel().close();
                    } catch (Exception inner) {
                        e.addSuppressed(inner);
                    }
                }
            }
            throw e;
        }
        success = true;
    } finally {
        if (success == false) {
            try {
                nodeChannels.close();
            } catch (IOException e) {
                logger.trace("exception while closing channels", e);
            }
        }
    }
    return nodeChannels;
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) InetSocketAddress(java.net.InetSocketAddress) NioServerSocketChannel(io.netty.channel.socket.nio.NioServerSocketChannel) NioSocketChannel(io.netty.channel.socket.nio.NioSocketChannel) Channel(io.netty.channel.Channel) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ElasticsearchException(org.elasticsearch.ElasticsearchException) ConnectTransportException(org.elasticsearch.transport.ConnectTransportException) IOException(java.io.IOException) ConnectTransportException(org.elasticsearch.transport.ConnectTransportException) Bootstrap(io.netty.bootstrap.Bootstrap) ServerBootstrap(io.netty.bootstrap.ServerBootstrap) TimeValue(org.elasticsearch.common.unit.TimeValue)

Example 12 with ConnectTransportException

use of org.elasticsearch.transport.ConnectTransportException in project elasticsearch by elastic.

the class TransportMasterNodeActionTests method testDelegateToFailingMaster.

public void testDelegateToFailingMaster() throws ExecutionException, InterruptedException {
    boolean failsWithConnectTransportException = randomBoolean();
    Request request = new Request().masterNodeTimeout(TimeValue.timeValueSeconds(failsWithConnectTransportException ? 60 : 0));
    setState(clusterService, ClusterStateCreationUtils.state(localNode, remoteNode, allNodes));
    PlainActionFuture<Response> listener = new PlainActionFuture<>();
    new Action(Settings.EMPTY, "testAction", transportService, clusterService, threadPool).execute(request, listener);
    assertThat(transport.capturedRequests().length, equalTo(1));
    CapturingTransport.CapturedRequest capturedRequest = transport.capturedRequests()[0];
    assertTrue(capturedRequest.node.isMasterNode());
    assertThat(capturedRequest.request, equalTo(request));
    assertThat(capturedRequest.action, equalTo("testAction"));
    if (failsWithConnectTransportException) {
        transport.handleRemoteError(capturedRequest.requestId, new ConnectTransportException(remoteNode, "Fake error"));
        assertFalse(listener.isDone());
        setState(clusterService, ClusterStateCreationUtils.state(localNode, localNode, allNodes));
        assertTrue(listener.isDone());
        listener.get();
    } else {
        ElasticsearchException t = new ElasticsearchException("test");
        t.addHeader("header", "is here");
        transport.handleRemoteError(capturedRequest.requestId, t);
        assertTrue(listener.isDone());
        try {
            listener.get();
            fail("Expected exception but returned proper result");
        } catch (ExecutionException ex) {
            final Throwable cause = ex.getCause().getCause();
            assertThat(cause, instanceOf(ElasticsearchException.class));
            final ElasticsearchException es = (ElasticsearchException) cause;
            assertThat(es.getMessage(), equalTo(t.getMessage()));
            assertThat(es.getHeader("header"), equalTo(t.getHeader("header")));
        }
    }
}
Also used : ActionResponse(org.elasticsearch.action.ActionResponse) PlainActionFuture(org.elasticsearch.action.support.PlainActionFuture) ConnectTransportException(org.elasticsearch.transport.ConnectTransportException) CapturingTransport(org.elasticsearch.test.transport.CapturingTransport) ElasticsearchException(org.elasticsearch.ElasticsearchException) ExecutionException(java.util.concurrent.ExecutionException)

Example 13 with ConnectTransportException

use of org.elasticsearch.transport.ConnectTransportException in project elasticsearch by elastic.

the class UnicastZenPingTests method testSimplePings.

public void testSimplePings() throws IOException, InterruptedException, ExecutionException {
    // use ephemeral ports
    final Settings settings = Settings.builder().put("cluster.name", "test").put(TransportSettings.PORT.getKey(), 0).build();
    final Settings settingsMismatch = Settings.builder().put(settings).put("cluster.name", "mismatch").put(TransportSettings.PORT.getKey(), 0).build();
    NetworkService networkService = new NetworkService(settings, Collections.emptyList());
    final BiFunction<Settings, Version, Transport> supplier = (s, v) -> new MockTcpTransport(s, threadPool, BigArrays.NON_RECYCLING_INSTANCE, new NoneCircuitBreakerService(), new NamedWriteableRegistry(Collections.emptyList()), networkService, v) {

        @Override
        public void connectToNode(DiscoveryNode node, ConnectionProfile connectionProfile, CheckedBiConsumer<Connection, ConnectionProfile, IOException> connectionValidator) throws ConnectTransportException {
            throw new AssertionError("zen pings should never connect to node (got [" + node + "])");
        }
    };
    NetworkHandle handleA = startServices(settings, threadPool, "UZP_A", Version.CURRENT, supplier);
    closeables.push(handleA.transportService);
    NetworkHandle handleB = startServices(settings, threadPool, "UZP_B", Version.CURRENT, supplier);
    closeables.push(handleB.transportService);
    NetworkHandle handleC = startServices(settingsMismatch, threadPool, "UZP_C", Version.CURRENT, supplier);
    closeables.push(handleC.transportService);
    final Version versionD;
    if (randomBoolean()) {
        versionD = VersionUtils.randomVersionBetween(random(), Version.CURRENT.minimumCompatibilityVersion(), Version.CURRENT);
    } else {
        versionD = Version.CURRENT;
    }
    logger.info("UZP_D version set to [{}]", versionD);
    NetworkHandle handleD = startServices(settingsMismatch, threadPool, "UZP_D", versionD, supplier);
    closeables.push(handleD.transportService);
    final ClusterState state = ClusterState.builder(new ClusterName("test")).version(randomNonNegativeLong()).build();
    final ClusterState stateMismatch = ClusterState.builder(new ClusterName("mismatch")).version(randomNonNegativeLong()).build();
    Settings hostsSettings = Settings.builder().putArray("discovery.zen.ping.unicast.hosts", NetworkAddress.format(new InetSocketAddress(handleA.address.address().getAddress(), handleA.address.address().getPort())), NetworkAddress.format(new InetSocketAddress(handleB.address.address().getAddress(), handleB.address.address().getPort())), NetworkAddress.format(new InetSocketAddress(handleC.address.address().getAddress(), handleC.address.address().getPort())), NetworkAddress.format(new InetSocketAddress(handleD.address.address().getAddress(), handleD.address.address().getPort()))).put("cluster.name", "test").build();
    Settings hostsSettingsMismatch = Settings.builder().put(hostsSettings).put(settingsMismatch).build();
    TestUnicastZenPing zenPingA = new TestUnicastZenPing(hostsSettings, threadPool, handleA, EMPTY_HOSTS_PROVIDER);
    zenPingA.start(new PingContextProvider() {

        @Override
        public DiscoveryNodes nodes() {
            return DiscoveryNodes.builder().add(handleA.node).localNodeId("UZP_A").build();
        }

        @Override
        public ClusterState clusterState() {
            return ClusterState.builder(state).blocks(ClusterBlocks.builder().addGlobalBlock(STATE_NOT_RECOVERED_BLOCK)).build();
        }
    });
    closeables.push(zenPingA);
    TestUnicastZenPing zenPingB = new TestUnicastZenPing(hostsSettings, threadPool, handleB, EMPTY_HOSTS_PROVIDER);
    zenPingB.start(new PingContextProvider() {

        @Override
        public DiscoveryNodes nodes() {
            return DiscoveryNodes.builder().add(handleB.node).localNodeId("UZP_B").build();
        }

        @Override
        public ClusterState clusterState() {
            return state;
        }
    });
    closeables.push(zenPingB);
    TestUnicastZenPing zenPingC = new TestUnicastZenPing(hostsSettingsMismatch, threadPool, handleC, EMPTY_HOSTS_PROVIDER) {

        @Override
        protected Version getVersion() {
            return versionD;
        }
    };
    zenPingC.start(new PingContextProvider() {

        @Override
        public DiscoveryNodes nodes() {
            return DiscoveryNodes.builder().add(handleC.node).localNodeId("UZP_C").build();
        }

        @Override
        public ClusterState clusterState() {
            return stateMismatch;
        }
    });
    closeables.push(zenPingC);
    TestUnicastZenPing zenPingD = new TestUnicastZenPing(hostsSettingsMismatch, threadPool, handleD, EMPTY_HOSTS_PROVIDER);
    zenPingD.start(new PingContextProvider() {

        @Override
        public DiscoveryNodes nodes() {
            return DiscoveryNodes.builder().add(handleD.node).localNodeId("UZP_D").build();
        }

        @Override
        public ClusterState clusterState() {
            return stateMismatch;
        }
    });
    closeables.push(zenPingD);
    logger.info("ping from UZP_A");
    Collection<ZenPing.PingResponse> pingResponses = zenPingA.pingAndWait().toList();
    assertThat(pingResponses.size(), equalTo(1));
    ZenPing.PingResponse ping = pingResponses.iterator().next();
    assertThat(ping.node().getId(), equalTo("UZP_B"));
    assertThat(ping.getClusterStateVersion(), equalTo(state.version()));
    assertPingCount(handleA, handleB, 3);
    // mismatch, shouldn't ping
    assertPingCount(handleA, handleC, 0);
    // mismatch, shouldn't ping
    assertPingCount(handleA, handleD, 0);
    // ping again, this time from B,
    logger.info("ping from UZP_B");
    pingResponses = zenPingB.pingAndWait().toList();
    assertThat(pingResponses.size(), equalTo(1));
    ping = pingResponses.iterator().next();
    assertThat(ping.node().getId(), equalTo("UZP_A"));
    assertThat(ping.getClusterStateVersion(), equalTo(ElectMasterService.MasterCandidate.UNRECOVERED_CLUSTER_VERSION));
    assertPingCount(handleB, handleA, 3);
    // mismatch, shouldn't ping
    assertPingCount(handleB, handleC, 0);
    // mismatch, shouldn't ping
    assertPingCount(handleB, handleD, 0);
    logger.info("ping from UZP_C");
    pingResponses = zenPingC.pingAndWait().toList();
    assertThat(pingResponses.size(), equalTo(1));
    assertPingCount(handleC, handleA, 0);
    assertPingCount(handleC, handleB, 0);
    assertPingCount(handleC, handleD, 3);
    logger.info("ping from UZP_D");
    pingResponses = zenPingD.pingAndWait().toList();
    assertThat(pingResponses.size(), equalTo(1));
    assertPingCount(handleD, handleA, 0);
    assertPingCount(handleD, handleB, 0);
    assertPingCount(handleD, handleC, 3);
}
Also used : Arrays(java.util.Arrays) BigArrays(org.elasticsearch.common.util.BigArrays) ConcurrentCollections(org.elasticsearch.common.util.concurrent.ConcurrentCollections) BiFunction(java.util.function.BiFunction) ClusterBlocks(org.elasticsearch.cluster.block.ClusterBlocks) InetAddress(java.net.InetAddress) STATE_NOT_RECOVERED_BLOCK(org.elasticsearch.gateway.GatewayService.STATE_NOT_RECOVERED_BLOCK) ClusterState(org.elasticsearch.cluster.ClusterState) ConnectTransportException(org.elasticsearch.transport.ConnectTransportException) Settings(org.elasticsearch.common.settings.Settings) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Mockito.verifyNoMoreInteractions(org.mockito.Mockito.verifyNoMoreInteractions) Matchers.eq(org.mockito.Matchers.eq) After(org.junit.After) Map(java.util.Map) ThreadPool(org.elasticsearch.threadpool.ThreadPool) ClusterName(org.elasticsearch.cluster.ClusterName) Role(org.elasticsearch.cluster.node.DiscoveryNode.Role) ThreadFactory(java.util.concurrent.ThreadFactory) EnumSet(java.util.EnumSet) Transport(org.elasticsearch.transport.Transport) Collection(java.util.Collection) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) Set(java.util.Set) InetSocketAddress(java.net.InetSocketAddress) Collectors(java.util.stream.Collectors) CountDownLatch(java.util.concurrent.CountDownLatch) AbstractRunnable(org.elasticsearch.common.util.concurrent.AbstractRunnable) List(java.util.List) Logger(org.apache.logging.log4j.Logger) Version(org.elasticsearch.Version) TransportAddress(org.elasticsearch.common.transport.TransportAddress) TransportConnectionListener(org.elasticsearch.transport.TransportConnectionListener) TransportSettings(org.elasticsearch.transport.TransportSettings) Matchers.equalTo(org.hamcrest.Matchers.equalTo) TransportResponseHandler(org.elasticsearch.transport.TransportResponseHandler) TransportRequestOptions(org.elasticsearch.transport.TransportRequestOptions) TransportException(org.elasticsearch.transport.TransportException) NetworkAddress(org.elasticsearch.common.network.NetworkAddress) Mockito.mock(org.mockito.Mockito.mock) IntStream(java.util.stream.IntStream) Matchers(org.mockito.Matchers) HashMap(java.util.HashMap) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress) AtomicReference(java.util.concurrent.atomic.AtomicReference) CheckedBiConsumer(org.elasticsearch.common.CheckedBiConsumer) Stack(java.util.Stack) ArrayList(java.util.ArrayList) ConcurrentMap(java.util.concurrent.ConcurrentMap) HashSet(java.util.HashSet) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) NetworkService(org.elasticsearch.common.network.NetworkService) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) TimeValue(org.elasticsearch.common.unit.TimeValue) Matchers.hasSize(org.hamcrest.Matchers.hasSize) ESTestCase(org.elasticsearch.test.ESTestCase) MockTransportService(org.elasticsearch.test.transport.MockTransportService) TransportService(org.elasticsearch.transport.TransportService) ExecutorService(java.util.concurrent.ExecutorService) Before(org.junit.Before) ConnectionProfile(org.elasticsearch.transport.ConnectionProfile) Collections.emptyMap(java.util.Collections.emptyMap) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) Matchers.empty(org.hamcrest.Matchers.empty) EsExecutors(org.elasticsearch.common.util.concurrent.EsExecutors) Collections.emptySet(java.util.Collections.emptySet) IOUtils(org.apache.lucene.util.IOUtils) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) VersionUtils(org.elasticsearch.test.VersionUtils) Mockito.verify(org.mockito.Mockito.verify) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) Closeable(java.io.Closeable) Collections(java.util.Collections) NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) CheckedBiConsumer(org.elasticsearch.common.CheckedBiConsumer) InetSocketAddress(java.net.InetSocketAddress) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) Version(org.elasticsearch.Version) ClusterName(org.elasticsearch.cluster.ClusterName) Settings(org.elasticsearch.common.settings.Settings) TransportSettings(org.elasticsearch.transport.TransportSettings) DiscoveryNodes(org.elasticsearch.cluster.node.DiscoveryNodes) ClusterState(org.elasticsearch.cluster.ClusterState) ConnectionProfile(org.elasticsearch.transport.ConnectionProfile) NetworkService(org.elasticsearch.common.network.NetworkService) Transport(org.elasticsearch.transport.Transport) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 14 with ConnectTransportException

use of org.elasticsearch.transport.ConnectTransportException in project elasticsearch by elastic.

the class FailAndRetryMockTransport method getConnection.

@Override
public Connection getConnection(DiscoveryNode node) {
    return new Connection() {

        @Override
        public DiscoveryNode getNode() {
            return node;
        }

        @Override
        public void sendRequest(long requestId, String action, TransportRequest request, TransportRequestOptions options) throws IOException, TransportException {
            //we make sure that nodes get added to the connected ones when calling addTransportAddress, by returning proper nodes info
            if (connectMode) {
                if (TransportLivenessAction.NAME.equals(action)) {
                    TransportResponseHandler transportResponseHandler = transportServiceAdapter.onResponseReceived(requestId);
                    transportResponseHandler.handleResponse(new LivenessResponse(ClusterName.CLUSTER_NAME_SETTING.getDefault(Settings.EMPTY), node));
                } else if (ClusterStateAction.NAME.equals(action)) {
                    TransportResponseHandler transportResponseHandler = transportServiceAdapter.onResponseReceived(requestId);
                    ClusterState clusterState = getMockClusterState(node);
                    transportResponseHandler.handleResponse(new ClusterStateResponse(clusterName, clusterState, 0L));
                } else {
                    throw new UnsupportedOperationException("Mock transport does not understand action " + action);
                }
                return;
            }
            //once nodes are connected we'll just return errors for each sendRequest call
            triedNodes.add(node);
            if (random.nextInt(100) > 10) {
                connectTransportExceptions.incrementAndGet();
                throw new ConnectTransportException(node, "node not available");
            } else {
                if (random.nextBoolean()) {
                    failures.incrementAndGet();
                    //throw whatever exception that is not a subclass of ConnectTransportException
                    throw new IllegalStateException();
                } else {
                    TransportResponseHandler transportResponseHandler = transportServiceAdapter.onResponseReceived(requestId);
                    if (random.nextBoolean()) {
                        successes.incrementAndGet();
                        transportResponseHandler.handleResponse(newResponse());
                    } else {
                        failures.incrementAndGet();
                        transportResponseHandler.handleException(new TransportException("transport exception"));
                    }
                }
            }
        }

        @Override
        public void close() throws IOException {
        }
    };
}
Also used : LivenessResponse(org.elasticsearch.action.admin.cluster.node.liveness.LivenessResponse) ClusterState(org.elasticsearch.cluster.ClusterState) TransportRequest(org.elasticsearch.transport.TransportRequest) ConnectTransportException(org.elasticsearch.transport.ConnectTransportException) ClusterStateResponse(org.elasticsearch.action.admin.cluster.state.ClusterStateResponse) TransportResponseHandler(org.elasticsearch.transport.TransportResponseHandler) TransportRequestOptions(org.elasticsearch.transport.TransportRequestOptions) ConnectTransportException(org.elasticsearch.transport.ConnectTransportException) TransportException(org.elasticsearch.transport.TransportException)

Example 15 with ConnectTransportException

use of org.elasticsearch.transport.ConnectTransportException in project elasticsearch by elastic.

the class IndicesStoreIntegrationIT method testShardCleanupIfShardDeletionAfterRelocationFailedAndIndexDeleted.

/* Test that shard is deleted in case ShardActiveRequest after relocation and next incoming cluster state is an index delete. */
public void testShardCleanupIfShardDeletionAfterRelocationFailedAndIndexDeleted() throws Exception {
    final String node_1 = internalCluster().startNode();
    logger.info("--> creating index [test] with one shard and on replica");
    assertAcked(prepareCreate("test").setSettings(Settings.builder().put(indexSettings()).put(IndexMetaData.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetaData.SETTING_NUMBER_OF_REPLICAS, 0)));
    ensureGreen("test");
    ClusterState state = client().admin().cluster().prepareState().get().getState();
    Index index = state.metaData().index("test").getIndex();
    assertThat(Files.exists(shardDirectory(node_1, index, 0)), equalTo(true));
    assertThat(Files.exists(indexDirectory(node_1, index)), equalTo(true));
    final String node_2 = internalCluster().startDataOnlyNode(Settings.builder().build());
    assertFalse(client().admin().cluster().prepareHealth().setWaitForNodes("2").get().isTimedOut());
    assertThat(Files.exists(shardDirectory(node_1, index, 0)), equalTo(true));
    assertThat(Files.exists(indexDirectory(node_1, index)), equalTo(true));
    assertThat(Files.exists(shardDirectory(node_2, index, 0)), equalTo(false));
    assertThat(Files.exists(indexDirectory(node_2, index)), equalTo(false));
    // add a transport delegate that will prevent the shard active request to succeed the first time after relocation has finished.
    // node_1 will then wait for the next cluster state change before it tries a next attempt to delete the shard.
    MockTransportService transportServiceNode_1 = (MockTransportService) internalCluster().getInstance(TransportService.class, node_1);
    TransportService transportServiceNode_2 = internalCluster().getInstance(TransportService.class, node_2);
    final CountDownLatch shardActiveRequestSent = new CountDownLatch(1);
    transportServiceNode_1.addDelegate(transportServiceNode_2, new MockTransportService.DelegateTransport(transportServiceNode_1.original()) {

        @Override
        protected void sendRequest(Connection connection, long requestId, String action, TransportRequest request, TransportRequestOptions options) throws IOException {
            if (action.equals("internal:index/shard/exists") && shardActiveRequestSent.getCount() > 0) {
                shardActiveRequestSent.countDown();
                logger.info("prevent shard active request from being sent");
                throw new ConnectTransportException(connection.getNode(), "DISCONNECT: simulated");
            }
            super.sendRequest(connection, requestId, action, request, options);
        }
    });
    logger.info("--> move shard from {} to {}, and wait for relocation to finish", node_1, node_2);
    internalCluster().client().admin().cluster().prepareReroute().add(new MoveAllocationCommand("test", 0, node_1, node_2)).get();
    shardActiveRequestSent.await();
    ClusterHealthResponse clusterHealth = client().admin().cluster().prepareHealth().setWaitForNoRelocatingShards(true).get();
    assertThat(clusterHealth.isTimedOut(), equalTo(false));
    logClusterState();
    // delete the index. node_1 that still waits for the next cluster state update will then get the delete index next.
    // it must still delete the shard, even if it cannot find it anymore in indicesservice
    client().admin().indices().prepareDelete("test").get();
    assertThat(waitForShardDeletion(node_1, index, 0), equalTo(false));
    assertThat(waitForIndexDeletion(node_1, index), equalTo(false));
    assertThat(Files.exists(shardDirectory(node_1, index, 0)), equalTo(false));
    assertThat(Files.exists(indexDirectory(node_1, index)), equalTo(false));
    assertThat(waitForShardDeletion(node_2, index, 0), equalTo(false));
    assertThat(waitForIndexDeletion(node_2, index), equalTo(false));
    assertThat(Files.exists(shardDirectory(node_2, index, 0)), equalTo(false));
    assertThat(Files.exists(indexDirectory(node_2, index)), equalTo(false));
}
Also used : ClusterState(org.elasticsearch.cluster.ClusterState) TransportRequest(org.elasticsearch.transport.TransportRequest) MockTransportService(org.elasticsearch.test.transport.MockTransportService) ClusterHealthResponse(org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse) MoveAllocationCommand(org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand) Index(org.elasticsearch.index.Index) IOException(java.io.IOException) CountDownLatch(java.util.concurrent.CountDownLatch) MockTransportService(org.elasticsearch.test.transport.MockTransportService) TransportService(org.elasticsearch.transport.TransportService) ConnectTransportException(org.elasticsearch.transport.ConnectTransportException) TransportRequestOptions(org.elasticsearch.transport.TransportRequestOptions)

Aggregations

ConnectTransportException (org.elasticsearch.transport.ConnectTransportException)22 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)12 IOException (java.io.IOException)11 TransportRequest (org.elasticsearch.transport.TransportRequest)10 TransportRequestOptions (org.elasticsearch.transport.TransportRequestOptions)9 TransportService (org.elasticsearch.transport.TransportService)8 ClusterState (org.elasticsearch.cluster.ClusterState)7 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)6 Settings (org.elasticsearch.common.settings.Settings)6 TimeValue (org.elasticsearch.common.unit.TimeValue)6 MockTransportService (org.elasticsearch.test.transport.MockTransportService)5 TransportException (org.elasticsearch.transport.TransportException)5 TimeValue (io.crate.common.unit.TimeValue)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 ElasticsearchException (org.elasticsearch.ElasticsearchException)4 AbstractRunnable (org.elasticsearch.common.util.concurrent.AbstractRunnable)4 TransportResponseHandler (org.elasticsearch.transport.TransportResponseHandler)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 CountDownLatch (java.util.concurrent.CountDownLatch)3