Package org.apache.hadoop.hbase.util
Class NettyFutureUtils
java.lang.Object
org.apache.hadoop.hbase.util.NettyFutureUtils
Helper class for processing netty futures.
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <V> void
addListener
(org.apache.hbase.thirdparty.io.netty.util.concurrent.Future<V> future, org.apache.hbase.thirdparty.io.netty.util.concurrent.GenericFutureListener<? extends org.apache.hbase.thirdparty.io.netty.util.concurrent.Future<? super V>> listener) This is method is used when you just want to add a listener to the given netty future.static void
consume
(org.apache.hbase.thirdparty.io.netty.util.concurrent.Future<?> future) Log the error if the future indicates any failure.private static void
loggingWhenError
(org.apache.hbase.thirdparty.io.netty.util.concurrent.Future<?> future) static void
safeClose
(org.apache.hbase.thirdparty.io.netty.channel.ChannelOutboundInvoker channel) Close the channel and eat the returned future by logging the error when the future is completed with error.static void
Call write on the channel and eat the returned future by logging the error when the future is completed with error.static void
safeWriteAndFlush
(org.apache.hbase.thirdparty.io.netty.channel.ChannelOutboundInvoker channel, Object msg) Call writeAndFlush on the channel and eat the returned future by logging the error when the future is completed with error.
-
Field Details
-
LOG
-
-
Constructor Details
-
NettyFutureUtils
private NettyFutureUtils()
-
-
Method Details
-
addListener
public static <V> void addListener(org.apache.hbase.thirdparty.io.netty.util.concurrent.Future<V> future, org.apache.hbase.thirdparty.io.netty.util.concurrent.GenericFutureListener<? extends org.apache.hbase.thirdparty.io.netty.util.concurrent.Future<? super V>> listener) This is method is used when you just want to add a listener to the given netty future. Ignoring the return value of a Future is considered as a bad practice as it may suppress exceptions thrown from the code that completes the future, and this method will catch all the exception thrown from thelistener
to catch possible code bugs. And the error phone check will always report FutureReturnValueIgnored because every method in theFuture
class will return a newFuture
, so you always have one future that has not been checked. So we introduce this method and add a suppress warnings annotation here. -
loggingWhenError
private static void loggingWhenError(org.apache.hbase.thirdparty.io.netty.util.concurrent.Future<?> future) -
consume
Log the error if the future indicates any failure. -
safeClose
public static void safeClose(org.apache.hbase.thirdparty.io.netty.channel.ChannelOutboundInvoker channel) Close the channel and eat the returned future by logging the error when the future is completed with error. -
safeWrite
public static void safeWrite(org.apache.hbase.thirdparty.io.netty.channel.ChannelOutboundInvoker channel, Object msg) Call write on the channel and eat the returned future by logging the error when the future is completed with error. -
safeWriteAndFlush
public static void safeWriteAndFlush(org.apache.hbase.thirdparty.io.netty.channel.ChannelOutboundInvoker channel, Object msg) Call writeAndFlush on the channel and eat the returned future by logging the error when the future is completed with error.
-