use of io.grpc.InternalChannelz.SocketOptions in project grpc-java by grpc.
the class UtilsTest method channelOptionsTest_noLinger.
@Test
public void channelOptionsTest_noLinger() {
Channel channel = new EmbeddedChannel();
assertNull(channel.config().getOption(ChannelOption.SO_LINGER));
InternalChannelz.SocketOptions socketOptions = Utils.getSocketOptions(channel);
assertNull(socketOptions.lingerSeconds);
}
use of io.grpc.InternalChannelz.SocketOptions in project grpc-java by grpc.
the class UtilsTest method channelOptionsTest_oio.
@Test
@SuppressWarnings("deprecation")
public void channelOptionsTest_oio() {
Channel channel = new io.netty.channel.socket.oio.OioSocketChannel();
SocketOptions socketOptions = setAndValidateGeneric(channel);
assertEquals(250, (int) socketOptions.soTimeoutMillis);
}
use of io.grpc.InternalChannelz.SocketOptions in project grpc-java by grpc.
the class UtilsTest method channelOptionsTest_nio.
@Test
public void channelOptionsTest_nio() {
Channel channel = new NioSocketChannel();
SocketOptions socketOptions = setAndValidateGeneric(channel);
assertNull(socketOptions.soTimeoutMillis);
}
use of io.grpc.InternalChannelz.SocketOptions in project grpc-java by grpc.
the class ChannelzProtoUtilTest method toSocket_withDataWithOptions.
@Test
public void toSocket_withDataWithOptions() throws Exception {
socket.socketOptions = new SocketOptions(null, null, null, ImmutableMap.of("test_name", "test_value"));
assertEquals(Socket.newBuilder().setRef(socketRef).setLocal(localAddress).setRemote(remoteAddress).setData(SocketData.newBuilder(socketDataWithDataNoSockOpts).addOption(SocketOption.newBuilder().setName("test_name").setValue("test_value"))).build(), ChannelzProtoUtil.toSocket(socket));
}
use of io.grpc.InternalChannelz.SocketOptions in project grpc-java by grpc.
the class UtilsTest method getSocketOptions.
@Test
public void getSocketOptions() throws Exception {
Socket socket = new Socket();
socket.setSoLinger(true, 2);
socket.setSoTimeout(3);
socket.setTcpNoDelay(true);
socket.setReuseAddress(true);
socket.setReceiveBufferSize(4000);
socket.setSendBufferSize(5000);
socket.setKeepAlive(true);
socket.setOOBInline(true);
// note: see javadoc for valid input values
socket.setTrafficClass(8);
SocketOptions socketOptions = Utils.getSocketOptions(socket);
assertEquals(2, (int) socketOptions.lingerSeconds);
assertEquals(3, (int) socketOptions.soTimeoutMillis);
assertEquals("true", socketOptions.others.get("TCP_NODELAY"));
assertEquals("true", socketOptions.others.get("SO_REUSEADDR"));
assertEquals("4000", socketOptions.others.get("SO_RECVBUF"));
assertEquals("5000", socketOptions.others.get("SO_SNDBUF"));
assertEquals("true", socketOptions.others.get("SO_KEEPALIVE"));
assertEquals("true", socketOptions.others.get("SO_OOBINLINE"));
assertEquals("8", socketOptions.others.get("IP_TOS"));
}
Aggregations