Package lumis.portal.structure.sync
Class ParallelExecutor
- java.lang.Object
-
- lumis.portal.structure.sync.ParallelExecutor
-
public class ParallelExecutor extends 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: 21880 $ $Date: 2018-09-21 17:07:19 -0300 (Fri, 21 Sep 2018) $
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ParallelExecutor.IDatabaseTask
A task that executes some operation in the database.static interface
ParallelExecutor.ITransactionFactory
ProvidesITransaction
instances.
-
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, 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(Runnable task)
Submits a general task for future execution.void
submit(ParallelExecutor.IDatabaseTask task)
Submits a database task for future execution.
-
-
-
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, 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(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
-
-