use of com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint in project java-driver by datastax.
the class DefaultSessionPoolsTest method mockLocalNode.
private static DefaultNode mockLocalNode(int i) {
DefaultNode node = mock(DefaultNode.class);
when(node.getHostId()).thenReturn(UUID.randomUUID());
DefaultEndPoint endPoint = TestNodeFactory.newEndPoint(i);
when(node.getEndPoint()).thenReturn(endPoint);
when(node.getBroadcastRpcAddress()).thenReturn(Optional.of(endPoint.resolve()));
when(node.getDistance()).thenReturn(NodeDistance.LOCAL);
when(node.toString()).thenReturn("node" + i);
return node;
}
use of com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint in project java-driver by datastax.
the class ContactPoints method merge.
public static Set<EndPoint> merge(Set<EndPoint> programmaticContactPoints, List<String> configContactPoints, boolean resolve) {
Set<EndPoint> result = Sets.newHashSet(programmaticContactPoints);
for (String spec : configContactPoints) {
for (InetSocketAddress address : extract(spec, resolve)) {
DefaultEndPoint endPoint = new DefaultEndPoint(address);
boolean wasNew = result.add(endPoint);
if (!wasNew) {
LOG.warn("Duplicate contact point {}", address);
}
}
}
return ImmutableSet.copyOf(result);
}
use of com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint 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.internal.core.metadata.DefaultEndPoint 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)));
}
Aggregations