Package org.apache.zookeeper.common
Class NettyUtils
- java.lang.Object
- 
- org.apache.zookeeper.common.NettyUtils
 
- 
 public class NettyUtils extends Object Helper methods for netty code.
- 
- 
Constructor SummaryConstructors Constructor Description NettyUtils()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static intgetClientReachableLocalInetAddressCount()Attempts to detect and return the number of local network addresses that could be used by a client to reach this server.static io.netty.channel.EventLoopGroupnewNioOrEpollEventLoopGroup()IfEpoll.isAvailable()== true, returns a newEpollEventLoopGroup, otherwise returns a newNioEventLoopGroup.static io.netty.channel.EventLoopGroupnewNioOrEpollEventLoopGroup(int nThreads)IfEpoll.isAvailable()== true, returns a newEpollEventLoopGroup, otherwise returns a newNioEventLoopGroup.static Class<? extends io.netty.channel.socket.ServerSocketChannel>nioOrEpollServerSocketChannel()IfEpoll.isAvailable()== true, returnsEpollServerSocketChannel, otherwise returnsNioServerSocketChannel.static Class<? extends io.netty.channel.socket.SocketChannel>nioOrEpollSocketChannel()IfEpoll.isAvailable()== true, returnsEpollSocketChannel, otherwise returnsNioSocketChannel.
 
- 
- 
- 
Method Detail- 
newNioOrEpollEventLoopGrouppublic static io.netty.channel.EventLoopGroup newNioOrEpollEventLoopGroup() IfEpoll.isAvailable()== true, returns a newEpollEventLoopGroup, otherwise returns a newNioEventLoopGroup. Creates the event loop group using the default number of threads.- Returns:
- a new EventLoopGroup.
 
 - 
newNioOrEpollEventLoopGrouppublic static io.netty.channel.EventLoopGroup newNioOrEpollEventLoopGroup(int nThreads) IfEpoll.isAvailable()== true, returns a newEpollEventLoopGroup, otherwise returns a newNioEventLoopGroup. Creates the event loop group using the specified number of threads instead of the default.- Parameters:
- nThreads- see- NioEventLoopGroup(int).
- Returns:
- a new EventLoopGroup.
 
 - 
nioOrEpollSocketChannelpublic static Class<? extends io.netty.channel.socket.SocketChannel> nioOrEpollSocketChannel() IfEpoll.isAvailable()== true, returnsEpollSocketChannel, otherwise returnsNioSocketChannel.- Returns:
- a socket channel class.
 
 - 
nioOrEpollServerSocketChannelpublic static Class<? extends io.netty.channel.socket.ServerSocketChannel> nioOrEpollServerSocketChannel() IfEpoll.isAvailable()== true, returnsEpollServerSocketChannel, otherwise returnsNioServerSocketChannel.- Returns:
- a server socket channel class.
 
 - 
getClientReachableLocalInetAddressCountpublic static int getClientReachableLocalInetAddressCount() Attempts to detect and return the number of local network addresses that could be used by a client to reach this server. This means we exclude the following address types:- Multicast addresses. Zookeeper server sockets use TCP, thus cannot bind to a multicast address.
- Link-local addresses. Routers don't forward traffic sent to a link-local address, so any realistic server deployment would not have clients using these.
- Loopback addresses. These are typically only used for testing.
 - Returns:
- the number of client-reachable local network addresses found, or 1 if listing the network interfaces fails.
 
 
- 
 
-