Search in sources :

Example 1 with TransportConnectionListener

use of org.opensearch.transport.TransportConnectionListener in project OpenSearch by opensearch-project.

the class TransportSearchActionTests method testCollectSearchShards.

public void testCollectSearchShards() throws Exception {
    int numClusters = randomIntBetween(2, 10);
    DiscoveryNode[] nodes = new DiscoveryNode[numClusters];
    Map<String, OriginalIndices> remoteIndicesByCluster = new HashMap<>();
    Settings.Builder builder = Settings.builder();
    MockTransportService[] mockTransportServices = startTransport(numClusters, nodes, remoteIndicesByCluster, builder);
    Settings settings = builder.build();
    try (MockTransportService service = MockTransportService.createNewService(settings, Version.CURRENT, threadPool, null)) {
        service.start();
        service.acceptIncomingRequests();
        RemoteClusterService remoteClusterService = service.getRemoteClusterService();
        {
            final CountDownLatch latch = new CountDownLatch(1);
            AtomicReference<Map<String, ClusterSearchShardsResponse>> response = new AtomicReference<>();
            AtomicInteger skippedClusters = new AtomicInteger();
            TransportSearchAction.collectSearchShards(IndicesOptions.lenientExpandOpen(), null, null, skippedClusters, remoteIndicesByCluster, remoteClusterService, threadPool, new LatchedActionListener<>(ActionListener.wrap(response::set, e -> fail("no failures expected")), latch));
            awaitLatch(latch, 5, TimeUnit.SECONDS);
            assertEquals(0, skippedClusters.get());
            assertNotNull(response.get());
            Map<String, ClusterSearchShardsResponse> map = response.get();
            assertEquals(numClusters, map.size());
            for (int i = 0; i < numClusters; i++) {
                String clusterAlias = "remote" + i;
                assertTrue(map.containsKey(clusterAlias));
                ClusterSearchShardsResponse shardsResponse = map.get(clusterAlias);
                assertEquals(1, shardsResponse.getNodes().length);
            }
        }
        {
            final CountDownLatch latch = new CountDownLatch(1);
            AtomicReference<Exception> failure = new AtomicReference<>();
            AtomicInteger skippedClusters = new AtomicInteger(0);
            TransportSearchAction.collectSearchShards(IndicesOptions.lenientExpandOpen(), "index_not_found", null, skippedClusters, remoteIndicesByCluster, remoteClusterService, threadPool, new LatchedActionListener<>(ActionListener.wrap(r -> fail("no response expected"), failure::set), latch));
            awaitLatch(latch, 5, TimeUnit.SECONDS);
            assertEquals(0, skippedClusters.get());
            assertNotNull(failure.get());
            assertThat(failure.get(), instanceOf(RemoteTransportException.class));
            RemoteTransportException remoteTransportException = (RemoteTransportException) failure.get();
            assertEquals(RestStatus.NOT_FOUND, remoteTransportException.status());
        }
        int numDisconnectedClusters = randomIntBetween(1, numClusters);
        Set<DiscoveryNode> disconnectedNodes = new HashSet<>(numDisconnectedClusters);
        Set<Integer> disconnectedNodesIndices = new HashSet<>(numDisconnectedClusters);
        while (disconnectedNodes.size() < numDisconnectedClusters) {
            int i = randomIntBetween(0, numClusters - 1);
            if (disconnectedNodes.add(nodes[i])) {
                assertTrue(disconnectedNodesIndices.add(i));
            }
        }
        CountDownLatch disconnectedLatch = new CountDownLatch(numDisconnectedClusters);
        RemoteClusterServiceTests.addConnectionListener(remoteClusterService, new TransportConnectionListener() {

            @Override
            public void onNodeDisconnected(DiscoveryNode node, Transport.Connection connection) {
                if (disconnectedNodes.remove(node)) {
                    disconnectedLatch.countDown();
                }
            }
        });
        for (DiscoveryNode disconnectedNode : disconnectedNodes) {
            service.addFailToSendNoConnectRule(disconnectedNode.getAddress());
        }
        {
            final CountDownLatch latch = new CountDownLatch(1);
            AtomicInteger skippedClusters = new AtomicInteger(0);
            AtomicReference<Exception> failure = new AtomicReference<>();
            TransportSearchAction.collectSearchShards(IndicesOptions.lenientExpandOpen(), null, null, skippedClusters, remoteIndicesByCluster, remoteClusterService, threadPool, new LatchedActionListener<>(ActionListener.wrap(r -> fail("no response expected"), failure::set), latch));
            awaitLatch(latch, 5, TimeUnit.SECONDS);
            assertEquals(0, skippedClusters.get());
            assertNotNull(failure.get());
            assertThat(failure.get(), instanceOf(RemoteTransportException.class));
            assertThat(failure.get().getMessage(), containsString("error while communicating with remote cluster ["));
            assertThat(failure.get().getCause(), instanceOf(NodeDisconnectedException.class));
        }
        // setting skip_unavailable to true for all the disconnected clusters will make the request succeed again
        for (int i : disconnectedNodesIndices) {
            RemoteClusterServiceTests.updateSkipUnavailable(remoteClusterService, "remote" + i, true);
        }
        {
            final CountDownLatch latch = new CountDownLatch(1);
            AtomicInteger skippedClusters = new AtomicInteger(0);
            AtomicReference<Map<String, ClusterSearchShardsResponse>> response = new AtomicReference<>();
            TransportSearchAction.collectSearchShards(IndicesOptions.lenientExpandOpen(), null, null, skippedClusters, remoteIndicesByCluster, remoteClusterService, threadPool, new LatchedActionListener<>(ActionListener.wrap(response::set, e -> fail("no failures expected")), latch));
            awaitLatch(latch, 5, TimeUnit.SECONDS);
            assertNotNull(response.get());
            Map<String, ClusterSearchShardsResponse> map = response.get();
            assertEquals(numClusters - disconnectedNodesIndices.size(), map.size());
            assertEquals(skippedClusters.get(), disconnectedNodesIndices.size());
            for (int i = 0; i < numClusters; i++) {
                String clusterAlias = "remote" + i;
                if (disconnectedNodesIndices.contains(i)) {
                    assertFalse(map.containsKey(clusterAlias));
                } else {
                    assertNotNull(map.get(clusterAlias));
                }
            }
        }
        // give transport service enough time to realize that the node is down, and to notify the connection listeners
        // so that RemoteClusterConnection is left with no connected nodes, hence it will retry connecting next
        assertTrue(disconnectedLatch.await(5, TimeUnit.SECONDS));
        service.clearAllRules();
        if (randomBoolean()) {
            for (int i : disconnectedNodesIndices) {
                if (randomBoolean()) {
                    RemoteClusterServiceTests.updateSkipUnavailable(remoteClusterService, "remote" + i, true);
                }
            }
        }
        {
            final CountDownLatch latch = new CountDownLatch(1);
            AtomicInteger skippedClusters = new AtomicInteger(0);
            AtomicReference<Map<String, ClusterSearchShardsResponse>> response = new AtomicReference<>();
            TransportSearchAction.collectSearchShards(IndicesOptions.lenientExpandOpen(), null, null, skippedClusters, remoteIndicesByCluster, remoteClusterService, threadPool, new LatchedActionListener<>(ActionListener.wrap(response::set, e -> fail("no failures expected")), latch));
            awaitLatch(latch, 5, TimeUnit.SECONDS);
            assertEquals(0, skippedClusters.get());
            assertNotNull(response.get());
            Map<String, ClusterSearchShardsResponse> map = response.get();
            assertEquals(numClusters, map.size());
            for (int i = 0; i < numClusters; i++) {
                String clusterAlias = "remote" + i;
                assertTrue(map.containsKey(clusterAlias));
                assertNotNull(map.get(clusterAlias));
            }
        }
        assertEquals(0, service.getConnectionManager().size());
    } finally {
        for (MockTransportService mockTransportService : mockTransportServices) {
            mockTransportService.close();
        }
    }
}
Also used : ClusterSearchShardsResponse(org.opensearch.action.admin.cluster.shards.ClusterSearchShardsResponse) Arrays(java.util.Arrays) SearchContext(org.opensearch.search.internal.SearchContext) BiFunction(java.util.function.BiFunction) TestThreadPool(org.opensearch.threadpool.TestThreadPool) SortBuilders(org.opensearch.search.sort.SortBuilders) Version(org.opensearch.Version) ClusterSearchShardsResponse(org.opensearch.action.admin.cluster.shards.ClusterSearchShardsResponse) CoreMatchers.startsWith(org.hamcrest.CoreMatchers.startsWith) Strings(org.opensearch.common.Strings) Transport(org.opensearch.transport.Transport) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) LatchedActionListener(org.opensearch.action.LatchedActionListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InternalAggregations(org.opensearch.search.aggregations.InternalAggregations) AliasFilter(org.opensearch.search.internal.AliasFilter) Map(java.util.Map) ActionListener(org.opensearch.action.ActionListener) Scroll(org.opensearch.search.Scroll) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) OpenSearchAssertions.awaitLatch(org.opensearch.test.hamcrest.OpenSearchAssertions.awaitLatch) InternalAggregationTestCase.emptyReduceContextBuilder(org.opensearch.test.InternalAggregationTestCase.emptyReduceContextBuilder) Index(org.opensearch.index.Index) SearchHit(org.opensearch.search.SearchHit) OpenSearchTestCase(org.opensearch.test.OpenSearchTestCase) RemoteTransportException(org.opensearch.transport.RemoteTransportException) TransportRequestOptions(org.opensearch.transport.TransportRequestOptions) InnerHitBuilder(org.opensearch.index.query.InnerHitBuilder) Set(java.util.Set) Settings(org.opensearch.common.settings.Settings) RestStatus(org.opensearch.rest.RestStatus) TransportService(org.opensearch.transport.TransportService) OriginalIndices(org.opensearch.action.OriginalIndices) Tuple(org.opensearch.common.collect.Tuple) TransportAddress(org.opensearch.common.transport.TransportAddress) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) NodeDisconnectedException(org.opensearch.transport.NodeDisconnectedException) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) CollapseBuilder(org.opensearch.search.collapse.CollapseBuilder) TermsQueryBuilder(org.opensearch.index.query.TermsQueryBuilder) InternalAggregation(org.opensearch.search.aggregations.InternalAggregation) TransportException(org.opensearch.transport.TransportException) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) RemoteClusterServiceTests(org.opensearch.transport.RemoteClusterServiceTests) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) ThreadPool(org.opensearch.threadpool.ThreadPool) GroupShardsIteratorTests(org.opensearch.cluster.routing.GroupShardsIteratorTests) HashMap(java.util.HashMap) SearchHits(org.opensearch.search.SearchHits) IndicesOptions(org.opensearch.action.support.IndicesOptions) MockTransportService(org.opensearch.test.transport.MockTransportService) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ClusterState(org.opensearch.cluster.ClusterState) ShardRoutingState(org.opensearch.cluster.routing.ShardRoutingState) ClusterBlocks(org.opensearch.cluster.block.ClusterBlocks) QueryBuilders(org.opensearch.index.query.QueryBuilders) SetOnce(org.apache.lucene.util.SetOnce) RemoteClusterService(org.opensearch.transport.RemoteClusterService) TransportRequest(org.opensearch.transport.TransportRequest) TransportConnectionListener(org.opensearch.transport.TransportConnectionListener) InternalSearchResponse(org.opensearch.search.internal.InternalSearchResponse) ClusterSearchShardsGroup(org.opensearch.action.admin.cluster.shards.ClusterSearchShardsGroup) TotalHits(org.apache.lucene.search.TotalHits) ShardRouting(org.opensearch.cluster.routing.ShardRouting) ShardId(org.opensearch.index.shard.ShardId) TimeUnit(java.util.concurrent.TimeUnit) GroupShardsIterator(org.opensearch.cluster.routing.GroupShardsIterator) TestShardRouting(org.opensearch.cluster.routing.TestShardRouting) SearchShardTarget(org.opensearch.search.SearchShardTarget) RemoteClusterConnectionTests(org.opensearch.transport.RemoteClusterConnectionTests) ClusterName(org.opensearch.cluster.ClusterName) OriginalIndicesTests(org.opensearch.action.OriginalIndicesTests) MatchAllQueryBuilder(org.opensearch.index.query.MatchAllQueryBuilder) Collections(java.util.Collections) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) MockTransportService(org.opensearch.test.transport.MockTransportService) HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TransportConnectionListener(org.opensearch.transport.TransportConnectionListener) LatchedActionListener(org.opensearch.action.LatchedActionListener) Settings(org.opensearch.common.settings.Settings) HashSet(java.util.HashSet) RemoteTransportException(org.opensearch.transport.RemoteTransportException) RemoteClusterService(org.opensearch.transport.RemoteClusterService) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Transport(org.opensearch.transport.Transport) Map(java.util.Map) HashMap(java.util.HashMap) OriginalIndices(org.opensearch.action.OriginalIndices)

Example 2 with TransportConnectionListener

use of org.opensearch.transport.TransportConnectionListener in project OpenSearch by opensearch-project.

the class TransportSearchActionTests method testCCSRemoteReduce.

public void testCCSRemoteReduce() throws Exception {
    int numClusters = randomIntBetween(1, 10);
    DiscoveryNode[] nodes = new DiscoveryNode[numClusters];
    Map<String, OriginalIndices> remoteIndicesByCluster = new HashMap<>();
    Settings.Builder builder = Settings.builder();
    MockTransportService[] mockTransportServices = startTransport(numClusters, nodes, remoteIndicesByCluster, builder);
    Settings settings = builder.build();
    boolean local = randomBoolean();
    OriginalIndices localIndices = local ? new OriginalIndices(new String[] { "index" }, SearchRequest.DEFAULT_INDICES_OPTIONS) : null;
    int totalClusters = numClusters + (local ? 1 : 0);
    TransportSearchAction.SearchTimeProvider timeProvider = new TransportSearchAction.SearchTimeProvider(0, 0, () -> 0);
    try (MockTransportService service = MockTransportService.createNewService(settings, Version.CURRENT, threadPool, null)) {
        service.start();
        service.acceptIncomingRequests();
        RemoteClusterService remoteClusterService = service.getRemoteClusterService();
        {
            SearchRequest searchRequest = new SearchRequest();
            final CountDownLatch latch = new CountDownLatch(1);
            SetOnce<Tuple<SearchRequest, ActionListener<SearchResponse>>> setOnce = new SetOnce<>();
            AtomicReference<SearchResponse> response = new AtomicReference<>();
            LatchedActionListener<SearchResponse> listener = new LatchedActionListener<>(ActionListener.wrap(response::set, e -> fail("no failures expected")), latch);
            TransportSearchAction.ccsRemoteReduce(searchRequest, localIndices, remoteIndicesByCluster, timeProvider, emptyReduceContextBuilder(), remoteClusterService, threadPool, listener, (r, l) -> setOnce.set(Tuple.tuple(r, l)));
            if (localIndices == null) {
                assertNull(setOnce.get());
            } else {
                Tuple<SearchRequest, ActionListener<SearchResponse>> tuple = setOnce.get();
                assertEquals("", tuple.v1().getLocalClusterAlias());
                assertThat(tuple.v2(), instanceOf(TransportSearchAction.CCSActionListener.class));
                tuple.v2().onResponse(emptySearchResponse());
            }
            awaitLatch(latch, 5, TimeUnit.SECONDS);
            SearchResponse searchResponse = response.get();
            assertEquals(0, searchResponse.getClusters().getSkipped());
            assertEquals(totalClusters, searchResponse.getClusters().getTotal());
            assertEquals(totalClusters, searchResponse.getClusters().getSuccessful());
            assertEquals(totalClusters == 1 ? 1 : totalClusters + 1, searchResponse.getNumReducePhases());
        }
        {
            SearchRequest searchRequest = new SearchRequest();
            searchRequest.preference("index_not_found");
            final CountDownLatch latch = new CountDownLatch(1);
            SetOnce<Tuple<SearchRequest, ActionListener<SearchResponse>>> setOnce = new SetOnce<>();
            AtomicReference<Exception> failure = new AtomicReference<>();
            LatchedActionListener<SearchResponse> listener = new LatchedActionListener<>(ActionListener.wrap(r -> fail("no response expected"), failure::set), latch);
            TransportSearchAction.ccsRemoteReduce(searchRequest, localIndices, remoteIndicesByCluster, timeProvider, emptyReduceContextBuilder(), remoteClusterService, threadPool, listener, (r, l) -> setOnce.set(Tuple.tuple(r, l)));
            if (localIndices == null) {
                assertNull(setOnce.get());
            } else {
                Tuple<SearchRequest, ActionListener<SearchResponse>> tuple = setOnce.get();
                assertEquals("", tuple.v1().getLocalClusterAlias());
                assertThat(tuple.v2(), instanceOf(TransportSearchAction.CCSActionListener.class));
                tuple.v2().onResponse(emptySearchResponse());
            }
            awaitLatch(latch, 5, TimeUnit.SECONDS);
            assertNotNull(failure.get());
            assertThat(failure.get(), instanceOf(RemoteTransportException.class));
            RemoteTransportException remoteTransportException = (RemoteTransportException) failure.get();
            assertEquals(RestStatus.NOT_FOUND, remoteTransportException.status());
        }
        int numDisconnectedClusters = randomIntBetween(1, numClusters);
        Set<DiscoveryNode> disconnectedNodes = new HashSet<>(numDisconnectedClusters);
        Set<Integer> disconnectedNodesIndices = new HashSet<>(numDisconnectedClusters);
        while (disconnectedNodes.size() < numDisconnectedClusters) {
            int i = randomIntBetween(0, numClusters - 1);
            if (disconnectedNodes.add(nodes[i])) {
                assertTrue(disconnectedNodesIndices.add(i));
            }
        }
        CountDownLatch disconnectedLatch = new CountDownLatch(numDisconnectedClusters);
        RemoteClusterServiceTests.addConnectionListener(remoteClusterService, new TransportConnectionListener() {

            @Override
            public void onNodeDisconnected(DiscoveryNode node, Transport.Connection connection) {
                if (disconnectedNodes.remove(node)) {
                    disconnectedLatch.countDown();
                }
            }
        });
        for (DiscoveryNode disconnectedNode : disconnectedNodes) {
            service.addFailToSendNoConnectRule(disconnectedNode.getAddress());
        }
        {
            SearchRequest searchRequest = new SearchRequest();
            final CountDownLatch latch = new CountDownLatch(1);
            SetOnce<Tuple<SearchRequest, ActionListener<SearchResponse>>> setOnce = new SetOnce<>();
            AtomicReference<Exception> failure = new AtomicReference<>();
            LatchedActionListener<SearchResponse> listener = new LatchedActionListener<>(ActionListener.wrap(r -> fail("no response expected"), failure::set), latch);
            TransportSearchAction.ccsRemoteReduce(searchRequest, localIndices, remoteIndicesByCluster, timeProvider, emptyReduceContextBuilder(), remoteClusterService, threadPool, listener, (r, l) -> setOnce.set(Tuple.tuple(r, l)));
            if (localIndices == null) {
                assertNull(setOnce.get());
            } else {
                Tuple<SearchRequest, ActionListener<SearchResponse>> tuple = setOnce.get();
                assertEquals("", tuple.v1().getLocalClusterAlias());
                assertThat(tuple.v2(), instanceOf(TransportSearchAction.CCSActionListener.class));
                tuple.v2().onResponse(emptySearchResponse());
            }
            awaitLatch(latch, 5, TimeUnit.SECONDS);
            assertNotNull(failure.get());
            assertThat(failure.get(), instanceOf(RemoteTransportException.class));
            assertThat(failure.get().getMessage(), containsString("error while communicating with remote cluster ["));
            assertThat(failure.get().getCause(), instanceOf(NodeDisconnectedException.class));
        }
        // setting skip_unavailable to true for all the disconnected clusters will make the request succeed again
        for (int i : disconnectedNodesIndices) {
            RemoteClusterServiceTests.updateSkipUnavailable(remoteClusterService, "remote" + i, true);
        }
        {
            SearchRequest searchRequest = new SearchRequest();
            final CountDownLatch latch = new CountDownLatch(1);
            SetOnce<Tuple<SearchRequest, ActionListener<SearchResponse>>> setOnce = new SetOnce<>();
            AtomicReference<SearchResponse> response = new AtomicReference<>();
            LatchedActionListener<SearchResponse> listener = new LatchedActionListener<>(ActionListener.wrap(response::set, e -> fail("no failures expected")), latch);
            TransportSearchAction.ccsRemoteReduce(searchRequest, localIndices, remoteIndicesByCluster, timeProvider, emptyReduceContextBuilder(), remoteClusterService, threadPool, listener, (r, l) -> setOnce.set(Tuple.tuple(r, l)));
            if (localIndices == null) {
                assertNull(setOnce.get());
            } else {
                Tuple<SearchRequest, ActionListener<SearchResponse>> tuple = setOnce.get();
                assertEquals("", tuple.v1().getLocalClusterAlias());
                assertThat(tuple.v2(), instanceOf(TransportSearchAction.CCSActionListener.class));
                tuple.v2().onResponse(emptySearchResponse());
            }
            awaitLatch(latch, 5, TimeUnit.SECONDS);
            SearchResponse searchResponse = response.get();
            assertEquals(disconnectedNodesIndices.size(), searchResponse.getClusters().getSkipped());
            assertEquals(totalClusters, searchResponse.getClusters().getTotal());
            int successful = totalClusters - disconnectedNodesIndices.size();
            assertEquals(successful, searchResponse.getClusters().getSuccessful());
            assertEquals(successful == 0 ? 0 : successful + 1, searchResponse.getNumReducePhases());
        }
        // give transport service enough time to realize that the node is down, and to notify the connection listeners
        // so that RemoteClusterConnection is left with no connected nodes, hence it will retry connecting next
        assertTrue(disconnectedLatch.await(5, TimeUnit.SECONDS));
        service.clearAllRules();
        if (randomBoolean()) {
            for (int i : disconnectedNodesIndices) {
                if (randomBoolean()) {
                    RemoteClusterServiceTests.updateSkipUnavailable(remoteClusterService, "remote" + i, true);
                }
            }
        }
        {
            SearchRequest searchRequest = new SearchRequest();
            final CountDownLatch latch = new CountDownLatch(1);
            SetOnce<Tuple<SearchRequest, ActionListener<SearchResponse>>> setOnce = new SetOnce<>();
            AtomicReference<SearchResponse> response = new AtomicReference<>();
            LatchedActionListener<SearchResponse> listener = new LatchedActionListener<>(ActionListener.wrap(response::set, e -> fail("no failures expected")), latch);
            TransportSearchAction.ccsRemoteReduce(searchRequest, localIndices, remoteIndicesByCluster, timeProvider, emptyReduceContextBuilder(), remoteClusterService, threadPool, listener, (r, l) -> setOnce.set(Tuple.tuple(r, l)));
            if (localIndices == null) {
                assertNull(setOnce.get());
            } else {
                Tuple<SearchRequest, ActionListener<SearchResponse>> tuple = setOnce.get();
                assertEquals("", tuple.v1().getLocalClusterAlias());
                assertThat(tuple.v2(), instanceOf(TransportSearchAction.CCSActionListener.class));
                tuple.v2().onResponse(emptySearchResponse());
            }
            awaitLatch(latch, 5, TimeUnit.SECONDS);
            SearchResponse searchResponse = response.get();
            assertEquals(0, searchResponse.getClusters().getSkipped());
            assertEquals(totalClusters, searchResponse.getClusters().getTotal());
            assertEquals(totalClusters, searchResponse.getClusters().getSuccessful());
            assertEquals(totalClusters == 1 ? 1 : totalClusters + 1, searchResponse.getNumReducePhases());
        }
        assertEquals(0, service.getConnectionManager().size());
    } finally {
        for (MockTransportService mockTransportService : mockTransportServices) {
            mockTransportService.close();
        }
    }
}
Also used : Arrays(java.util.Arrays) SearchContext(org.opensearch.search.internal.SearchContext) BiFunction(java.util.function.BiFunction) TestThreadPool(org.opensearch.threadpool.TestThreadPool) SortBuilders(org.opensearch.search.sort.SortBuilders) Version(org.opensearch.Version) ClusterSearchShardsResponse(org.opensearch.action.admin.cluster.shards.ClusterSearchShardsResponse) CoreMatchers.startsWith(org.hamcrest.CoreMatchers.startsWith) Strings(org.opensearch.common.Strings) Transport(org.opensearch.transport.Transport) CoreMatchers.instanceOf(org.hamcrest.CoreMatchers.instanceOf) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) LatchedActionListener(org.opensearch.action.LatchedActionListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) InternalAggregations(org.opensearch.search.aggregations.InternalAggregations) AliasFilter(org.opensearch.search.internal.AliasFilter) Map(java.util.Map) ActionListener(org.opensearch.action.ActionListener) Scroll(org.opensearch.search.Scroll) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) OpenSearchAssertions.awaitLatch(org.opensearch.test.hamcrest.OpenSearchAssertions.awaitLatch) InternalAggregationTestCase.emptyReduceContextBuilder(org.opensearch.test.InternalAggregationTestCase.emptyReduceContextBuilder) Index(org.opensearch.index.Index) SearchHit(org.opensearch.search.SearchHit) OpenSearchTestCase(org.opensearch.test.OpenSearchTestCase) RemoteTransportException(org.opensearch.transport.RemoteTransportException) TransportRequestOptions(org.opensearch.transport.TransportRequestOptions) InnerHitBuilder(org.opensearch.index.query.InnerHitBuilder) Set(java.util.Set) Settings(org.opensearch.common.settings.Settings) RestStatus(org.opensearch.rest.RestStatus) TransportService(org.opensearch.transport.TransportService) OriginalIndices(org.opensearch.action.OriginalIndices) Tuple(org.opensearch.common.collect.Tuple) TransportAddress(org.opensearch.common.transport.TransportAddress) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) NodeDisconnectedException(org.opensearch.transport.NodeDisconnectedException) SearchSourceBuilder(org.opensearch.search.builder.SearchSourceBuilder) CollapseBuilder(org.opensearch.search.collapse.CollapseBuilder) TermsQueryBuilder(org.opensearch.index.query.TermsQueryBuilder) InternalAggregation(org.opensearch.search.aggregations.InternalAggregation) TransportException(org.opensearch.transport.TransportException) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) RemoteClusterServiceTests(org.opensearch.transport.RemoteClusterServiceTests) IndexMetadata(org.opensearch.cluster.metadata.IndexMetadata) ThreadPool(org.opensearch.threadpool.ThreadPool) GroupShardsIteratorTests(org.opensearch.cluster.routing.GroupShardsIteratorTests) HashMap(java.util.HashMap) SearchHits(org.opensearch.search.SearchHits) IndicesOptions(org.opensearch.action.support.IndicesOptions) MockTransportService(org.opensearch.test.transport.MockTransportService) AtomicReference(java.util.concurrent.atomic.AtomicReference) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ClusterState(org.opensearch.cluster.ClusterState) ShardRoutingState(org.opensearch.cluster.routing.ShardRoutingState) ClusterBlocks(org.opensearch.cluster.block.ClusterBlocks) QueryBuilders(org.opensearch.index.query.QueryBuilders) SetOnce(org.apache.lucene.util.SetOnce) RemoteClusterService(org.opensearch.transport.RemoteClusterService) TransportRequest(org.opensearch.transport.TransportRequest) TransportConnectionListener(org.opensearch.transport.TransportConnectionListener) InternalSearchResponse(org.opensearch.search.internal.InternalSearchResponse) ClusterSearchShardsGroup(org.opensearch.action.admin.cluster.shards.ClusterSearchShardsGroup) TotalHits(org.apache.lucene.search.TotalHits) ShardRouting(org.opensearch.cluster.routing.ShardRouting) ShardId(org.opensearch.index.shard.ShardId) TimeUnit(java.util.concurrent.TimeUnit) GroupShardsIterator(org.opensearch.cluster.routing.GroupShardsIterator) TestShardRouting(org.opensearch.cluster.routing.TestShardRouting) SearchShardTarget(org.opensearch.search.SearchShardTarget) RemoteClusterConnectionTests(org.opensearch.transport.RemoteClusterConnectionTests) ClusterName(org.opensearch.cluster.ClusterName) OriginalIndicesTests(org.opensearch.action.OriginalIndicesTests) MatchAllQueryBuilder(org.opensearch.index.query.MatchAllQueryBuilder) Collections(java.util.Collections) DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) MockTransportService(org.opensearch.test.transport.MockTransportService) HashMap(java.util.HashMap) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) TransportConnectionListener(org.opensearch.transport.TransportConnectionListener) LatchedActionListener(org.opensearch.action.LatchedActionListener) Settings(org.opensearch.common.settings.Settings) HashSet(java.util.HashSet) RemoteTransportException(org.opensearch.transport.RemoteTransportException) SetOnce(org.apache.lucene.util.SetOnce) RemoteClusterService(org.opensearch.transport.RemoteClusterService) AtomicReference(java.util.concurrent.atomic.AtomicReference) CountDownLatch(java.util.concurrent.CountDownLatch) InternalSearchResponse(org.opensearch.search.internal.InternalSearchResponse) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LatchedActionListener(org.opensearch.action.LatchedActionListener) ActionListener(org.opensearch.action.ActionListener) Transport(org.opensearch.transport.Transport) OriginalIndices(org.opensearch.action.OriginalIndices) Tuple(org.opensearch.common.collect.Tuple)

Aggregations

ArrayList (java.util.ArrayList)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Map (java.util.Map)2 Set (java.util.Set)2 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 TimeUnit (java.util.concurrent.TimeUnit)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 BiFunction (java.util.function.BiFunction)2 Function (java.util.function.Function)2 TotalHits (org.apache.lucene.search.TotalHits)2 SetOnce (org.apache.lucene.util.SetOnce)2 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)2 CoreMatchers.instanceOf (org.hamcrest.CoreMatchers.instanceOf)2 CoreMatchers.startsWith (org.hamcrest.CoreMatchers.startsWith)2