Class NettyFutureUtils

java.lang.Object
org.apache.hadoop.hbase.util.NettyFutureUtils

@Private public final class NettyFutureUtils extends Object
Helper class for processing netty futures.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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
    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.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOG

      private static final org.slf4j.Logger LOG
  • Constructor Details

  • 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 the listener to catch possible code bugs.

      And the error phone check will always report FutureReturnValueIgnored because every method in the Future class will return a new Future, 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

      public static void consume(org.apache.hbase.thirdparty.io.netty.util.concurrent.Future<?> future)
      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.