Search in sources :

Example 56 with TransportAddress

use of org.opensearch.common.transport.TransportAddress in project OpenSearch by opensearch-project.

the class TransportInfoTests method testCorrectDisplayPublishedIpv6.

public void testCorrectDisplayPublishedIpv6() throws Exception {
    InetAddress address = InetAddress.getByName(NetworkAddress.format(InetAddress.getByName("0:0:0:0:0:0:0:1")));
    int port = 9200;
    assertPublishAddress(createTransportInfo(address, port, true), new TransportAddress(address, port).toString());
}
Also used : TransportAddress(org.opensearch.common.transport.TransportAddress) BoundTransportAddress(org.opensearch.common.transport.BoundTransportAddress) InetAddress(java.net.InetAddress)

Example 57 with TransportAddress

use of org.opensearch.common.transport.TransportAddress in project OpenSearch by opensearch-project.

the class OpenSearchIntegTestCase method buildExternalCluster.

private ExternalTestCluster buildExternalCluster(String clusterAddresses, String clusterName) throws IOException {
    String[] stringAddresses = clusterAddresses.split(",");
    TransportAddress[] transportAddresses = new TransportAddress[stringAddresses.length];
    int i = 0;
    for (String stringAddress : stringAddresses) {
        URL url = new URL("http://" + stringAddress);
        InetAddress inetAddress = InetAddress.getByName(url.getHost());
        transportAddresses[i++] = new TransportAddress(new InetSocketAddress(inetAddress, url.getPort()));
    }
    return new ExternalTestCluster(createTempDir(), externalClusterClientSettings(), getClientWrapper(), clusterName, nodePlugins(), transportAddresses);
}
Also used : TransportAddress(org.opensearch.common.transport.TransportAddress) InetSocketAddress(java.net.InetSocketAddress) InetAddress(java.net.InetAddress) URL(java.net.URL)

Example 58 with TransportAddress

use of org.opensearch.common.transport.TransportAddress in project OpenSearch by opensearch-project.

the class MockTransportService method extractTransportAddresses.

private static TransportAddress[] extractTransportAddresses(TransportService transportService) {
    HashSet<TransportAddress> transportAddresses = new HashSet<>();
    BoundTransportAddress boundTransportAddress = transportService.boundAddress();
    transportAddresses.addAll(Arrays.asList(boundTransportAddress.boundAddresses()));
    transportAddresses.add(boundTransportAddress.publishAddress());
    return transportAddresses.toArray(new TransportAddress[transportAddresses.size()]);
}
Also used : BoundTransportAddress(org.opensearch.common.transport.BoundTransportAddress) TransportAddress(org.opensearch.common.transport.TransportAddress) BoundTransportAddress(org.opensearch.common.transport.BoundTransportAddress) HashSet(java.util.HashSet)

Example 59 with TransportAddress

use of org.opensearch.common.transport.TransportAddress in project OpenSearch by opensearch-project.

the class StubbableTransport method openConnection.

@Override
public void openConnection(DiscoveryNode node, ConnectionProfile profile, ActionListener<Connection> listener) {
    TransportAddress address = node.getAddress();
    OpenConnectionBehavior behavior = connectBehaviors.getOrDefault(address, defaultConnectBehavior);
    ActionListener<Connection> wrappedListener = ActionListener.delegateFailure(listener, (delegatedListener, connection) -> delegatedListener.onResponse(new WrappedConnection(connection)));
    if (behavior == null) {
        delegate.openConnection(node, profile, wrappedListener);
    } else {
        behavior.openConnection(delegate, node, profile, wrappedListener);
    }
}
Also used : BoundTransportAddress(org.opensearch.common.transport.BoundTransportAddress) TransportAddress(org.opensearch.common.transport.TransportAddress)

Example 60 with TransportAddress

use of org.opensearch.common.transport.TransportAddress in project OpenSearch by opensearch-project.

the class AbstractSimpleTransportTestCase method testHandshakeWithIncompatVersion.

public void testHandshakeWithIncompatVersion() {
    assumeTrue("only tcp transport has a handshake method", serviceA.getOriginalTransport() instanceof TcpTransport);
    Version version = LegacyESVersion.fromString("6.0.0");
    try (MockTransportService service = buildService("TS_C", version, Settings.EMPTY)) {
        service.start();
        service.acceptIncomingRequests();
        TransportAddress address = service.boundAddress().publishAddress();
        DiscoveryNode node = new DiscoveryNode("TS_TPC", "TS_TPC", address, emptyMap(), emptySet(), version0);
        ConnectionProfile.Builder builder = new ConnectionProfile.Builder();
        builder.addConnections(1, TransportRequestOptions.Type.BULK, TransportRequestOptions.Type.PING, TransportRequestOptions.Type.RECOVERY, TransportRequestOptions.Type.REG, TransportRequestOptions.Type.STATE);
        expectThrows(ConnectTransportException.class, () -> serviceA.openConnection(node, builder.build()));
    }
}
Also used : DiscoveryNode(org.opensearch.cluster.node.DiscoveryNode) MockTransportService(org.opensearch.test.transport.MockTransportService) Version(org.opensearch.Version) LegacyESVersion(org.opensearch.LegacyESVersion) BoundTransportAddress(org.opensearch.common.transport.BoundTransportAddress) TransportAddress(org.opensearch.common.transport.TransportAddress)

Aggregations

TransportAddress (org.opensearch.common.transport.TransportAddress)129 Settings (org.opensearch.common.settings.Settings)51 DiscoveryNode (org.opensearch.cluster.node.DiscoveryNode)43 BoundTransportAddress (org.opensearch.common.transport.BoundTransportAddress)31 Version (org.opensearch.Version)26 ArrayList (java.util.ArrayList)24 IOException (java.io.IOException)22 List (java.util.List)21 InetAddress (java.net.InetAddress)20 HashSet (java.util.HashSet)20 CountDownLatch (java.util.concurrent.CountDownLatch)20 ClusterSettings (org.opensearch.common.settings.ClusterSettings)20 ThreadPool (org.opensearch.threadpool.ThreadPool)17 Matchers.containsString (org.hamcrest.Matchers.containsString)16 HttpServerTransport (org.opensearch.http.HttpServerTransport)16 Set (java.util.Set)15 TimeUnit (java.util.concurrent.TimeUnit)15 AtomicReference (java.util.concurrent.atomic.AtomicReference)15 OpenSearchTestCase (org.opensearch.test.OpenSearchTestCase)15 MockTransportService (org.opensearch.test.transport.MockTransportService)15