@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); }
static InternalChannelz.SocketOptions getSocketOptions(Channel channel) { ChannelConfig config = channel.config(); InternalChannelz.SocketOptions.Builder b = new InternalChannelz.SocketOptions.Builder(); Integer lingerSeconds = config.getOption(SO_LINGER); if (lingerSeconds != null) { b.setSocketOptionLingerSeconds(lingerSeconds); } Integer timeoutMillis = config.getOption(SO_TIMEOUT); if (timeoutMillis != null) { b.setSocketOptionTimeoutMillis(timeoutMillis); } for (Entry<ChannelOption<?>, Object> opt : config.getOptions().entrySet()) { ChannelOption<?> key = opt.getKey(); if (key.equals(SO_LINGER) || key.equals(SO_TIMEOUT)) { continue; } Object value = opt.getValue(); b.addOption(key.name(), String.valueOf(value)); } NativeSocketOptions nativeOptions = NettySocketSupport.getNativeSocketOptions(channel); if (nativeOptions != null) { b.setTcpInfo(nativeOptions.tcpInfo); for (Entry<String, String> entry : nativeOptions.otherInfo.entrySet()) { b.addOption(entry.getKey(), entry.getValue()); } } return b.build(); }
Utils { static InternalChannelz.SocketOptions getSocketOptions(Channel channel) { ChannelConfig config = channel.config(); InternalChannelz.SocketOptions.Builder b = new InternalChannelz.SocketOptions.Builder(); Integer lingerSeconds = config.getOption(SO_LINGER); if (lingerSeconds != null) { b.setSocketOptionLingerSeconds(lingerSeconds); } Integer timeoutMillis = config.getOption(SO_TIMEOUT); if (timeoutMillis != null) { b.setSocketOptionTimeoutMillis(timeoutMillis); } for (Entry<ChannelOption<?>, Object> opt : config.getOptions().entrySet()) { ChannelOption<?> key = opt.getKey(); if (key.equals(SO_LINGER) || key.equals(SO_TIMEOUT)) { continue; } Object value = opt.getValue(); b.addOption(key.name(), String.valueOf(value)); } NativeSocketOptions nativeOptions = NettySocketSupport.getNativeSocketOptions(channel); if (nativeOptions != null) { b.setTcpInfo(nativeOptions.tcpInfo); for (Entry<String, String> entry : nativeOptions.otherInfo.entrySet()) { b.addOption(entry.getKey(), entry.getValue()); } } return b.build(); } }
Utils { static InternalChannelz.SocketOptions getSocketOptions(Channel channel) { ChannelConfig config = channel.config(); InternalChannelz.SocketOptions.Builder b = new InternalChannelz.SocketOptions.Builder(); Integer lingerSeconds = config.getOption(SO_LINGER); if (lingerSeconds != null) { b.setSocketOptionLingerSeconds(lingerSeconds); } Integer timeoutMillis = config.getOption(SO_TIMEOUT); if (timeoutMillis != null) { b.setSocketOptionTimeoutMillis(timeoutMillis); } for (Entry<ChannelOption<?>, Object> opt : config.getOptions().entrySet()) { ChannelOption<?> key = opt.getKey(); if (key.equals(SO_LINGER) || key.equals(SO_TIMEOUT)) { continue; } Object value = opt.getValue(); b.addOption(key.name(), String.valueOf(value)); } NativeSocketOptions nativeOptions = NettySocketSupport.getNativeSocketOptions(channel); if (nativeOptions != null) { b.setTcpInfo(nativeOptions.tcpInfo); for (Entry<String, String> entry : nativeOptions.otherInfo.entrySet()) { b.addOption(entry.getKey(), entry.getValue()); } } return b.build(); } private  Utils(); }
Utils { static InternalChannelz.SocketOptions getSocketOptions(Channel channel) { ChannelConfig config = channel.config(); InternalChannelz.SocketOptions.Builder b = new InternalChannelz.SocketOptions.Builder(); Integer lingerSeconds = config.getOption(SO_LINGER); if (lingerSeconds != null) { b.setSocketOptionLingerSeconds(lingerSeconds); } Integer timeoutMillis = config.getOption(SO_TIMEOUT); if (timeoutMillis != null) { b.setSocketOptionTimeoutMillis(timeoutMillis); } for (Entry<ChannelOption<?>, Object> opt : config.getOptions().entrySet()) { ChannelOption<?> key = opt.getKey(); if (key.equals(SO_LINGER) || key.equals(SO_TIMEOUT)) { continue; } Object value = opt.getValue(); b.addOption(key.name(), String.valueOf(value)); } NativeSocketOptions nativeOptions = NettySocketSupport.getNativeSocketOptions(channel); if (nativeOptions != null) { b.setTcpInfo(nativeOptions.tcpInfo); for (Entry<String, String> entry : nativeOptions.otherInfo.entrySet()) { b.addOption(entry.getKey(), entry.getValue()); } } return b.build(); } private  Utils(); static Metadata convertHeaders(Http2Headers http2Headers); static Http2Headers convertClientHeaders(Metadata headers,
      AsciiString scheme,
      AsciiString defaultPath,
      AsciiString authority,
      AsciiString method,
      AsciiString userAgent); static Http2Headers convertServerHeaders(Metadata headers); static Metadata convertTrailers(Http2Headers http2Headers); static Http2Headers convertTrailers(Metadata trailers, boolean headersSent); static Status statusFromThrowable(Throwable t); }
Utils { static InternalChannelz.SocketOptions getSocketOptions(Channel channel) { ChannelConfig config = channel.config(); InternalChannelz.SocketOptions.Builder b = new InternalChannelz.SocketOptions.Builder(); Integer lingerSeconds = config.getOption(SO_LINGER); if (lingerSeconds != null) { b.setSocketOptionLingerSeconds(lingerSeconds); } Integer timeoutMillis = config.getOption(SO_TIMEOUT); if (timeoutMillis != null) { b.setSocketOptionTimeoutMillis(timeoutMillis); } for (Entry<ChannelOption<?>, Object> opt : config.getOptions().entrySet()) { ChannelOption<?> key = opt.getKey(); if (key.equals(SO_LINGER) || key.equals(SO_TIMEOUT)) { continue; } Object value = opt.getValue(); b.addOption(key.name(), String.valueOf(value)); } NativeSocketOptions nativeOptions = NettySocketSupport.getNativeSocketOptions(channel); if (nativeOptions != null) { b.setTcpInfo(nativeOptions.tcpInfo); for (Entry<String, String> entry : nativeOptions.otherInfo.entrySet()) { b.addOption(entry.getKey(), entry.getValue()); } } return b.build(); } private  Utils(); static Metadata convertHeaders(Http2Headers http2Headers); static Http2Headers convertClientHeaders(Metadata headers,
      AsciiString scheme,
      AsciiString defaultPath,
      AsciiString authority,
      AsciiString method,
      AsciiString userAgent); static Http2Headers convertServerHeaders(Metadata headers); static Metadata convertTrailers(Http2Headers http2Headers); static Http2Headers convertTrailers(Metadata trailers, boolean headersSent); static Status statusFromThrowable(Throwable t); static final AsciiString STATUS_OK; static final AsciiString HTTP_METHOD; static final AsciiString HTTP_GET_METHOD; static final AsciiString HTTPS; static final AsciiString HTTP; static final AsciiString CONTENT_TYPE_HEADER; static final AsciiString CONTENT_TYPE_GRPC; static final AsciiString TE_HEADER; static final AsciiString TE_TRAILERS; static final AsciiString USER_AGENT; static final Resource<EventLoopGroup> DEFAULT_BOSS_EVENT_LOOP_GROUP; static final Resource<EventLoopGroup> DEFAULT_WORKER_EVENT_LOOP_GROUP; }