Class NettyListener

java.lang.Object
org.elasticsearch.http.nio.NettyListener
All Implemented Interfaces:
io.netty.channel.ChannelFuture, io.netty.channel.ChannelPromise, io.netty.util.concurrent.Future<java.lang.Void>, io.netty.util.concurrent.Promise<java.lang.Void>, java.util.concurrent.Future<java.lang.Void>, java.util.function.BiConsumer<java.lang.Void,​java.lang.Exception>

public class NettyListener
extends java.lang.Object
implements java.util.function.BiConsumer<java.lang.Void,​java.lang.Exception>, io.netty.channel.ChannelPromise
This is an BiConsumer that interfaces with netty code. It wraps a netty promise and will complete that promise when accept is called. It delegates the normal promise methods to the underlying promise.
  • Method Summary

    Modifier and Type Method Description
    void accept​(java.lang.Void v, java.lang.Exception exception)  
    io.netty.channel.ChannelPromise addListener​(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> listener)  
    io.netty.channel.ChannelPromise addListeners​(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>>... listeners)  
    io.netty.channel.ChannelPromise await()  
    boolean await​(long timeoutMillis)  
    boolean await​(long timeout, java.util.concurrent.TimeUnit unit)  
    io.netty.channel.ChannelPromise awaitUninterruptibly()  
    boolean awaitUninterruptibly​(long timeoutMillis)  
    boolean awaitUninterruptibly​(long timeout, java.util.concurrent.TimeUnit unit)  
    boolean cancel​(boolean mayInterruptIfRunning)  
    java.lang.Throwable cause()  
    io.netty.channel.Channel channel()  
    static NettyListener fromBiConsumer​(java.util.function.BiConsumer<java.lang.Void,​java.lang.Exception> biConsumer, io.netty.channel.Channel channel)  
    static NettyListener fromChannelPromise​(io.netty.channel.ChannelPromise channelPromise)  
    java.lang.Void get()  
    java.lang.Void get​(long timeout, java.util.concurrent.TimeUnit unit)  
    java.lang.Void getNow()  
    boolean isCancellable()  
    boolean isCancelled()  
    boolean isDone()  
    boolean isSuccess()  
    boolean isVoid()  
    io.netty.channel.ChannelPromise removeListener​(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> listener)  
    io.netty.channel.ChannelPromise removeListeners​(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>>... listeners)  
    io.netty.channel.ChannelPromise setFailure​(java.lang.Throwable cause)  
    io.netty.channel.ChannelPromise setSuccess()  
    io.netty.channel.ChannelPromise setSuccess​(java.lang.Void result)  
    boolean setUncancellable()  
    io.netty.channel.ChannelPromise sync()  
    io.netty.channel.ChannelPromise syncUninterruptibly()  
    boolean tryFailure​(java.lang.Throwable cause)  
    boolean trySuccess()  
    boolean trySuccess​(java.lang.Void result)  
    io.netty.channel.ChannelPromise unvoid()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.util.function.BiConsumer

    andThen
  • Method Details

    • accept

      public void accept​(java.lang.Void v, java.lang.Exception exception)
      Specified by:
      accept in interface java.util.function.BiConsumer<java.lang.Void,​java.lang.Exception>
    • channel

      public io.netty.channel.Channel channel()
      Specified by:
      channel in interface io.netty.channel.ChannelFuture
      Specified by:
      channel in interface io.netty.channel.ChannelPromise
    • setSuccess

      public io.netty.channel.ChannelPromise setSuccess​(java.lang.Void result)
      Specified by:
      setSuccess in interface io.netty.channel.ChannelPromise
      Specified by:
      setSuccess in interface io.netty.util.concurrent.Promise<java.lang.Void>
    • trySuccess

      public boolean trySuccess​(java.lang.Void result)
      Specified by:
      trySuccess in interface io.netty.util.concurrent.Promise<java.lang.Void>
    • setSuccess

      public io.netty.channel.ChannelPromise setSuccess()
      Specified by:
      setSuccess in interface io.netty.channel.ChannelPromise
    • trySuccess

      public boolean trySuccess()
      Specified by:
      trySuccess in interface io.netty.channel.ChannelPromise
    • setFailure

      public io.netty.channel.ChannelPromise setFailure​(java.lang.Throwable cause)
      Specified by:
      setFailure in interface io.netty.channel.ChannelPromise
      Specified by:
      setFailure in interface io.netty.util.concurrent.Promise<java.lang.Void>
    • tryFailure

      public boolean tryFailure​(java.lang.Throwable cause)
      Specified by:
      tryFailure in interface io.netty.util.concurrent.Promise<java.lang.Void>
    • setUncancellable

      public boolean setUncancellable()
      Specified by:
      setUncancellable in interface io.netty.util.concurrent.Promise<java.lang.Void>
    • isSuccess

      public boolean isSuccess()
      Specified by:
      isSuccess in interface io.netty.util.concurrent.Future<java.lang.Void>
    • isCancellable

      public boolean isCancellable()
      Specified by:
      isCancellable in interface io.netty.util.concurrent.Future<java.lang.Void>
    • cause

      public java.lang.Throwable cause()
      Specified by:
      cause in interface io.netty.util.concurrent.Future<java.lang.Void>
    • addListener

      public io.netty.channel.ChannelPromise addListener​(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> listener)
      Specified by:
      addListener in interface io.netty.channel.ChannelFuture
      Specified by:
      addListener in interface io.netty.channel.ChannelPromise
      Specified by:
      addListener in interface io.netty.util.concurrent.Future<java.lang.Void>
      Specified by:
      addListener in interface io.netty.util.concurrent.Promise<java.lang.Void>
    • addListeners

      @SafeVarargs public final io.netty.channel.ChannelPromise addListeners​(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>>... listeners)
      Specified by:
      addListeners in interface io.netty.channel.ChannelFuture
      Specified by:
      addListeners in interface io.netty.channel.ChannelPromise
      Specified by:
      addListeners in interface io.netty.util.concurrent.Future<java.lang.Void>
      Specified by:
      addListeners in interface io.netty.util.concurrent.Promise<java.lang.Void>
    • removeListener

      public io.netty.channel.ChannelPromise removeListener​(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> listener)
      Specified by:
      removeListener in interface io.netty.channel.ChannelFuture
      Specified by:
      removeListener in interface io.netty.channel.ChannelPromise
      Specified by:
      removeListener in interface io.netty.util.concurrent.Future<java.lang.Void>
      Specified by:
      removeListener in interface io.netty.util.concurrent.Promise<java.lang.Void>
    • removeListeners

      @SafeVarargs public final io.netty.channel.ChannelPromise removeListeners​(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>>... listeners)
      Specified by:
      removeListeners in interface io.netty.channel.ChannelFuture
      Specified by:
      removeListeners in interface io.netty.channel.ChannelPromise
      Specified by:
      removeListeners in interface io.netty.util.concurrent.Future<java.lang.Void>
      Specified by:
      removeListeners in interface io.netty.util.concurrent.Promise<java.lang.Void>
    • sync

      public io.netty.channel.ChannelPromise sync() throws java.lang.InterruptedException
      Specified by:
      sync in interface io.netty.channel.ChannelFuture
      Specified by:
      sync in interface io.netty.channel.ChannelPromise
      Specified by:
      sync in interface io.netty.util.concurrent.Future<java.lang.Void>
      Specified by:
      sync in interface io.netty.util.concurrent.Promise<java.lang.Void>
      Throws:
      java.lang.InterruptedException
    • syncUninterruptibly

      public io.netty.channel.ChannelPromise syncUninterruptibly()
      Specified by:
      syncUninterruptibly in interface io.netty.channel.ChannelFuture
      Specified by:
      syncUninterruptibly in interface io.netty.channel.ChannelPromise
      Specified by:
      syncUninterruptibly in interface io.netty.util.concurrent.Future<java.lang.Void>
      Specified by:
      syncUninterruptibly in interface io.netty.util.concurrent.Promise<java.lang.Void>
    • await

      public io.netty.channel.ChannelPromise await() throws java.lang.InterruptedException
      Specified by:
      await in interface io.netty.channel.ChannelFuture
      Specified by:
      await in interface io.netty.channel.ChannelPromise
      Specified by:
      await in interface io.netty.util.concurrent.Future<java.lang.Void>
      Specified by:
      await in interface io.netty.util.concurrent.Promise<java.lang.Void>
      Throws:
      java.lang.InterruptedException
    • awaitUninterruptibly

      public io.netty.channel.ChannelPromise awaitUninterruptibly()
      Specified by:
      awaitUninterruptibly in interface io.netty.channel.ChannelFuture
      Specified by:
      awaitUninterruptibly in interface io.netty.channel.ChannelPromise
      Specified by:
      awaitUninterruptibly in interface io.netty.util.concurrent.Future<java.lang.Void>
      Specified by:
      awaitUninterruptibly in interface io.netty.util.concurrent.Promise<java.lang.Void>
    • await

      public boolean await​(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
      Specified by:
      await in interface io.netty.util.concurrent.Future<java.lang.Void>
      Throws:
      java.lang.InterruptedException
    • await

      public boolean await​(long timeoutMillis) throws java.lang.InterruptedException
      Specified by:
      await in interface io.netty.util.concurrent.Future<java.lang.Void>
      Throws:
      java.lang.InterruptedException
    • awaitUninterruptibly

      public boolean awaitUninterruptibly​(long timeout, java.util.concurrent.TimeUnit unit)
      Specified by:
      awaitUninterruptibly in interface io.netty.util.concurrent.Future<java.lang.Void>
    • awaitUninterruptibly

      public boolean awaitUninterruptibly​(long timeoutMillis)
      Specified by:
      awaitUninterruptibly in interface io.netty.util.concurrent.Future<java.lang.Void>
    • getNow

      public java.lang.Void getNow()
      Specified by:
      getNow in interface io.netty.util.concurrent.Future<java.lang.Void>
    • cancel

      public boolean cancel​(boolean mayInterruptIfRunning)
      Specified by:
      cancel in interface io.netty.util.concurrent.Future<java.lang.Void>
      Specified by:
      cancel in interface java.util.concurrent.Future<java.lang.Void>
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface java.util.concurrent.Future<java.lang.Void>
    • isDone

      public boolean isDone()
      Specified by:
      isDone in interface java.util.concurrent.Future<java.lang.Void>
    • get

      public java.lang.Void get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
      Specified by:
      get in interface java.util.concurrent.Future<java.lang.Void>
      Throws:
      java.lang.InterruptedException
      java.util.concurrent.ExecutionException
    • get

      public java.lang.Void get​(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
      Specified by:
      get in interface java.util.concurrent.Future<java.lang.Void>
      Throws:
      java.lang.InterruptedException
      java.util.concurrent.ExecutionException
      java.util.concurrent.TimeoutException
    • isVoid

      public boolean isVoid()
      Specified by:
      isVoid in interface io.netty.channel.ChannelFuture
    • unvoid

      public io.netty.channel.ChannelPromise unvoid()
      Specified by:
      unvoid in interface io.netty.channel.ChannelPromise
    • fromBiConsumer

      public static NettyListener fromBiConsumer​(java.util.function.BiConsumer<java.lang.Void,​java.lang.Exception> biConsumer, io.netty.channel.Channel channel)
    • fromChannelPromise

      public static NettyListener fromChannelPromise​(io.netty.channel.ChannelPromise channelPromise)