use of com.datastax.oss.driver.api.core.metadata.EndPoint in project java-driver by datastax.
the class ContactPointsTest method should_parse_host_and_port_and_resolve_all_a_records.
@Test
public void should_parse_host_and_port_and_resolve_all_a_records() throws UnknownHostException {
int localhostARecordsCount = InetAddress.getAllByName("localhost").length;
assumeTrue("This test assumes that localhost resolves to multiple A-records", localhostARecordsCount >= 2);
Set<EndPoint> endPoints = ContactPoints.merge(Collections.emptySet(), ImmutableList.of("localhost:9042"), true);
assertThat(endPoints).hasSize(localhostARecordsCount);
assertLog(Level.INFO, "Contact point localhost:9042 resolves to multiple addresses, will use them all");
}
use of com.datastax.oss.driver.api.core.metadata.EndPoint in project java-driver by datastax.
the class ContactPointsTest method should_parse_ipv6_address_and_port_in_configuration.
@Test
public void should_parse_ipv6_address_and_port_in_configuration() {
Set<EndPoint> endPoints = ContactPoints.merge(Collections.emptySet(), ImmutableList.of("0:0:0:0:0:0:0:1:9042", "::2:9042"), true);
assertThat(endPoints).containsExactly(new DefaultEndPoint(new InetSocketAddress("::1", 9042)), new DefaultEndPoint(new InetSocketAddress("::2", 9042)));
}
use of com.datastax.oss.driver.api.core.metadata.EndPoint in project java-driver by datastax.
the class ContactPointsTest method should_merge_programmatic_and_configuration.
@Test
public void should_merge_programmatic_and_configuration() {
Set<EndPoint> endPoints = ContactPoints.merge(ImmutableSet.of(new DefaultEndPoint(new InetSocketAddress("127.0.0.1", 9042))), ImmutableList.of("127.0.0.2:9042"), true);
assertThat(endPoints).containsOnly(new DefaultEndPoint(new InetSocketAddress("127.0.0.1", 9042)), new DefaultEndPoint(new InetSocketAddress("127.0.0.2", 9042)));
}
use of com.datastax.oss.driver.api.core.metadata.EndPoint in project java-driver by datastax.
the class DefaultLoadBalancingPolicyIT method firstNonDefaultContactPoint.
private EndPoint firstNonDefaultContactPoint(Iterable<Node> nodes) {
for (Node localNode : nodes) {
EndPoint endPoint = localNode.getEndPoint();
InetSocketAddress connectAddress = (InetSocketAddress) endPoint.resolve();
if (!connectAddress.getAddress().getHostAddress().equals("127.0.0.1")) {
return endPoint;
}
}
fail("should have other nodes than the default contact point");
// never reached
return null;
}
Aggregations