Package org.elasticsearch.http.nio
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 voidaccept(java.lang.Void v, java.lang.Exception exception)io.netty.channel.ChannelPromiseaddListener(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> listener)io.netty.channel.ChannelPromiseaddListeners(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>>... listeners)io.netty.channel.ChannelPromiseawait()booleanawait(long timeoutMillis)booleanawait(long timeout, java.util.concurrent.TimeUnit unit)io.netty.channel.ChannelPromiseawaitUninterruptibly()booleanawaitUninterruptibly(long timeoutMillis)booleanawaitUninterruptibly(long timeout, java.util.concurrent.TimeUnit unit)booleancancel(boolean mayInterruptIfRunning)java.lang.Throwablecause()io.netty.channel.Channelchannel()static NettyListenerfromBiConsumer(java.util.function.BiConsumer<java.lang.Void,java.lang.Exception> biConsumer, io.netty.channel.Channel channel)static NettyListenerfromChannelPromise(io.netty.channel.ChannelPromise channelPromise)java.lang.Voidget()java.lang.Voidget(long timeout, java.util.concurrent.TimeUnit unit)java.lang.VoidgetNow()booleanisCancellable()booleanisCancelled()booleanisDone()booleanisSuccess()booleanisVoid()io.netty.channel.ChannelPromiseremoveListener(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> listener)io.netty.channel.ChannelPromiseremoveListeners(io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>>... listeners)io.netty.channel.ChannelPromisesetFailure(java.lang.Throwable cause)io.netty.channel.ChannelPromisesetSuccess()io.netty.channel.ChannelPromisesetSuccess(java.lang.Void result)booleansetUncancellable()io.netty.channel.ChannelPromisesync()io.netty.channel.ChannelPromisesyncUninterruptibly()booleantryFailure(java.lang.Throwable cause)booleantrySuccess()booleantrySuccess(java.lang.Void result)io.netty.channel.ChannelPromiseunvoid()
-
Method Details
-
accept
public void accept(java.lang.Void v, java.lang.Exception exception)- Specified by:
acceptin interfacejava.util.function.BiConsumer<java.lang.Void,java.lang.Exception>
-
channel
public io.netty.channel.Channel channel()- Specified by:
channelin interfaceio.netty.channel.ChannelFuture- Specified by:
channelin interfaceio.netty.channel.ChannelPromise
-
setSuccess
public io.netty.channel.ChannelPromise setSuccess(java.lang.Void result)- Specified by:
setSuccessin interfaceio.netty.channel.ChannelPromise- Specified by:
setSuccessin interfaceio.netty.util.concurrent.Promise<java.lang.Void>
-
trySuccess
public boolean trySuccess(java.lang.Void result)- Specified by:
trySuccessin interfaceio.netty.util.concurrent.Promise<java.lang.Void>
-
setSuccess
public io.netty.channel.ChannelPromise setSuccess()- Specified by:
setSuccessin interfaceio.netty.channel.ChannelPromise
-
trySuccess
public boolean trySuccess()- Specified by:
trySuccessin interfaceio.netty.channel.ChannelPromise
-
setFailure
public io.netty.channel.ChannelPromise setFailure(java.lang.Throwable cause)- Specified by:
setFailurein interfaceio.netty.channel.ChannelPromise- Specified by:
setFailurein interfaceio.netty.util.concurrent.Promise<java.lang.Void>
-
tryFailure
public boolean tryFailure(java.lang.Throwable cause)- Specified by:
tryFailurein interfaceio.netty.util.concurrent.Promise<java.lang.Void>
-
setUncancellable
public boolean setUncancellable()- Specified by:
setUncancellablein interfaceio.netty.util.concurrent.Promise<java.lang.Void>
-
isSuccess
public boolean isSuccess()- Specified by:
isSuccessin interfaceio.netty.util.concurrent.Future<java.lang.Void>
-
isCancellable
public boolean isCancellable()- Specified by:
isCancellablein interfaceio.netty.util.concurrent.Future<java.lang.Void>
-
cause
public java.lang.Throwable cause()- Specified by:
causein interfaceio.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:
addListenerin interfaceio.netty.channel.ChannelFuture- Specified by:
addListenerin interfaceio.netty.channel.ChannelPromise- Specified by:
addListenerin interfaceio.netty.util.concurrent.Future<java.lang.Void>- Specified by:
addListenerin interfaceio.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:
addListenersin interfaceio.netty.channel.ChannelFuture- Specified by:
addListenersin interfaceio.netty.channel.ChannelPromise- Specified by:
addListenersin interfaceio.netty.util.concurrent.Future<java.lang.Void>- Specified by:
addListenersin interfaceio.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:
removeListenerin interfaceio.netty.channel.ChannelFuture- Specified by:
removeListenerin interfaceio.netty.channel.ChannelPromise- Specified by:
removeListenerin interfaceio.netty.util.concurrent.Future<java.lang.Void>- Specified by:
removeListenerin interfaceio.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:
removeListenersin interfaceio.netty.channel.ChannelFuture- Specified by:
removeListenersin interfaceio.netty.channel.ChannelPromise- Specified by:
removeListenersin interfaceio.netty.util.concurrent.Future<java.lang.Void>- Specified by:
removeListenersin interfaceio.netty.util.concurrent.Promise<java.lang.Void>
-
sync
public io.netty.channel.ChannelPromise sync() throws java.lang.InterruptedException- Specified by:
syncin interfaceio.netty.channel.ChannelFuture- Specified by:
syncin interfaceio.netty.channel.ChannelPromise- Specified by:
syncin interfaceio.netty.util.concurrent.Future<java.lang.Void>- Specified by:
syncin interfaceio.netty.util.concurrent.Promise<java.lang.Void>- Throws:
java.lang.InterruptedException
-
syncUninterruptibly
public io.netty.channel.ChannelPromise syncUninterruptibly()- Specified by:
syncUninterruptiblyin interfaceio.netty.channel.ChannelFuture- Specified by:
syncUninterruptiblyin interfaceio.netty.channel.ChannelPromise- Specified by:
syncUninterruptiblyin interfaceio.netty.util.concurrent.Future<java.lang.Void>- Specified by:
syncUninterruptiblyin interfaceio.netty.util.concurrent.Promise<java.lang.Void>
-
await
public io.netty.channel.ChannelPromise await() throws java.lang.InterruptedException- Specified by:
awaitin interfaceio.netty.channel.ChannelFuture- Specified by:
awaitin interfaceio.netty.channel.ChannelPromise- Specified by:
awaitin interfaceio.netty.util.concurrent.Future<java.lang.Void>- Specified by:
awaitin interfaceio.netty.util.concurrent.Promise<java.lang.Void>- Throws:
java.lang.InterruptedException
-
awaitUninterruptibly
public io.netty.channel.ChannelPromise awaitUninterruptibly()- Specified by:
awaitUninterruptiblyin interfaceio.netty.channel.ChannelFuture- Specified by:
awaitUninterruptiblyin interfaceio.netty.channel.ChannelPromise- Specified by:
awaitUninterruptiblyin interfaceio.netty.util.concurrent.Future<java.lang.Void>- Specified by:
awaitUninterruptiblyin interfaceio.netty.util.concurrent.Promise<java.lang.Void>
-
await
public boolean await(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException- Specified by:
awaitin interfaceio.netty.util.concurrent.Future<java.lang.Void>- Throws:
java.lang.InterruptedException
-
await
public boolean await(long timeoutMillis) throws java.lang.InterruptedException- Specified by:
awaitin interfaceio.netty.util.concurrent.Future<java.lang.Void>- Throws:
java.lang.InterruptedException
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeout, java.util.concurrent.TimeUnit unit)- Specified by:
awaitUninterruptiblyin interfaceio.netty.util.concurrent.Future<java.lang.Void>
-
awaitUninterruptibly
public boolean awaitUninterruptibly(long timeoutMillis)- Specified by:
awaitUninterruptiblyin interfaceio.netty.util.concurrent.Future<java.lang.Void>
-
getNow
public java.lang.Void getNow()- Specified by:
getNowin interfaceio.netty.util.concurrent.Future<java.lang.Void>
-
cancel
public boolean cancel(boolean mayInterruptIfRunning)- Specified by:
cancelin interfaceio.netty.util.concurrent.Future<java.lang.Void>- Specified by:
cancelin interfacejava.util.concurrent.Future<java.lang.Void>
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelledin interfacejava.util.concurrent.Future<java.lang.Void>
-
isDone
public boolean isDone()- Specified by:
isDonein interfacejava.util.concurrent.Future<java.lang.Void>
-
get
public java.lang.Void get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException- Specified by:
getin interfacejava.util.concurrent.Future<java.lang.Void>- Throws:
java.lang.InterruptedExceptionjava.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:
getin interfacejava.util.concurrent.Future<java.lang.Void>- Throws:
java.lang.InterruptedExceptionjava.util.concurrent.ExecutionExceptionjava.util.concurrent.TimeoutException
-
isVoid
public boolean isVoid()- Specified by:
isVoidin interfaceio.netty.channel.ChannelFuture
-
unvoid
public io.netty.channel.ChannelPromise unvoid()- Specified by:
unvoidin interfaceio.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
-