Class ParallelExecutor


  • public class ParallelExecutor
    extends java.lang.Object
    Receives submissions of tasks to be executed in parallel.

    There are two queue of tasks. One queue for database tasks and other queue for non-database tasks. Tasks of type ParallelExecutor.IDatabaseTask that are submitted enter the database tasks queue, the others enter the non-database tasks queue. Each queue is processed in FIFO order, but independently of each other.

    Since:
    6.2.0
    Version:
    $Revision$ $Date$
    • Constructor Summary

      Constructors 
      Constructor Description
      ParallelExecutor​(int numGeneralThreads, int numDbThreads, ParallelExecutor.ITransactionFactory transactionFactory)
      Constructs a parallel executor with independent transaction for each database task.
      ParallelExecutor​(int numGeneralThreads, java.lang.String processId, ITransaction singleTransaction)
      Constructs a parallel executor with a single transaction for all database tasks.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void awaitExecutions()
      Pauses until all pending tasks complete execution.
      void awaitExecutions​(boolean flushAndClearSession)
      Pauses until all pending tasks complete execution.
      void shutdown()
      Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted.
      void submit​(java.lang.Runnable task)
      Submits a general task for future execution.
      void submit​(ParallelExecutor.IDatabaseTask task)
      Submits a database task for future execution.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ParallelExecutor

        public ParallelExecutor​(int numGeneralThreads,
                                int numDbThreads,
                                ParallelExecutor.ITransactionFactory transactionFactory)
        Constructs a parallel executor with independent transaction for each database task.
        Parameters:
        numGeneralThreads - the number of threads for executing general tasks.
        numDbThreads - the number of threads for executing database tasks.
        transactionFactory - the transaction factory used to obtain transaction for each database task.
        Since:
        6.2.0
      • ParallelExecutor

        public ParallelExecutor​(int numGeneralThreads,
                                java.lang.String processId,
                                ITransaction singleTransaction)
        Constructs a parallel executor with a single transaction for all database tasks.
        Parameters:
        numGeneralThreads - the number of threads for executing general tasks.
        singleTransaction - the transaction to be used for the database tasks.
        processId - the process identification of the operation.
        Since:
        6.2.0
    • Method Detail

      • shutdown

        public void shutdown()
        Initiates an orderly shutdown in which previously submitted tasks are executed, but no new tasks will be accepted. Invocation has no additional effect if already shut down.
        Since:
        6.2.0
      • awaitExecutions

        public void awaitExecutions()
                             throws PortalException
        Pauses until all pending tasks complete execution.
        Throws:
        PortalException
        Since:
        6.2.0
      • awaitExecutions

        public void awaitExecutions​(boolean flushAndClearSession)
                             throws PortalException
        Pauses until all pending tasks complete execution.
        Throws:
        PortalException
        Since:
        6.2.0
      • submit

        public void submit​(java.lang.Runnable task)
        Submits a general task for future execution.
        Parameters:
        task - the task.
        Since:
        6.2.0
      • submit

        public void submit​(ParallelExecutor.IDatabaseTask task)
        Submits a database task for future execution.
        Parameters:
        task - the database task.
        Since:
        6.2.0