@Test public void toAddress_inet() throws Exception { InetSocketAddress inet4 = new InetSocketAddress(Inet4Address.getByName("10.0.0.1"), 1000); assertEquals( Address.newBuilder().setTcpipAddress( TcpIpAddress .newBuilder() .setIpAddress(ByteString.copyFrom(inet4.getAddress().getAddress())) .setPort(1000)) .build(), ChannelzProtoUtil.toAddress(inet4)); }
static Address toAddress(SocketAddress address) { Preconditions.checkNotNull(address); Address.Builder builder = Address.newBuilder(); if (address instanceof InetSocketAddress) { InetSocketAddress inetAddress = (InetSocketAddress) address; builder.setTcpipAddress( TcpIpAddress .newBuilder() .setIpAddress( ByteString.copyFrom(inetAddress.getAddress().getAddress())) .setPort(inetAddress.getPort()) .build()); } else if (address.getClass().getName().endsWith("io.netty.channel.unix.DomainSocketAddress")) { builder.setUdsAddress( UdsAddress .newBuilder() .setFilename(address.toString()) .build()); } else { builder.setOtherAddress(OtherAddress.newBuilder().setName(address.toString()).build()); } return builder.build(); }
ChannelzProtoUtil { static Address toAddress(SocketAddress address) { Preconditions.checkNotNull(address); Address.Builder builder = Address.newBuilder(); if (address instanceof InetSocketAddress) { InetSocketAddress inetAddress = (InetSocketAddress) address; builder.setTcpipAddress( TcpIpAddress .newBuilder() .setIpAddress( ByteString.copyFrom(inetAddress.getAddress().getAddress())) .setPort(inetAddress.getPort()) .build()); } else if (address.getClass().getName().endsWith("io.netty.channel.unix.DomainSocketAddress")) { builder.setUdsAddress( UdsAddress .newBuilder() .setFilename(address.toString()) .build()); } else { builder.setOtherAddress(OtherAddress.newBuilder().setName(address.toString()).build()); } return builder.build(); } }
ChannelzProtoUtil { static Address toAddress(SocketAddress address) { Preconditions.checkNotNull(address); Address.Builder builder = Address.newBuilder(); if (address instanceof InetSocketAddress) { InetSocketAddress inetAddress = (InetSocketAddress) address; builder.setTcpipAddress( TcpIpAddress .newBuilder() .setIpAddress( ByteString.copyFrom(inetAddress.getAddress().getAddress())) .setPort(inetAddress.getPort()) .build()); } else if (address.getClass().getName().endsWith("io.netty.channel.unix.DomainSocketAddress")) { builder.setUdsAddress( UdsAddress .newBuilder() .setFilename(address.toString()) .build()); } else { builder.setOtherAddress(OtherAddress.newBuilder().setName(address.toString()).build()); } return builder.build(); } private  ChannelzProtoUtil(); }
ChannelzProtoUtil { static Address toAddress(SocketAddress address) { Preconditions.checkNotNull(address); Address.Builder builder = Address.newBuilder(); if (address instanceof InetSocketAddress) { InetSocketAddress inetAddress = (InetSocketAddress) address; builder.setTcpipAddress( TcpIpAddress .newBuilder() .setIpAddress( ByteString.copyFrom(inetAddress.getAddress().getAddress())) .setPort(inetAddress.getPort()) .build()); } else if (address.getClass().getName().endsWith("io.netty.channel.unix.DomainSocketAddress")) { builder.setUdsAddress( UdsAddress .newBuilder() .setFilename(address.toString()) .build()); } else { builder.setOtherAddress(OtherAddress.newBuilder().setName(address.toString()).build()); } return builder.build(); } private  ChannelzProtoUtil();  }
ChannelzProtoUtil { static Address toAddress(SocketAddress address) { Preconditions.checkNotNull(address); Address.Builder builder = Address.newBuilder(); if (address instanceof InetSocketAddress) { InetSocketAddress inetAddress = (InetSocketAddress) address; builder.setTcpipAddress( TcpIpAddress .newBuilder() .setIpAddress( ByteString.copyFrom(inetAddress.getAddress().getAddress())) .setPort(inetAddress.getPort()) .build()); } else if (address.getClass().getName().endsWith("io.netty.channel.unix.DomainSocketAddress")) { builder.setUdsAddress( UdsAddress .newBuilder() .setFilename(address.toString()) .build()); } else { builder.setOtherAddress(OtherAddress.newBuilder().setName(address.toString()).build()); } return builder.build(); } private  ChannelzProtoUtil();  static final String SO_LINGER; static final String SO_TIMEOUT; static final String TCP_INFO; }