Search in sources :

Example 1 with DefaultEndPoint

use of com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint in project java-driver by datastax.

the class ControlConnectionTestBase method newMockDriverChannel.

protected DriverChannel newMockDriverChannel(int id) {
    DriverChannel driverChannel = mock(DriverChannel.class);
    Channel channel = mock(Channel.class);
    EventLoop adminExecutor = adminEventLoopGroup.next();
    DefaultChannelPromise closeFuture = new DefaultChannelPromise(channel, adminExecutor);
    when(driverChannel.close()).thenAnswer(i -> {
        closeFuture.trySuccess(null);
        return closeFuture;
    });
    when(driverChannel.forceClose()).thenAnswer(i -> {
        closeFuture.trySuccess(null);
        return closeFuture;
    });
    when(driverChannel.closeFuture()).thenReturn(closeFuture);
    when(driverChannel.toString()).thenReturn("channel" + id);
    when(driverChannel.getEndPoint()).thenReturn(new DefaultEndPoint(new InetSocketAddress("127.0.0." + id, 9042)));
    return driverChannel;
}
Also used : DriverChannel(com.datastax.oss.driver.internal.core.channel.DriverChannel) EventLoop(io.netty.channel.EventLoop) DefaultChannelPromise(io.netty.channel.DefaultChannelPromise) InetSocketAddress(java.net.InetSocketAddress) Channel(io.netty.channel.Channel) DriverChannel(com.datastax.oss.driver.internal.core.channel.DriverChannel) DefaultEndPoint(com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint)

Example 2 with DefaultEndPoint

use of com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint in project java-driver by datastax.

the class ContactPointsTest method should_warn_if_duplicate_between_programmatic_and_configuration.

@Test
public void should_warn_if_duplicate_between_programmatic_and_configuration() {
    Set<EndPoint> endPoints = ContactPoints.merge(ImmutableSet.of(new DefaultEndPoint(new InetSocketAddress("127.0.0.1", 9042))), ImmutableList.of("127.0.0.1:9042"), true);
    assertThat(endPoints).containsOnly(new DefaultEndPoint(new InetSocketAddress("127.0.0.1", 9042)));
    assertLog(Level.WARN, "Duplicate contact point /127.0.0.1:9042");
}
Also used : InetSocketAddress(java.net.InetSocketAddress) DefaultEndPoint(com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint) DefaultEndPoint(com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint) EndPoint(com.datastax.oss.driver.api.core.metadata.EndPoint) Test(org.junit.Test)

Example 3 with DefaultEndPoint

use of com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint in project java-driver by datastax.

the class ContactPointsTest method should_parse_host_and_port_in_configuration_and_create_unresolved.

@Test
public void should_parse_host_and_port_in_configuration_and_create_unresolved() {
    Set<EndPoint> endPoints = ContactPoints.merge(Collections.emptySet(), ImmutableList.of("localhost:9042"), false);
    assertThat(endPoints).containsExactly(new DefaultEndPoint(InetSocketAddress.createUnresolved("localhost", 9042)));
}
Also used : DefaultEndPoint(com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint) DefaultEndPoint(com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint) EndPoint(com.datastax.oss.driver.api.core.metadata.EndPoint) Test(org.junit.Test)

Example 4 with DefaultEndPoint

use of com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint in project java-driver by datastax.

the class ContactPointsTest method should_warn_if_duplicate_in_configuration.

@Test
public void should_warn_if_duplicate_in_configuration() {
    Set<EndPoint> endPoints = ContactPoints.merge(Collections.emptySet(), ImmutableList.of("127.0.0.1:9042", "127.0.0.1:9042"), true);
    assertThat(endPoints).containsOnly(new DefaultEndPoint(new InetSocketAddress("127.0.0.1", 9042)));
    assertLog(Level.WARN, "Duplicate contact point /127.0.0.1:9042");
}
Also used : InetSocketAddress(java.net.InetSocketAddress) DefaultEndPoint(com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint) DefaultEndPoint(com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint) EndPoint(com.datastax.oss.driver.api.core.metadata.EndPoint) Test(org.junit.Test)

Example 5 with DefaultEndPoint

use of com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint in project java-driver by datastax.

the class ContactPointsTest method should_parse_ipv4_address_and_port_in_configuration.

@Test
public void should_parse_ipv4_address_and_port_in_configuration() {
    Set<EndPoint> endPoints = ContactPoints.merge(Collections.emptySet(), ImmutableList.of("127.0.0.1:9042"), true);
    assertThat(endPoints).containsExactly(new DefaultEndPoint(new InetSocketAddress("127.0.0.1", 9042)));
}
Also used : InetSocketAddress(java.net.InetSocketAddress) DefaultEndPoint(com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint) DefaultEndPoint(com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint) EndPoint(com.datastax.oss.driver.api.core.metadata.EndPoint) Test(org.junit.Test)

Aggregations

DefaultEndPoint (com.datastax.oss.driver.internal.core.metadata.DefaultEndPoint)9 EndPoint (com.datastax.oss.driver.api.core.metadata.EndPoint)7 InetSocketAddress (java.net.InetSocketAddress)7 Test (org.junit.Test)6 DriverChannel (com.datastax.oss.driver.internal.core.channel.DriverChannel)1 DefaultNode (com.datastax.oss.driver.internal.core.metadata.DefaultNode)1 Channel (io.netty.channel.Channel)1 DefaultChannelPromise (io.netty.channel.DefaultChannelPromise)1 EventLoop (io.netty.channel.EventLoop)1