Class ExecutorNettyAdapter

  • All Implemented Interfaces:
    io.netty.channel.EventLoop, io.netty.channel.EventLoopGroup, io.netty.util.concurrent.EventExecutor, io.netty.util.concurrent.EventExecutorGroup, io.netty.util.concurrent.OrderedEventExecutor, java.lang.Iterable<io.netty.util.concurrent.EventExecutor>, java.util.concurrent.Executor, java.util.concurrent.ExecutorService, java.util.concurrent.ScheduledExecutorService

    public class ExecutorNettyAdapter
    extends java.lang.Object
    implements io.netty.channel.EventLoop
    Test cases may supply a simple executor instead of the real Netty Executor On that case this is a simple adapter for what's needed from these tests. Not intended to be used in production. TODO: This could be refactored out of the main codebase but at a high cost. We may do it some day if we find an easy way that won't clutter the code too much.
    • Constructor Summary

      Constructors 
      Constructor Description
      ExecutorNettyAdapter​(org.apache.activemq.artemis.utils.actors.ArtemisExecutor executor)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean awaitTermination​(long timeout, java.util.concurrent.TimeUnit unit)  
      void execute​(java.lang.Runnable command)  
      boolean inEventLoop()  
      boolean inEventLoop​(java.lang.Thread thread)  
      <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()  
      <V> io.netty.util.concurrent.Future<V> newFailedFuture​(java.lang.Throwable cause)  
      <V> io.netty.util.concurrent.ProgressivePromise<V> newProgressivePromise()  
      <V> io.netty.util.concurrent.Promise<V> newPromise()  
      <V> io.netty.util.concurrent.Future<V> newSucceededFuture​(V result)  
      io.netty.channel.EventLoop next()  
      io.netty.channel.EventLoopGroup parent()  
      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()  
      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()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • ExecutorNettyAdapter

        public ExecutorNettyAdapter​(org.apache.activemq.artemis.utils.actors.ArtemisExecutor executor)
    • Method Detail

      • parent

        public io.netty.channel.EventLoopGroup parent()
        Specified by:
        parent in interface io.netty.util.concurrent.EventExecutor
        Specified by:
        parent in interface io.netty.channel.EventLoop
      • next

        public io.netty.channel.EventLoop next()
        Specified by:
        next in interface io.netty.util.concurrent.EventExecutor
        Specified by:
        next in interface io.netty.util.concurrent.EventExecutorGroup
        Specified by:
        next in interface io.netty.channel.EventLoopGroup
      • register

        public io.netty.channel.ChannelFuture register​(io.netty.channel.Channel channel)
        Specified by:
        register in interface io.netty.channel.EventLoopGroup
      • register

        public io.netty.channel.ChannelFuture register​(io.netty.channel.ChannelPromise promise)
        Specified by:
        register in interface io.netty.channel.EventLoopGroup
      • register

        public io.netty.channel.ChannelFuture register​(io.netty.channel.Channel channel,
                                                       io.netty.channel.ChannelPromise promise)
        Specified by:
        register in interface io.netty.channel.EventLoopGroup
      • inEventLoop

        public boolean inEventLoop()
        Specified by:
        inEventLoop in interface io.netty.util.concurrent.EventExecutor
      • inEventLoop

        public boolean inEventLoop​(java.lang.Thread thread)
        Specified by:
        inEventLoop in interface io.netty.util.concurrent.EventExecutor
      • newPromise

        public <V> io.netty.util.concurrent.Promise<V> newPromise()
        Specified by:
        newPromise in interface io.netty.util.concurrent.EventExecutor
      • newProgressivePromise

        public <V> io.netty.util.concurrent.ProgressivePromise<V> newProgressivePromise()
        Specified by:
        newProgressivePromise in interface io.netty.util.concurrent.EventExecutor
      • newSucceededFuture

        public <V> io.netty.util.concurrent.Future<V> newSucceededFuture​(V result)
        Specified by:
        newSucceededFuture in interface io.netty.util.concurrent.EventExecutor
      • newFailedFuture

        public <V> io.netty.util.concurrent.Future<V> newFailedFuture​(java.lang.Throwable cause)
        Specified by:
        newFailedFuture in interface io.netty.util.concurrent.EventExecutor
      • isShuttingDown

        public boolean isShuttingDown()
        Specified by:
        isShuttingDown in interface io.netty.util.concurrent.EventExecutorGroup
      • shutdownGracefully

        public io.netty.util.concurrent.Future<?> shutdownGracefully()
        Specified by:
        shutdownGracefully in interface io.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 interface io.netty.util.concurrent.EventExecutorGroup
      • terminationFuture

        public io.netty.util.concurrent.Future<?> terminationFuture()
        Specified by:
        terminationFuture in interface io.netty.util.concurrent.EventExecutorGroup
      • shutdown

        public void shutdown()
        Specified by:
        shutdown in interface io.netty.util.concurrent.EventExecutorGroup
        Specified by:
        shutdown in interface java.util.concurrent.ExecutorService
      • shutdownNow

        public java.util.List<java.lang.Runnable> shutdownNow()
        Specified by:
        shutdownNow in interface io.netty.util.concurrent.EventExecutorGroup
        Specified by:
        shutdownNow in interface java.util.concurrent.ExecutorService
      • iterator

        public java.util.Iterator<io.netty.util.concurrent.EventExecutor> iterator()
        Specified by:
        iterator in interface io.netty.util.concurrent.EventExecutorGroup
        Specified by:
        iterator in interface java.lang.Iterable<io.netty.util.concurrent.EventExecutor>
      • submit

        public io.netty.util.concurrent.Future<?> submit​(java.lang.Runnable task)
        Specified by:
        submit in interface io.netty.util.concurrent.EventExecutorGroup
        Specified by:
        submit in interface java.util.concurrent.ExecutorService
      • submit

        public <T> io.netty.util.concurrent.Future<T> submit​(java.lang.Runnable task,
                                                             T result)
        Specified by:
        submit in interface io.netty.util.concurrent.EventExecutorGroup
        Specified by:
        submit in interface java.util.concurrent.ExecutorService
      • submit

        public <T> io.netty.util.concurrent.Future<T> submit​(java.util.concurrent.Callable<T> task)
        Specified by:
        submit in interface io.netty.util.concurrent.EventExecutorGroup
        Specified by:
        submit in interface java.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 interface io.netty.util.concurrent.EventExecutorGroup
        Specified by:
        schedule in interface java.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 interface io.netty.util.concurrent.EventExecutorGroup
        Specified by:
        schedule in interface java.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 interface io.netty.util.concurrent.EventExecutorGroup
        Specified by:
        scheduleAtFixedRate in interface java.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 interface io.netty.util.concurrent.EventExecutorGroup
        Specified by:
        scheduleWithFixedDelay in interface java.util.concurrent.ScheduledExecutorService
      • isShutdown

        public boolean isShutdown()
        Specified by:
        isShutdown in interface java.util.concurrent.ExecutorService
      • isTerminated

        public boolean isTerminated()
        Specified by:
        isTerminated in interface java.util.concurrent.ExecutorService
      • awaitTermination

        public boolean awaitTermination​(long timeout,
                                        java.util.concurrent.TimeUnit unit)
                                 throws java.lang.InterruptedException
        Specified by:
        awaitTermination in interface java.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)
                                                                     throws java.lang.InterruptedException
        Specified by:
        invokeAll in interface java.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 interface java.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 interface java.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 interface java.util.concurrent.ExecutorService
        Throws:
        java.lang.InterruptedException
        java.util.concurrent.ExecutionException
        java.util.concurrent.TimeoutException
      • execute

        public void execute​(java.lang.Runnable command)
        Specified by:
        execute in interface java.util.concurrent.Executor