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<Void>, io.netty.util.concurrent.Promise<Void>, Future<Void>, BiConsumer<Void,Exception>

public class NettyListener extends Object implements BiConsumer<Void,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 Details

    • accept

      public void accept(Void v, Exception exception)
      Specified by:
      accept in interface BiConsumer<Void,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(Void result)
      Specified by:
      setSuccess in interface io.netty.channel.ChannelPromise
      Specified by:
      setSuccess in interface io.netty.util.concurrent.Promise<Void>
    • trySuccess

      public boolean trySuccess(Void result)
      Specified by:
      trySuccess in interface io.netty.util.concurrent.Promise<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(Throwable cause)
      Specified by:
      setFailure in interface io.netty.channel.ChannelPromise
      Specified by:
      setFailure in interface io.netty.util.concurrent.Promise<Void>
    • tryFailure

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

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

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

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

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

      public io.netty.channel.ChannelPromise addListener(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super 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<Void>
      Specified by:
      addListener in interface io.netty.util.concurrent.Promise<Void>
    • addListeners

      @SafeVarargs public final io.netty.channel.ChannelPromise addListeners(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super 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<Void>
      Specified by:
      addListeners in interface io.netty.util.concurrent.Promise<Void>
    • removeListener

      public io.netty.channel.ChannelPromise removeListener(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super 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<Void>
      Specified by:
      removeListener in interface io.netty.util.concurrent.Promise<Void>
    • removeListeners

      @SafeVarargs public final io.netty.channel.ChannelPromise removeListeners(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super 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<Void>
      Specified by:
      removeListeners in interface io.netty.util.concurrent.Promise<Void>
    • sync

      public io.netty.channel.ChannelPromise sync() throws 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<Void>
      Specified by:
      sync in interface io.netty.util.concurrent.Promise<Void>
      Throws:
      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<Void>
      Specified by:
      syncUninterruptibly in interface io.netty.util.concurrent.Promise<Void>
    • await

      public io.netty.channel.ChannelPromise await() throws 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<Void>
      Specified by:
      await in interface io.netty.util.concurrent.Promise<Void>
      Throws:
      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<Void>
      Specified by:
      awaitUninterruptibly in interface io.netty.util.concurrent.Promise<Void>
    • await

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

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

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

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

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

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

      public boolean isCancelled()
      Specified by:
      isCancelled in interface Future<Void>
    • isDone

      public boolean isDone()
      Specified by:
      isDone in interface Future<Void>
    • get

      Specified by:
      get in interface Future<Void>
      Throws:
      InterruptedException
      ExecutionException
    • get

      public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
      Specified by:
      get in interface Future<Void>
      Throws:
      InterruptedException
      ExecutionException
      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(BiConsumer<Void,Exception> biConsumer, io.netty.channel.Channel channel)
    • fromChannelPromise

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