Search in sources :

Example 21 with BigArrays

use of org.elasticsearch.common.util.BigArrays in project elasticsearch by elastic.

the class NetworkModuleTests method testDefaultKeys.

public void testDefaultKeys() {
    Settings settings = Settings.builder().put(NetworkModule.HTTP_DEFAULT_TYPE_SETTING.getKey(), "default_custom").put(NetworkModule.TRANSPORT_DEFAULT_TYPE_SETTING.getKey(), "default_custom").build();
    Supplier<HttpServerTransport> custom = FakeHttpTransport::new;
    Supplier<HttpServerTransport> def = FakeHttpTransport::new;
    Supplier<Transport> customTransport = () -> null;
    NetworkModule module = newNetworkModule(settings, false, new NetworkPlugin() {

        @Override
        public Map<String, Supplier<Transport>> getTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays, CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NetworkService networkService) {
            return Collections.singletonMap("default_custom", customTransport);
        }

        @Override
        public Map<String, Supplier<HttpServerTransport>> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays, CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NamedXContentRegistry xContentRegistry, NetworkService networkService, HttpServerTransport.Dispatcher requestDispatcher) {
            Map<String, Supplier<HttpServerTransport>> supplierMap = new HashMap<>();
            supplierMap.put("custom", custom);
            supplierMap.put("default_custom", def);
            return supplierMap;
        }
    });
    assertSame(def, module.getHttpServerTransportSupplier());
    assertSame(customTransport, module.getTransportSupplier());
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) NetworkPlugin(org.elasticsearch.plugins.NetworkPlugin) ThreadPool(org.elasticsearch.threadpool.ThreadPool) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) HttpServerTransport(org.elasticsearch.http.HttpServerTransport) BigArrays(org.elasticsearch.common.util.BigArrays) HttpServerTransport(org.elasticsearch.http.HttpServerTransport) Transport(org.elasticsearch.transport.Transport) CircuitBreakerService(org.elasticsearch.indices.breaker.CircuitBreakerService) HashMap(java.util.HashMap) Map(java.util.Map) NamedXContentRegistry(org.elasticsearch.common.xcontent.NamedXContentRegistry) Settings(org.elasticsearch.common.settings.Settings)

Example 22 with BigArrays

use of org.elasticsearch.common.util.BigArrays in project elasticsearch by elastic.

the class SearchSlowLogTests method createSearchContext.

@Override
protected SearchContext createSearchContext(IndexService indexService) {
    BigArrays bigArrays = indexService.getBigArrays();
    ThreadPool threadPool = indexService.getThreadPool();
    return new TestSearchContext(threadPool, bigArrays, indexService) {

        final ShardSearchRequest request = new ShardSearchRequest() {

            private SearchSourceBuilder searchSourceBuilder;

            @Override
            public ShardId shardId() {
                return new ShardId(indexService.index(), 0);
            }

            @Override
            public String[] types() {
                return new String[0];
            }

            @Override
            public SearchSourceBuilder source() {
                return searchSourceBuilder;
            }

            @Override
            public void source(SearchSourceBuilder source) {
                searchSourceBuilder = source;
            }

            @Override
            public int numberOfShards() {
                return 0;
            }

            @Override
            public SearchType searchType() {
                return null;
            }

            @Override
            public QueryBuilder filteringAliases() {
                return null;
            }

            @Override
            public float indexBoost() {
                return 1.0f;
            }

            @Override
            public long nowInMillis() {
                return 0;
            }

            @Override
            public Boolean requestCache() {
                return null;
            }

            @Override
            public Scroll scroll() {
                return null;
            }

            @Override
            public void setProfile(boolean profile) {
            }

            @Override
            public boolean isProfile() {
                return false;
            }

            @Override
            public BytesReference cacheKey() throws IOException {
                return null;
            }

            @Override
            public void rewrite(QueryShardContext context) throws IOException {
            }
        };

        @Override
        public ShardSearchRequest request() {
            return request;
        }
    };
}
Also used : BytesReference(org.elasticsearch.common.bytes.BytesReference) Scroll(org.elasticsearch.search.Scroll) ThreadPool(org.elasticsearch.threadpool.ThreadPool) QueryBuilder(org.elasticsearch.index.query.QueryBuilder) IOException(java.io.IOException) SearchSourceBuilder(org.elasticsearch.search.builder.SearchSourceBuilder) ShardId(org.elasticsearch.index.shard.ShardId) BigArrays(org.elasticsearch.common.util.BigArrays) TestSearchContext(org.elasticsearch.test.TestSearchContext) ShardSearchRequest(org.elasticsearch.search.internal.ShardSearchRequest) QueryShardContext(org.elasticsearch.index.query.QueryShardContext) SearchType(org.elasticsearch.action.search.SearchType)

Example 23 with BigArrays

use of org.elasticsearch.common.util.BigArrays in project elasticsearch by elastic.

the class NettyTransportMultiPortTests method startTransport.

private TcpTransport<?> startTransport(Settings settings, ThreadPool threadPool) {
    BigArrays bigArrays = new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService());
    TcpTransport<?> transport = new Netty4Transport(settings, threadPool, new NetworkService(settings, Collections.emptyList()), bigArrays, new NamedWriteableRegistry(Collections.emptyList()), new NoneCircuitBreakerService());
    transport.start();
    assertThat(transport.lifecycleState(), is(Lifecycle.State.STARTED));
    return transport;
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) BigArrays(org.elasticsearch.common.util.BigArrays) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) NetworkService(org.elasticsearch.common.network.NetworkService) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 24 with BigArrays

use of org.elasticsearch.common.util.BigArrays in project elasticsearch by elastic.

the class ESSingleNodeTestCase method createSearchContext.

/**
     * Create a new search context.
     */
protected SearchContext createSearchContext(IndexService indexService) {
    BigArrays bigArrays = indexService.getBigArrays();
    ThreadPool threadPool = indexService.getThreadPool();
    return new TestSearchContext(threadPool, bigArrays, indexService);
}
Also used : BigArrays(org.elasticsearch.common.util.BigArrays) ThreadPool(org.elasticsearch.threadpool.ThreadPool)

Example 25 with BigArrays

use of org.elasticsearch.common.util.BigArrays in project elasticsearch by elastic.

the class MockNodeTests method testComponentsMockedByMarkerPlugins.

/**
     * Test that we add the appropriate mock services when their plugins are added. This is a very heavy test for a testing component but
     * we've broken it in the past so it is important.
     */
public void testComponentsMockedByMarkerPlugins() throws IOException {
    Settings settings = // All these are required or MockNode will fail to build.
    Settings.builder().put(Environment.PATH_HOME_SETTING.getKey(), createTempDir()).put("transport.type", MockTcpTransportPlugin.MOCK_TCP_TRANSPORT_NAME).put("http.enabled", false).build();
    List<Class<? extends Plugin>> plugins = new ArrayList<>();
    plugins.add(MockTcpTransportPlugin.class);
    boolean useMockBigArrays = randomBoolean();
    boolean useMockSearchService = randomBoolean();
    if (useMockBigArrays) {
        plugins.add(NodeMocksPlugin.class);
    }
    if (useMockSearchService) {
        plugins.add(MockSearchService.TestPlugin.class);
    }
    try (MockNode node = new MockNode(settings, plugins)) {
        BigArrays bigArrays = node.injector().getInstance(BigArrays.class);
        SearchService searchService = node.injector().getInstance(SearchService.class);
        if (useMockBigArrays) {
            assertSame(bigArrays.getClass(), MockBigArrays.class);
        } else {
            assertSame(bigArrays.getClass(), BigArrays.class);
        }
        if (useMockSearchService) {
            assertSame(searchService.getClass(), MockSearchService.class);
        } else {
            assertSame(searchService.getClass(), SearchService.class);
        }
    }
}
Also used : BigArrays(org.elasticsearch.common.util.BigArrays) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) MockSearchService(org.elasticsearch.search.MockSearchService) SearchService(org.elasticsearch.search.SearchService) ArrayList(java.util.ArrayList) MockSearchService(org.elasticsearch.search.MockSearchService) Settings(org.elasticsearch.common.settings.Settings) Plugin(org.elasticsearch.plugins.Plugin) MockTcpTransportPlugin(org.elasticsearch.transport.MockTcpTransportPlugin)

Aggregations

BigArrays (org.elasticsearch.common.util.BigArrays)26 LeafBucketCollectorBase (org.elasticsearch.search.aggregations.LeafBucketCollectorBase)12 ThreadPool (org.elasticsearch.threadpool.ThreadPool)10 SortedNumericDoubleValues (org.elasticsearch.index.fielddata.SortedNumericDoubleValues)8 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)7 Settings (org.elasticsearch.common.settings.Settings)7 CircuitBreakerService (org.elasticsearch.indices.breaker.CircuitBreakerService)6 TestThreadPool (org.elasticsearch.threadpool.TestThreadPool)6 NamedXContentRegistry (org.elasticsearch.common.xcontent.NamedXContentRegistry)5 NetworkPlugin (org.elasticsearch.plugins.NetworkPlugin)5 HashMap (java.util.HashMap)4 Map (java.util.Map)4 HttpServerTransport (org.elasticsearch.http.HttpServerTransport)4 Transport (org.elasticsearch.transport.Transport)4 List (java.util.List)3 NetworkService (org.elasticsearch.common.network.NetworkService)3 MockBigArrays (org.elasticsearch.common.util.MockBigArrays)3 NumericDoubleValues (org.elasticsearch.index.fielddata.NumericDoubleValues)3 Closeable (java.io.Closeable)2 IOException (java.io.IOException)2