Package com.linkedin.alpini.netty4.misc
Class ShutdownableEventLoopGroup<E extends io.netty.channel.EventLoopGroup>
- java.lang.Object
-
- com.linkedin.alpini.netty4.misc.ShutdownableEventLoopGroup<E>
-
- All Implemented Interfaces:
Shutdownable
,io.netty.channel.EventLoopGroup
,io.netty.util.concurrent.EventExecutorGroup
,java.lang.Iterable<io.netty.util.concurrent.EventExecutor>
,java.util.concurrent.Executor
,java.util.concurrent.ExecutorService
,java.util.concurrent.ScheduledExecutorService
public class ShutdownableEventLoopGroup<E extends io.netty.channel.EventLoopGroup> extends java.lang.Object implements io.netty.channel.EventLoopGroup, Shutdownable
Created by acurtis on 3/30/17.
-
-
Constructor Summary
Constructors Constructor Description ShutdownableEventLoopGroup(E eventLoop)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
awaitTermination(long timeout, java.util.concurrent.TimeUnit unit)
E
eventLoopGroup()
void
execute(java.lang.Runnable command)
<T> java.util.List<java.util.concurrent.Future<T>>
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
<T> java.util.List<java.util.concurrent.Future<T>>
invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)
<T> T
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks)
<T> T
invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit)
boolean
isShutdown()
boolean
isShuttingDown()
boolean
isTerminated()
java.util.Iterator<io.netty.util.concurrent.EventExecutor>
iterator()
io.netty.channel.EventLoop
next()
io.netty.channel.ChannelFuture
register(io.netty.channel.Channel channel)
io.netty.channel.ChannelFuture
register(io.netty.channel.ChannelPromise promise)
io.netty.channel.ChannelFuture
register(io.netty.channel.Channel channel, io.netty.channel.ChannelPromise promise)
io.netty.util.concurrent.ScheduledFuture<?>
schedule(java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)
<V> io.netty.util.concurrent.ScheduledFuture<V>
schedule(java.util.concurrent.Callable<V> callable, long delay, java.util.concurrent.TimeUnit unit)
io.netty.util.concurrent.ScheduledFuture<?>
scheduleAtFixedRate(java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
io.netty.util.concurrent.ScheduledFuture<?>
scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
void
shutdown()
Starts the shutdown process.io.netty.util.concurrent.Future<?>
shutdownGracefully()
io.netty.util.concurrent.Future<?>
shutdownGracefully(long quietPeriod, long timeout, java.util.concurrent.TimeUnit unit)
java.util.List<java.lang.Runnable>
shutdownNow()
io.netty.util.concurrent.Future<?>
submit(java.lang.Runnable task)
<T> io.netty.util.concurrent.Future<T>
submit(java.lang.Runnable task, T result)
<T> io.netty.util.concurrent.Future<T>
submit(java.util.concurrent.Callable<T> task)
io.netty.util.concurrent.Future<?>
terminationFuture()
void
waitForShutdown()
Waits for shutdown to completevoid
waitForShutdown(long timeoutInMs)
Waits for shutdown to complete with a timeout
-
-
-
Constructor Detail
-
ShutdownableEventLoopGroup
public ShutdownableEventLoopGroup(E eventLoop)
-
-
Method Detail
-
eventLoopGroup
public E eventLoopGroup()
-
waitForShutdown
public void waitForShutdown() throws java.lang.InterruptedException, java.lang.IllegalStateException
Description copied from interface:Shutdownable
Waits for shutdown to complete- Specified by:
waitForShutdown
in interfaceShutdownable
- Throws:
java.lang.InterruptedException
- when the wait is interruptedjava.lang.IllegalStateException
- when the method is invoked when the shutdown has yet to be started
-
waitForShutdown
public void waitForShutdown(long timeoutInMs) throws java.lang.InterruptedException, java.lang.IllegalStateException, java.util.concurrent.TimeoutException
Description copied from interface:Shutdownable
Waits for shutdown to complete with a timeout- Specified by:
waitForShutdown
in interfaceShutdownable
- Parameters:
timeoutInMs
- number of milliseconds to wait before throwing TimeoutException- Throws:
java.lang.InterruptedException
- when the wait is interruptedjava.lang.IllegalStateException
- when the method is invoked when the shutdown has yet to be startedjava.util.concurrent.TimeoutException
- when the operation times out
-
isShuttingDown
public boolean isShuttingDown()
- Specified by:
isShuttingDown
in interfaceio.netty.util.concurrent.EventExecutorGroup
-
shutdownGracefully
public io.netty.util.concurrent.Future<?> shutdownGracefully()
- Specified by:
shutdownGracefully
in interfaceio.netty.util.concurrent.EventExecutorGroup
-
shutdownGracefully
public io.netty.util.concurrent.Future<?> shutdownGracefully(long quietPeriod, long timeout, java.util.concurrent.TimeUnit unit)
- Specified by:
shutdownGracefully
in interfaceio.netty.util.concurrent.EventExecutorGroup
-
terminationFuture
public io.netty.util.concurrent.Future<?> terminationFuture()
- Specified by:
terminationFuture
in interfaceio.netty.util.concurrent.EventExecutorGroup
-
shutdown
public void shutdown()
Description copied from interface:Shutdownable
Starts the shutdown process. It is recommended to perform the actual shutdown activity in a separate thread from the thread that calls shutdown- Specified by:
shutdown
in interfaceio.netty.util.concurrent.EventExecutorGroup
- Specified by:
shutdown
in interfacejava.util.concurrent.ExecutorService
- Specified by:
shutdown
in interfaceShutdownable
-
shutdownNow
public java.util.List<java.lang.Runnable> shutdownNow()
- Specified by:
shutdownNow
in interfaceio.netty.util.concurrent.EventExecutorGroup
- Specified by:
shutdownNow
in interfacejava.util.concurrent.ExecutorService
-
isShutdown
public boolean isShutdown()
- Specified by:
isShutdown
in interfacejava.util.concurrent.ExecutorService
-
isTerminated
public boolean isTerminated()
- Specified by:
isTerminated
in interfacejava.util.concurrent.ExecutorService
-
awaitTermination
public boolean awaitTermination(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
awaitTermination
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
next
public io.netty.channel.EventLoop next()
- Specified by:
next
in interfaceio.netty.util.concurrent.EventExecutorGroup
- Specified by:
next
in interfaceio.netty.channel.EventLoopGroup
-
iterator
public java.util.Iterator<io.netty.util.concurrent.EventExecutor> iterator()
- Specified by:
iterator
in interfaceio.netty.util.concurrent.EventExecutorGroup
- Specified by:
iterator
in interfacejava.lang.Iterable<E extends io.netty.channel.EventLoopGroup>
-
submit
public io.netty.util.concurrent.Future<?> submit(java.lang.Runnable task)
- Specified by:
submit
in interfaceio.netty.util.concurrent.EventExecutorGroup
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
invokeAll
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException
- Specified by:
invokeAll
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
invokeAll
public <T> java.util.List<java.util.concurrent.Future<T>> invokeAll(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
- Specified by:
invokeAll
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
-
invokeAny
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
- Specified by:
invokeAny
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
-
invokeAny
public <T> T invokeAny(java.util.Collection<? extends java.util.concurrent.Callable<T>> tasks, long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
- Specified by:
invokeAny
in interfacejava.util.concurrent.ExecutorService
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
-
submit
public <T> io.netty.util.concurrent.Future<T> submit(java.lang.Runnable task, T result)
- Specified by:
submit
in interfaceio.netty.util.concurrent.EventExecutorGroup
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
submit
public <T> io.netty.util.concurrent.Future<T> submit(java.util.concurrent.Callable<T> task)
- Specified by:
submit
in interfaceio.netty.util.concurrent.EventExecutorGroup
- Specified by:
submit
in interfacejava.util.concurrent.ExecutorService
-
schedule
public io.netty.util.concurrent.ScheduledFuture<?> schedule(java.lang.Runnable command, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
schedule
in interfaceio.netty.util.concurrent.EventExecutorGroup
- Specified by:
schedule
in interfacejava.util.concurrent.ScheduledExecutorService
-
schedule
public <V> io.netty.util.concurrent.ScheduledFuture<V> schedule(java.util.concurrent.Callable<V> callable, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
schedule
in interfaceio.netty.util.concurrent.EventExecutorGroup
- Specified by:
schedule
in interfacejava.util.concurrent.ScheduledExecutorService
-
scheduleAtFixedRate
public io.netty.util.concurrent.ScheduledFuture<?> scheduleAtFixedRate(java.lang.Runnable command, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
- Specified by:
scheduleAtFixedRate
in interfaceio.netty.util.concurrent.EventExecutorGroup
- Specified by:
scheduleAtFixedRate
in interfacejava.util.concurrent.ScheduledExecutorService
-
scheduleWithFixedDelay
public io.netty.util.concurrent.ScheduledFuture<?> scheduleWithFixedDelay(java.lang.Runnable command, long initialDelay, long delay, java.util.concurrent.TimeUnit unit)
- Specified by:
scheduleWithFixedDelay
in interfaceio.netty.util.concurrent.EventExecutorGroup
- Specified by:
scheduleWithFixedDelay
in interfacejava.util.concurrent.ScheduledExecutorService
-
register
public io.netty.channel.ChannelFuture register(io.netty.channel.Channel channel)
- Specified by:
register
in interfaceio.netty.channel.EventLoopGroup
-
register
public io.netty.channel.ChannelFuture register(io.netty.channel.ChannelPromise promise)
- Specified by:
register
in interfaceio.netty.channel.EventLoopGroup
-
register
public io.netty.channel.ChannelFuture register(io.netty.channel.Channel channel, io.netty.channel.ChannelPromise promise)
- Specified by:
register
in interfaceio.netty.channel.EventLoopGroup
-
execute
public void execute(java.lang.Runnable command)
- Specified by:
execute
in interfacejava.util.concurrent.Executor
-
-