use of org.elasticsearch.common.transport.TransportAddress in project elasticsearch by elastic.
the class Ec2DiscoveryTests method testPrivateDns.
public void testPrivateDns() throws InterruptedException {
int nodes = randomInt(10);
for (int i = 0; i < nodes; i++) {
String instanceId = "node" + (i + 1);
poorMansDNS.put(AmazonEC2Mock.PREFIX_PRIVATE_DNS + instanceId + AmazonEC2Mock.SUFFIX_PRIVATE_DNS, buildNewFakeTransportAddress());
}
Settings nodeSettings = Settings.builder().put(DISCOVERY_EC2.HOST_TYPE_SETTING.getKey(), "private_dns").build();
List<DiscoveryNode> discoveryNodes = buildDynamicNodes(nodeSettings, nodes);
assertThat(discoveryNodes, hasSize(nodes));
// We check that we are using here expected address
int node = 1;
for (DiscoveryNode discoveryNode : discoveryNodes) {
String instanceId = "node" + node++;
TransportAddress address = discoveryNode.getAddress();
TransportAddress expected = poorMansDNS.get(AmazonEC2Mock.PREFIX_PRIVATE_DNS + instanceId + AmazonEC2Mock.SUFFIX_PRIVATE_DNS);
assertEquals(address, expected);
}
}
use of org.elasticsearch.common.transport.TransportAddress 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);
}
use of org.elasticsearch.common.transport.TransportAddress in project elasticsearch by elastic.
the class Ec2DiscoveryTests method testPrivateIp.
public void testPrivateIp() throws InterruptedException {
int nodes = randomInt(10);
for (int i = 0; i < nodes; i++) {
poorMansDNS.put(AmazonEC2Mock.PREFIX_PRIVATE_IP + (i + 1), buildNewFakeTransportAddress());
}
Settings nodeSettings = Settings.builder().put(DISCOVERY_EC2.HOST_TYPE_SETTING.getKey(), "private_ip").build();
List<DiscoveryNode> discoveryNodes = buildDynamicNodes(nodeSettings, nodes);
assertThat(discoveryNodes, hasSize(nodes));
// We check that we are using here expected address
int node = 1;
for (DiscoveryNode discoveryNode : discoveryNodes) {
TransportAddress address = discoveryNode.getAddress();
TransportAddress expected = poorMansDNS.get(AmazonEC2Mock.PREFIX_PRIVATE_IP + node++);
assertEquals(address, expected);
}
}
use of org.elasticsearch.common.transport.TransportAddress 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);
}
use of org.elasticsearch.common.transport.TransportAddress in project elasticsearch by elastic.
the class Ec2DiscoveryTests method testReadHostFromTag.
public void testReadHostFromTag() throws InterruptedException, UnknownHostException {
int nodes = randomIntBetween(5, 10);
String[] addresses = new String[nodes];
for (int node = 0; node < nodes; node++) {
addresses[node] = "192.168.0." + (node + 1);
poorMansDNS.put("node" + (node + 1), new TransportAddress(InetAddress.getByName(addresses[node]), 9300));
}
Settings nodeSettings = Settings.builder().put(DISCOVERY_EC2.HOST_TYPE_SETTING.getKey(), "tag:foo").build();
List<List<Tag>> tagsList = new ArrayList<>();
for (int node = 0; node < nodes; node++) {
List<Tag> tags = new ArrayList<>();
tags.add(new Tag("foo", "node" + (node + 1)));
tagsList.add(tags);
}
logger.info("started [{}] instances", nodes);
List<DiscoveryNode> discoveryNodes = buildDynamicNodes(nodeSettings, nodes, tagsList);
assertThat(discoveryNodes, hasSize(nodes));
for (DiscoveryNode discoveryNode : discoveryNodes) {
TransportAddress address = discoveryNode.getAddress();
TransportAddress expected = poorMansDNS.get(discoveryNode.getName());
assertEquals(address, expected);
}
}
Aggregations