Search in sources :

Example 6 with NetworkService

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

the class FileBasedUnicastHostsProviderTests method createTransportSvc.

@Before
public void createTransportSvc() {
    MockTcpTransport transport = new MockTcpTransport(Settings.EMPTY, threadPool, BigArrays.NON_RECYCLING_INSTANCE, new NoneCircuitBreakerService(), new NamedWriteableRegistry(Collections.emptyList()), new NetworkService(Settings.EMPTY, Collections.emptyList())) {

        @Override
        public BoundTransportAddress boundAddress() {
            return new BoundTransportAddress(new TransportAddress[] { new TransportAddress(InetAddress.getLoopbackAddress(), 9300) }, new TransportAddress(InetAddress.getLoopbackAddress(), 9300));
        }
    };
    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) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress) TransportAddress(org.elasticsearch.common.transport.TransportAddress) BoundTransportAddress(org.elasticsearch.common.transport.BoundTransportAddress) NetworkService(org.elasticsearch.common.network.NetworkService) MockTcpTransport(org.elasticsearch.transport.MockTcpTransport) NoneCircuitBreakerService(org.elasticsearch.indices.breaker.NoneCircuitBreakerService) Before(org.junit.Before)

Example 7 with NetworkService

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

the class Ec2NetworkTests method testNetworkHostEc2.

/**
     * Test for network.host: _ec2_
     */
public void testNetworkHostEc2() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_ec2_").build();
    NetworkService networkService = new NetworkService(nodeSettings, Collections.singletonList(new Ec2NameResolver(nodeSettings)));
    // TODO we need to replace that with a mock. For now we check the URL we are supposed to reach.
    try {
        networkService.resolveBindHostAddresses(null);
    } catch (IOException e) {
        assertThat(e.getMessage(), containsString("local-ipv4"));
    }
}
Also used : NetworkService(org.elasticsearch.common.network.NetworkService) Ec2NameResolver(org.elasticsearch.cloud.aws.network.Ec2NameResolver) IOException(java.io.IOException) Settings(org.elasticsearch.common.settings.Settings)

Example 8 with NetworkService

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

the class Ec2NetworkTests method testNetworkHostEc2PrivateIp.

/**
     * Test for network.host: _ec2:privateIp_
     */
public void testNetworkHostEc2PrivateIp() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_ec2:privateIp_").build();
    NetworkService networkService = new NetworkService(nodeSettings, Collections.singletonList(new Ec2NameResolver(nodeSettings)));
    // TODO we need to replace that with a mock. For now we check the URL we are supposed to reach.
    try {
        networkService.resolveBindHostAddresses(null);
    } catch (IOException e) {
        assertThat(e.getMessage(), containsString("local-ipv4"));
    }
}
Also used : NetworkService(org.elasticsearch.common.network.NetworkService) Ec2NameResolver(org.elasticsearch.cloud.aws.network.Ec2NameResolver) IOException(java.io.IOException) Settings(org.elasticsearch.common.settings.Settings)

Example 9 with NetworkService

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

the class Ec2NetworkTests method testNetworkHostEc2PublicIpv4.

/**
     * Test for network.host: _ec2:publicIpv4_
     */
public void testNetworkHostEc2PublicIpv4() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_ec2:publicIpv4_").build();
    NetworkService networkService = new NetworkService(nodeSettings, Collections.singletonList(new Ec2NameResolver(nodeSettings)));
    // TODO we need to replace that with a mock. For now we check the URL we are supposed to reach.
    try {
        networkService.resolveBindHostAddresses(null);
    } catch (IOException e) {
        assertThat(e.getMessage(), containsString("public-ipv4"));
    }
}
Also used : NetworkService(org.elasticsearch.common.network.NetworkService) Ec2NameResolver(org.elasticsearch.cloud.aws.network.Ec2NameResolver) IOException(java.io.IOException) Settings(org.elasticsearch.common.settings.Settings)

Example 10 with NetworkService

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

the class Ec2NetworkTests method testNetworkHostCoreLocal.

/**
     * Test that we don't have any regression with network host core settings such as
     * network.host: _local_
     */
public void testNetworkHostCoreLocal() throws IOException {
    Settings nodeSettings = Settings.builder().put("network.host", "_local_").build();
    NetworkService networkService = new NetworkService(nodeSettings, Collections.singletonList(new Ec2NameResolver(nodeSettings)));
    InetAddress[] addresses = networkService.resolveBindHostAddresses(null);
    assertThat(addresses, arrayContaining(networkService.resolveBindHostAddresses(new String[] { "_local_" })));
}
Also used : NetworkService(org.elasticsearch.common.network.NetworkService) Ec2NameResolver(org.elasticsearch.cloud.aws.network.Ec2NameResolver) InetAddress(java.net.InetAddress) Settings(org.elasticsearch.common.settings.Settings)

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