Package org.copperengine.core.common
Class PriorityProcessorPool
- java.lang.Object
-
- org.copperengine.core.common.PriorityProcessorPool
-
- All Implemented Interfaces:
ProcessorPool
,org.copperengine.management.ProcessorPoolMXBean
- Direct Known Subclasses:
PersistentPriorityProcessorPool
,TransientPriorityProcessorPool
public abstract class PriorityProcessorPool extends java.lang.Object implements ProcessorPool, org.copperengine.management.ProcessorPoolMXBean
AProcessorPool
implementation using a priority queue.
-
-
Field Summary
Fields Modifier and Type Field Description protected ProcessorFactory
processorFactory
protected SuspendableQueue<Workflow<?>>
queue
-
Constructor Summary
Constructors Constructor Description PriorityProcessorPool()
Creates a newPriorityProcessorPool
with as many worker threads as processors available on the corresponding environment.PriorityProcessorPool(java.lang.String id)
Creates a newPriorityProcessorPool
with as many worker threads as processors available on the corresponding environment.PriorityProcessorPool(java.lang.String id, int numberOfThreads)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.util.Queue<Workflow<?>>
createQueue()
Creates a new instance ofWfPriorityQueue
protected ProcessingEngine
getEngine()
java.lang.String
getId()
int
getMemoryQueueSize()
int
getNumberOfActiveThreads()
int
getNumberOfThreads()
java.lang.String
getProcessorPoolState()
ProcessorPoolState
getState()
int
getThreadPriority()
void
resume()
Resume processing of workflowsvoid
setEngine(ProcessingEngine engine)
Called internally by COPPER during initializationvoid
setId(java.lang.String id)
void
setNumberOfThreads(int numberOfThreads)
void
setProcessorFactory(ProcessorFactory processorFactory)
void
setShutdownWaitIntervalMSec(int shutdownWaitIntervalMSec)
This processor pool wait up to the specified number of milliseconds until all of its Processors are terminated.void
setThreadPriority(int threadPriority)
void
shutdown()
Shuts down the processor poolvoid
startup()
Starts up the processor poolvoid
suspend()
Suspend processing of workflows.
-
-
-
Field Detail
-
queue
protected final SuspendableQueue<Workflow<?>> queue
-
processorFactory
protected ProcessorFactory processorFactory
-
-
Constructor Detail
-
PriorityProcessorPool
public PriorityProcessorPool()
Creates a newPriorityProcessorPool
with as many worker threads as processors available on the corresponding environment.id
needs to be initialized later using the setter.
-
PriorityProcessorPool
public PriorityProcessorPool(java.lang.String id)
Creates a newPriorityProcessorPool
with as many worker threads as processors available on the corresponding environment.- Parameters:
id
- id for the new created pool. Must be unique and shall not be longer than 32 characters which is the limit to be stored for the processor pool ids when using persistent engines.
-
PriorityProcessorPool
public PriorityProcessorPool(java.lang.String id, int numberOfThreads)
-
-
Method Detail
-
createQueue
protected java.util.Queue<Workflow<?>> createQueue()
Creates a new instance ofWfPriorityQueue
- Returns:
- the new created instance.
-
setShutdownWaitIntervalMSec
public void setShutdownWaitIntervalMSec(int shutdownWaitIntervalMSec)
This processor pool wait up to the specified number of milliseconds until all of its Processors are terminated. A value ≤ 0 means, that the processor pool will not wait at all.- Parameters:
shutdownWaitIntervalMSec
- wait interval in milliseconds
-
setEngine
public void setEngine(ProcessingEngine engine)
Description copied from interface:ProcessorPool
Called internally by COPPER during initialization- Specified by:
setEngine
in interfaceProcessorPool
- Parameters:
engine
- engine which holds the ProcessorPool
-
setId
public void setId(java.lang.String id)
-
setNumberOfThreads
public void setNumberOfThreads(int numberOfThreads)
- Specified by:
setNumberOfThreads
in interfaceorg.copperengine.management.ProcessorPoolMXBean
-
getNumberOfThreads
public int getNumberOfThreads()
- Specified by:
getNumberOfThreads
in interfaceorg.copperengine.management.ProcessorPoolMXBean
-
setThreadPriority
public void setThreadPriority(int threadPriority)
- Specified by:
setThreadPriority
in interfaceorg.copperengine.management.ProcessorPoolMXBean
-
getThreadPriority
public int getThreadPriority()
- Specified by:
getThreadPriority
in interfaceorg.copperengine.management.ProcessorPoolMXBean
-
getId
public java.lang.String getId()
- Specified by:
getId
in interfaceProcessorPool
- Specified by:
getId
in interfaceorg.copperengine.management.ProcessorPoolMXBean
- Returns:
- the processor pools identifier
-
shutdown
public void shutdown()
Description copied from interface:ProcessorPool
Shuts down the processor pool- Specified by:
shutdown
in interfaceProcessorPool
-
startup
public void startup()
Description copied from interface:ProcessorPool
Starts up the processor pool- Specified by:
startup
in interfaceProcessorPool
-
getEngine
protected ProcessingEngine getEngine()
-
getMemoryQueueSize
public int getMemoryQueueSize()
- Specified by:
getMemoryQueueSize
in interfaceorg.copperengine.management.ProcessorPoolMXBean
-
resume
public void resume()
Description copied from interface:ProcessorPool
Resume processing of workflows- Specified by:
resume
in interfaceProcessorPool
- Specified by:
resume
in interfaceorg.copperengine.management.ProcessorPoolMXBean
-
suspend
public void suspend()
Description copied from interface:ProcessorPool
Suspend processing of workflows.- Specified by:
suspend
in interfaceProcessorPool
- Specified by:
suspend
in interfaceorg.copperengine.management.ProcessorPoolMXBean
-
setProcessorFactory
public void setProcessorFactory(ProcessorFactory processorFactory)
-
getProcessorPoolState
public java.lang.String getProcessorPoolState()
- Specified by:
getProcessorPoolState
in interfaceorg.copperengine.management.ProcessorPoolMXBean
-
getState
public ProcessorPoolState getState()
-
getNumberOfActiveThreads
public int getNumberOfActiveThreads()
- Specified by:
getNumberOfActiveThreads
in interfaceorg.copperengine.management.ProcessorPoolMXBean
-
-