Search in sources :

Example 1 with NetworkService

use of org.elasticsearch.common.network.NetworkService in project elasticsearch by elastic.

the class Netty4HttpServerTransportTests method setup.

@Before
public void setup() throws Exception {
    networkService = new NetworkService(Settings.EMPTY, Collections.emptyList());
    threadPool = new TestThreadPool("test");
    bigArrays = new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService());
}
Also used : NetworkService(org.elasticsearch.common.network.NetworkService) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) Before(org.junit.Before)

Example 2 with NetworkService

use of org.elasticsearch.common.network.NetworkService in project elasticsearch by elastic.

the class SimpleNetty4TransportTests method nettyFromThreadPool.

public static MockTransportService nettyFromThreadPool(Settings settings, ThreadPool threadPool, final Version version, ClusterSettings clusterSettings, boolean doHandshake) {
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    Transport transport = new Netty4Transport(settings, threadPool, new NetworkService(settings, Collections.emptyList()), BigArrays.NON_RECYCLING_INSTANCE, namedWriteableRegistry, new NoneCircuitBreakerService()) {

        @Override
        protected Version executeHandshake(DiscoveryNode node, Channel channel, TimeValue timeout) throws IOException, InterruptedException {
            if (doHandshake) {
                return super.executeHandshake(node, channel, timeout);
            } else {
                return version.minimumCompatibilityVersion();
            }
        }

        @Override
        protected Version getCurrentVersion() {
            return version;
        }
    };
    MockTransportService mockTransportService = MockTransportService.createNewService(Settings.EMPTY, transport, version, threadPool, clusterSettings);
    mockTransportService.start();
    return mockTransportService;
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) DiscoveryNode(org.elasticsearch.cluster.node.DiscoveryNode) MockTransportService(org.elasticsearch.test.transport.MockTransportService) Channel(io.netty.channel.Channel) NetworkService(org.elasticsearch.common.network.NetworkService) Transport(org.elasticsearch.transport.Transport) TimeValue(org.elasticsearch.common.unit.TimeValue) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService)

Example 3 with NetworkService

use of org.elasticsearch.common.network.NetworkService in project elasticsearch by elastic.

the class Netty4HttpServerPipeliningTests method setup.

@Before
public void setup() throws Exception {
    networkService = new NetworkService(Settings.EMPTY, Collections.emptyList());
    threadPool = new TestThreadPool("test");
    bigArrays = new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService());
}
Also used : NetworkService(org.elasticsearch.common.network.NetworkService) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) TestThreadPool(org.elasticsearch.threadpool.TestThreadPool) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) Before(org.junit.Before)

Example 4 with NetworkService

use of org.elasticsearch.common.network.NetworkService in project elasticsearch by elastic.

the class Netty4SizeHeaderFrameDecoderTests method startThreadPool.

@Before
public void startThreadPool() {
    threadPool = new ThreadPool(settings);
    NetworkService networkService = new NetworkService(settings, Collections.emptyList());
    BigArrays bigArrays = new MockBigArrays(Settings.EMPTY, new NoneCircuitBreakerService());
    nettyTransport = new Netty4Transport(settings, threadPool, networkService, bigArrays, new NamedWriteableRegistry(Collections.emptyList()), new NoneCircuitBreakerService());
    nettyTransport.start();
    TransportAddress[] boundAddresses = nettyTransport.boundAddress().boundAddresses();
    TransportAddress transportAddress = (TransportAddress) randomFrom(boundAddresses);
    port = transportAddress.address().getPort();
    host = transportAddress.address().getAddress();
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) BigArrays(org.elasticsearch.common.util.BigArrays) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) TransportAddress(org.elasticsearch.common.transport.TransportAddress) ThreadPool(org.elasticsearch.threadpool.ThreadPool) NetworkService(org.elasticsearch.common.network.NetworkService) MockBigArrays(org.elasticsearch.common.util.MockBigArrays) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) Before(org.junit.Before)

Example 5 with NetworkService

use of org.elasticsearch.common.network.NetworkService in project elasticsearch by elastic.

the class Ec2DiscoveryTests method createTransportService.

@Before
public void createTransportService() {
    NamedWriteableRegistry namedWriteableRegistry = new NamedWriteableRegistry(Collections.emptyList());
    final Transport transport = new MockTcpTransport(Settings.EMPTY, threadPool, BigArrays.NON_RECYCLING_INSTANCE, new NoneCircuitBreakerService(), namedWriteableRegistry, new NetworkService(Settings.EMPTY, Collections.emptyList()), Version.CURRENT) {

        @Override
        public TransportAddress[] addressesFromString(String address, int perAddressLimit) throws UnknownHostException {
            // we just need to ensure we don't resolve DNS here
            return new TransportAddress[] { poorMansDNS.getOrDefault(address, buildNewFakeTransportAddress()) };
        }
    };
    transportService = new MockTransportService(Settings.EMPTY, transport, threadPool, TransportService.NOOP_TRANSPORT_INTERCEPTOR, null);
}
Also used : NamedWriteableRegistry(org.elasticsearch.common.io.stream.NamedWriteableRegistry) MockTransportService(org.elasticsearch.test.transport.MockTransportService) TransportAddress(org.elasticsearch.common.transport.TransportAddress) NetworkService(org.elasticsearch.common.network.NetworkService) Matchers.containsString(org.hamcrest.Matchers.containsString) Transport(org.elasticsearch.transport.Transport) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) Before(org.junit.Before)

Aggregations

NetworkService (org.elasticsearch.common.network.NetworkService)38 NoneCircuitBreakerService (org.elasticsearch.indices.breaker.NoneCircuitBreakerService)26 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)25 DiscoveryNode (org.elasticsearch.cluster.node.DiscoveryNode)19 Settings (org.elasticsearch.common.settings.Settings)19 MockTransportService (org.elasticsearch.test.transport.MockTransportService)17 IOException (java.io.IOException)15 MockTcpTransport (org.elasticsearch.transport.MockTcpTransport)15 Transport (org.elasticsearch.transport.Transport)14 TransportAddress (org.elasticsearch.common.transport.TransportAddress)13 Before (org.junit.Before)13 TestThreadPool (org.elasticsearch.threadpool.TestThreadPool)12 TransportService (org.elasticsearch.transport.TransportService)12 BigArrays (org.elasticsearch.common.util.BigArrays)11 ThreadPool (org.elasticsearch.threadpool.ThreadPool)11 BoundTransportAddress (org.elasticsearch.common.transport.BoundTransportAddress)10 TimeValue (org.elasticsearch.common.unit.TimeValue)10 Collections (java.util.Collections)9 TimeUnit (java.util.concurrent.TimeUnit)9 Logger (org.apache.logging.log4j.Logger)9