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());
}
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);
}
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()]);
}
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);
}
}
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()));
}
}
Aggregations