use of org.elasticsearch.threadpool.ThreadPool in project elasticsearch by elastic.
the class NetworkModuleTests method testRegisterHttpTransport.
public void testRegisterHttpTransport() {
Settings settings = Settings.builder().put(NetworkModule.HTTP_TYPE_SETTING.getKey(), "custom").put(NetworkModule.TRANSPORT_TYPE_KEY, "local").build();
Supplier<HttpServerTransport> custom = FakeHttpTransport::new;
NetworkModule module = newNetworkModule(settings, false, new NetworkPlugin() {
@Override
public Map<String, Supplier<HttpServerTransport>> getHttpTransports(Settings settings, ThreadPool threadPool, BigArrays bigArrays, CircuitBreakerService circuitBreakerService, NamedWriteableRegistry namedWriteableRegistry, NamedXContentRegistry xContentRegistry, NetworkService networkService, HttpServerTransport.Dispatcher requestDispatcher) {
return Collections.singletonMap("custom", custom);
}
});
assertSame(custom, module.getHttpServerTransportSupplier());
assertFalse(module.isTransportClient());
assertTrue(module.isHttpEnabled());
settings = Settings.builder().put(NetworkModule.HTTP_ENABLED.getKey(), false).put(NetworkModule.TRANSPORT_TYPE_KEY, "local").build();
NetworkModule newModule = newNetworkModule(settings, false);
assertFalse(newModule.isTransportClient());
assertFalse(newModule.isHttpEnabled());
expectThrows(IllegalStateException.class, () -> newModule.getHttpServerTransportSupplier());
}
use of org.elasticsearch.threadpool.ThreadPool 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());
}
use of org.elasticsearch.threadpool.ThreadPool 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;
}
};
}
use of org.elasticsearch.threadpool.ThreadPool in project elasticsearch by elastic.
the class NettyTransportMultiPortTests method testThatNettyCanBindToMultiplePorts.
public void testThatNettyCanBindToMultiplePorts() throws Exception {
Settings settings = Settings.builder().put("network.host", host).put(TransportSettings.PORT.getKey(), // will not actually bind to this
22).put("transport.profiles.default.port", 0).put("transport.profiles.client1.port", 0).build();
ThreadPool threadPool = new TestThreadPool("tst");
try (TcpTransport<?> transport = startTransport(settings, threadPool)) {
assertEquals(1, transport.profileBoundAddresses().size());
assertEquals(1, transport.boundAddress().boundAddresses().length);
} finally {
terminate(threadPool);
}
}
use of org.elasticsearch.threadpool.ThreadPool in project elasticsearch by elastic.
the class NettyTransportMultiPortTests method testThatProfileWithoutPortSettingsFails.
public void testThatProfileWithoutPortSettingsFails() throws Exception {
Settings settings = Settings.builder().put("network.host", host).put(TransportSettings.PORT.getKey(), 0).put("transport.profiles.client1.whatever", "foo").build();
ThreadPool threadPool = new TestThreadPool("tst");
try (TcpTransport<?> transport = startTransport(settings, threadPool)) {
assertEquals(0, transport.profileBoundAddresses().size());
assertEquals(1, transport.boundAddress().boundAddresses().length);
} finally {
terminate(threadPool);
}
}
Aggregations