Class BuilderUtils
- java.lang.Object
-
- io.servicetalk.transport.netty.internal.BuilderUtils
-
public final class BuilderUtils extends java.lang.ObjectUtilities which are used for builders.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcloseAndRethrowUnchecked(java.io.Closeable closable)CallCloseable.close()and re-throw an unchecked exception if a checked exception is thrown.static java.lang.Class<? extends io.netty.channel.socket.DatagramChannel>datagramChannel(io.netty.channel.EventLoopGroup group)Returns the correctClassto use with the givenEventLoopGroup.static java.lang.StringformatCanonicalAddress(java.net.SocketAddress address)Format an address into a canonical numeric format.static java.lang.Class<? extends io.netty.channel.ServerChannel>serverChannel(io.netty.channel.EventLoopGroup group, java.lang.Class<? extends java.net.SocketAddress> addressClass)Returns the correctClassto use with the givenEventLoopGroup.static io.netty.channel.ChannelsocketChannel(io.netty.channel.EventLoopGroup group, FileDescriptorSocketAddress address)Returns the correct Channel that wraps the given filedescriptor ornullif not supported.static java.lang.Class<? extends io.netty.channel.Channel>socketChannel(io.netty.channel.EventLoopGroup group, java.lang.Class<? extends java.net.SocketAddress> addressClass)Returns the correctClassto use with the givenEventLoopGroup.static java.net.SocketAddresstoNettyAddress(java.lang.Object address)Ifaddressif a ServiceTalk specific address it is unwrapped into a Netty address.static java.net.InetSocketAddresstoResolvedInetSocketAddress(HostAndPort resolvedAddress)ConvertsHostAndPortthat contains a resolved address intoInetSocketAddress.static booleanuseEpoll(io.netty.channel.EventLoopGroup group)Returnstrueif native epoll transport should be used.static booleanuseKQueue(io.netty.channel.EventLoopGroup group)Returnstrueif native kqueue transport should be used.
-
-
-
Method Detail
-
useEpoll
public static boolean useEpoll(io.netty.channel.EventLoopGroup group)
Returnstrueif native epoll transport should be used.- Parameters:
group- the usedEventLoopGroup- Returns:
trueif native transport should be used
-
useKQueue
public static boolean useKQueue(io.netty.channel.EventLoopGroup group)
Returnstrueif native kqueue transport should be used.- Parameters:
group- the usedEventLoopGroup- Returns:
trueif native transport should be used
-
serverChannel
public static java.lang.Class<? extends io.netty.channel.ServerChannel> serverChannel(io.netty.channel.EventLoopGroup group, java.lang.Class<? extends java.net.SocketAddress> addressClass)Returns the correctClassto use with the givenEventLoopGroup.- Parameters:
group- theEventLoopGroupfor which the class is neededaddressClass- The class of the address that the server socket will be bound to.- Returns:
- the class that should be used for bootstrapping
-
socketChannel
public static java.lang.Class<? extends io.netty.channel.Channel> socketChannel(io.netty.channel.EventLoopGroup group, java.lang.Class<? extends java.net.SocketAddress> addressClass)Returns the correctClassto use with the givenEventLoopGroup.- Parameters:
group- theEventLoopGroupfor which the class is neededaddressClass- The class of the address that to connect to.- Returns:
- the class that should be used for bootstrapping
-
socketChannel
@Nullable public static io.netty.channel.Channel socketChannel(io.netty.channel.EventLoopGroup group, FileDescriptorSocketAddress address)Returns the correct Channel that wraps the given filedescriptor ornullif not supported.- Parameters:
group- theEventLoopGroupfor which the class is neededaddress- the filedescriptor to wrap.- Returns:
- the class that should be used for bootstrapping
-
toNettyAddress
public static java.net.SocketAddress toNettyAddress(java.lang.Object address)
Ifaddressif a ServiceTalk specific address it is unwrapped into a Netty address.- Parameters:
address- the address to convert.- Returns:
- an address that Netty understands.
-
toResolvedInetSocketAddress
public static java.net.InetSocketAddress toResolvedInetSocketAddress(HostAndPort resolvedAddress)
ConvertsHostAndPortthat contains a resolved address intoInetSocketAddress.- Parameters:
resolvedAddress- the resolved address to convert.- Returns:
InetSocketAddressfrom the passed resolvedHostAndPort.
-
datagramChannel
public static java.lang.Class<? extends io.netty.channel.socket.DatagramChannel> datagramChannel(io.netty.channel.EventLoopGroup group)
Returns the correctClassto use with the givenEventLoopGroup.- Parameters:
group- theEventLoopGroupfor which the class is needed- Returns:
- the class that should be used for bootstrapping
-
formatCanonicalAddress
public static java.lang.String formatCanonicalAddress(java.net.SocketAddress address)
Format an address into a canonical numeric format.- Parameters:
address- socket address- Returns:
- formatted address
-
closeAndRethrowUnchecked
public static void closeAndRethrowUnchecked(@Nullable java.io.Closeable closable)CallCloseable.close()and re-throw an unchecked exception if a checked exception is thrown.- Parameters:
closable- The object to close.
-
-