Search in sources :

Example 6 with SocketOptions

use of io.grpc.InternalChannelz.SocketOptions in project grpc-java by grpc.

the class UtilsTest method setAndValidateGeneric.

private static InternalChannelz.SocketOptions setAndValidateGeneric(Channel channel) {
    channel.config().setOption(ChannelOption.SO_LINGER, 3);
    // only applicable for OIO channels:
    channel.config().setOption(ChannelOption.SO_TIMEOUT, 250);
    // Test some arbitrarily chosen options with a non numeric values
    channel.config().setOption(ChannelOption.SO_KEEPALIVE, true);
    WriteBufferWaterMark writeBufWaterMark = new WriteBufferWaterMark(10, 20);
    channel.config().setOption(ChannelOption.WRITE_BUFFER_WATER_MARK, writeBufWaterMark);
    InternalChannelz.SocketOptions socketOptions = Utils.getSocketOptions(channel);
    assertEquals(3, (int) socketOptions.lingerSeconds);
    assertEquals("true", socketOptions.others.get("SO_KEEPALIVE"));
    assertEquals(writeBufWaterMark.toString(), socketOptions.others.get(ChannelOption.WRITE_BUFFER_WATER_MARK.toString()));
    return socketOptions;
}
Also used : SocketOptions(io.grpc.InternalChannelz.SocketOptions) InternalChannelz(io.grpc.InternalChannelz) WriteBufferWaterMark(io.netty.channel.WriteBufferWaterMark)

Aggregations

SocketOptions (io.grpc.InternalChannelz.SocketOptions)6 Test (org.junit.Test)5 Channel (io.netty.channel.Channel)3 ServerChannel (io.netty.channel.ServerChannel)3 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)3 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)3 InternalChannelz (io.grpc.InternalChannelz)2 WriteBufferWaterMark (io.netty.channel.WriteBufferWaterMark)1 Socket (java.net.Socket)1