MCPcopy Create free account
hub / github.com/grpc/grpc-java / getSocketOptions

Method getSocketOptions

netty/src/main/java/io/grpc/netty/Utils.java:557–594  ·  view source on GitHub ↗
(Channel channel)

Source from the content-addressed store, hash-verified

555 }
556
557 static InternalChannelz.SocketOptions getSocketOptions(Channel channel) {
558 ChannelConfig config = channel.config();
559 InternalChannelz.SocketOptions.Builder b = new InternalChannelz.SocketOptions.Builder();
560
561 // The API allows returning null but not sure if it can happen in practice.
562 // Let's be paranoid and do null checking just in case.
563 Integer lingerSeconds = config.getOption(SO_LINGER);
564 if (lingerSeconds != null) {
565 b.setSocketOptionLingerSeconds(lingerSeconds);
566 }
567
568 Integer timeoutMillis = config.getOption(SO_TIMEOUT);
569 if (timeoutMillis != null) {
570 // in java, SO_TIMEOUT only applies to receiving
571 b.setSocketOptionTimeoutMillis(timeoutMillis);
572 }
573
574 for (Map.Entry<ChannelOption<?>, Object> opt : config.getOptions().entrySet()) {
575 ChannelOption<?> key = opt.getKey();
576 // Constants are pooled, so there should only be one instance of each constant
577 if (key.equals(SO_LINGER) || key.equals(SO_TIMEOUT)) {
578 continue;
579 }
580 Object value = opt.getValue();
581 // zpencer: Can a netty option be null?
582 b.addOption(key.name(), String.valueOf(value));
583 }
584
585 NativeSocketOptions nativeOptions
586 = NettySocketSupport.getNativeSocketOptions(channel);
587 if (nativeOptions != null) {
588 b.setTcpInfo(nativeOptions.tcpInfo); // may be null
589 for (Map.Entry<String, String> entry : nativeOptions.otherInfo.entrySet()) {
590 b.addOption(entry.getKey(), entry.getValue());
591 }
592 }
593 return b.build();
594 }
595
596 private enum EventLoopGroupType {
597 NIO,

Callers 6

setAndValidateGenericMethod · 0.95
getStatsHelperMethod · 0.95
getStatsMethod · 0.95
runMethod · 0.95
getStatsHelperMethod · 0.95

Calls 12

addOptionMethod · 0.95
setTcpInfoMethod · 0.95
buildMethod · 0.95
configMethod · 0.45
getOptionMethod · 0.45
getKeyMethod · 0.45
equalsMethod · 0.45
getValueMethod · 0.45
nameMethod · 0.45

Tested by 2

setAndValidateGenericMethod · 0.76