Class GraphThreadPoolExecutor<T>

  • All Implemented Interfaces:
    java.util.concurrent.Executor, java.util.concurrent.ExecutorService, ITestNGThreadPoolExecutor

    public class GraphThreadPoolExecutor<T>
    extends java.util.concurrent.ThreadPoolExecutor
    implements ITestNGThreadPoolExecutor
    An Executor that launches tasks per batches. It takes a DynamicGraph of tasks to be run and a IThreadWorkerFactory to initialize/create Runnable wrappers around those tasks
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      private class  GraphThreadPoolExecutor.PhoneyWorker  
      • Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor

        java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
    • Constructor Summary

      Constructors 
      Constructor Description
      GraphThreadPoolExecutor​(java.lang.String name, IDynamicGraph<T> graph, IThreadWorkerFactory<T> factory, int corePoolSize, int maximumPoolSize, long keepAliveTime, java.util.concurrent.TimeUnit unit, java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue, java.util.Comparator<T> comparator)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterExecute​(java.lang.Runnable r, java.lang.Throwable t)  
      private IDynamicGraph.Status computeStatus​(java.lang.Runnable r)  
      private void handleThreadAffinity​(java.util.List<T> freeNodes)  
      private void mapNodeToParent​(java.util.List<T> freeNodes)  
      private void mapNodeToWorker​(java.util.List<IWorker<T>> runnables, java.util.List<T> freeNodes)  
      void run()
      Helps kick start the execution and is the point of entry for execution.
      private void runNodes​(java.util.List<T> freeNodes)
      Create one worker per node and execute them.
      private void setStatus​(IWorker<T> worker, IDynamicGraph.Status status)  
      • Methods inherited from class java.util.concurrent.ThreadPoolExecutor

        allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, beforeExecute, execute, finalize, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getQueue, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, remove, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory, shutdown, shutdownNow, terminated, toString
      • Methods inherited from class java.util.concurrent.AbstractExecutorService

        invokeAll, invokeAll, invokeAny, invokeAny, newTaskFor, newTaskFor, submit, submit, submit
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.concurrent.Executor

        execute
      • Methods inherited from interface java.util.concurrent.ExecutorService

        awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow, submit, submit, submit
    • Field Detail

      • mapping

        private final java.util.Map<T,​IWorker<T>> mapping
      • upstream

        private final java.util.Map<T,​T> upstream
      • m_comparator

        private final java.util.Comparator<T> m_comparator
    • Constructor Detail

      • GraphThreadPoolExecutor

        public GraphThreadPoolExecutor​(java.lang.String name,
                                       IDynamicGraph<T> graph,
                                       IThreadWorkerFactory<T> factory,
                                       int corePoolSize,
                                       int maximumPoolSize,
                                       long keepAliveTime,
                                       java.util.concurrent.TimeUnit unit,
                                       java.util.concurrent.BlockingQueue<java.lang.Runnable> workQueue,
                                       java.util.Comparator<T> comparator)
    • Method Detail

      • runNodes

        private void runNodes​(java.util.List<T> freeNodes)
        Create one worker per node and execute them.
      • afterExecute

        public void afterExecute​(java.lang.Runnable r,
                                 java.lang.Throwable t)
        Overrides:
        afterExecute in class java.util.concurrent.ThreadPoolExecutor
      • mapNodeToWorker

        private void mapNodeToWorker​(java.util.List<IWorker<T>> runnables,
                                     java.util.List<T> freeNodes)
      • mapNodeToParent

        private void mapNodeToParent​(java.util.List<T> freeNodes)
      • handleThreadAffinity

        private void handleThreadAffinity​(java.util.List<T> freeNodes)