use of com.datastax.oss.driver.internal.core.session.SessionWrapper in project java-driver by datastax.
the class ChannelSocketOptionsIT method should_report_socket_options.
@Test
public void should_report_socket_options() {
Session session = SESSION_RULE.session();
DriverExecutionProfile config = session.getContext().getConfig().getDefaultProfile();
assertThat(config.getBoolean(SOCKET_TCP_NODELAY)).isTrue();
assertThat(config.getBoolean(SOCKET_KEEP_ALIVE)).isFalse();
assertThat(config.getBoolean(SOCKET_REUSE_ADDRESS)).isFalse();
assertThat(config.getInt(SOCKET_LINGER_INTERVAL)).isEqualTo(10);
assertThat(config.getInt(SOCKET_RECEIVE_BUFFER_SIZE)).isEqualTo(123456);
assertThat(config.getInt(SOCKET_SEND_BUFFER_SIZE)).isEqualTo(123456);
Node node = session.getMetadata().getNodes().values().iterator().next();
if (session instanceof SessionWrapper) {
session = ((SessionWrapper) session).getDelegate();
}
DriverChannel channel = ((DefaultSession) session).getChannel(node, "test");
assertThat(channel).isNotNull();
assertThat(channel.config()).isInstanceOf(SocketChannelConfig.class);
SocketChannelConfig socketConfig = (SocketChannelConfig) channel.config();
assertThat(socketConfig.isTcpNoDelay()).isTrue();
assertThat(socketConfig.isKeepAlive()).isFalse();
assertThat(socketConfig.isReuseAddress()).isFalse();
assertThat(socketConfig.getSoLinger()).isEqualTo(10);
RecvByteBufAllocator allocator = socketConfig.getRecvByteBufAllocator();
assertThat(allocator).isInstanceOf(FixedRecvByteBufAllocator.class);
assertThat(allocator.newHandle().guess()).isEqualTo(123456);
// cannot assert around SO_RCVBUF and SO_SNDBUF, such values are just hints
}
Aggregations