lumis.portal.structure.sync
Class ParallelExecutor

Package class diagram package ParallelExecutor
java.lang.Object
  extended by 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

Nested Class Summary
static interface ParallelExecutor.IDatabaseTask
          A task that executes some operation in the database.
static interface ParallelExecutor.ITransactionFactory
          Provides ITransaction instances.
 
Constructor Summary
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
 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(ParallelExecutor.IDatabaseTask task)
          Submits a database task for future execution.
 void submit(Runnable task)
          Submits a general 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,
                        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()
Pauses until all pending tasks complete execution.

Since:
6.2.0

awaitExecutions

public void awaitExecutions(boolean flushAndClearSession)
Pauses until all pending tasks complete execution.

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


Lumisportal  6.2.0.120405 - Copyright © 2006–2012 Lumis EIP Tecnologia da Informação LTDA. All Rights Reserved.