Package org.copperengine.core.common
Class AbstractProcessingEngine
- java.lang.Object
-
- org.copperengine.core.common.AbstractProcessingEngine
-
- All Implemented Interfaces:
ProcessingEngine
,org.copperengine.management.ProcessingEngineMXBean
- Direct Known Subclasses:
PersistentScottyEngine
,TransientScottyEngine
public abstract class AbstractProcessingEngine extends java.lang.Object implements ProcessingEngine, org.copperengine.management.ProcessingEngineMXBean
Abstract base implementation of the COPPERProcessingEngine
interface.
-
-
Field Summary
Fields Modifier and Type Field Description protected DependencyInjector
dependencyInjector
protected EngineState
engineState
protected Blocker
startupBlocker
protected java.util.Date
startupTS
protected RuntimeStatisticsCollector
statisticsCollector
protected WorkflowRepository
wfRepository
-
Constructor Summary
Constructors Constructor Description AbstractProcessingEngine()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
addShutdownObserver(java.lang.Runnable observer)
Adds a shutdown observer/hook to the engine.protected org.copperengine.management.model.WorkflowInfo
convert2Wfi(Workflow<?> wf)
protected long
count(org.copperengine.management.model.WorkflowInstanceFilter filter, java.util.Collection<Workflow<?>> workflowInstances)
java.lang.String
createUUID()
<E> WorkflowFactory<E>
createWorkflowFactory(java.lang.String classname)
protected Workflow<java.lang.Object>
createWorkflowInstance(WorkflowInstanceDescr<?> wfInstanceDescr)
protected java.util.List<org.copperengine.management.model.WorkflowInfo>
filter(org.copperengine.management.model.WorkflowInstanceFilter filter, java.util.Collection<Workflow<?>> workflowInstances)
java.lang.String
getDependencyInjectorType()
long
getDequeuedCount()
java.lang.String
getEngineId()
returns the engines idEngineState
getEngineState()
returns the engines current statelong
getErrorCount()
long
getFinishedCount()
long
getInvalidCount()
long
getRunningCount()
RuntimeStatisticsCollector
getStatisticsCollector()
java.lang.String
getStatisticsCollectorType()
long
getWaitingCount()
WorkflowRepository
getWfRepository()
org.copperengine.management.WorkflowRepositoryMXBean
getWorkflowRepository()
void
injectDependencies(Workflow<?> wf)
org.copperengine.management.model.EngineActivity
queryEngineActivity(int minutesInHistory)
java.lang.String
run(java.lang.String wfname, java.lang.Object data)
Enqueues the specified workflow instance into the engine for execution.protected abstract void
run(java.util.List<Workflow<?>> w)
protected abstract java.lang.String
run(Workflow<?> w)
java.lang.String
run(WorkflowInstanceDescr<?> wfInstanceDescr)
Enqueues the specified workflow instance description into the engine for execution.void
runBatch(java.util.List<WorkflowInstanceDescr<?>> wfInstanceDescr)
Enqueues the specified batch of workflow instance descriptions into the engine for execution.void
setDependencyInjector(DependencyInjector dependencyInjector)
void
setEngineIdProvider(EngineIdProvider engineIdProvider)
void
setIdFactory(IdFactory idFactory)
void
setStatisticsCollector(RuntimeStatisticsCollector statisticsCollector)
void
setWfRepository(WorkflowRepository wfRepository)
void
shutdown()
Triggers the shutdown of the engine.void
startup()
Starts up the engine.protected void
trackActivity()
protected void
trackWfiStarted()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.copperengine.core.ProcessingEngine
addWaitHook, notify, registerCallbacks
-
Methods inherited from interface org.copperengine.management.ProcessingEngineMXBean
countWorkflowInstances, getEngineType, getNumberOfWorkflowInstances, getProcessorPools, getState, getWorkflowInstanceStates, queryActiveWorkflowInstance, queryActiveWorkflowInstances, queryObjectState, queryWorkflowInstance, queryWorkflowInstances, queryWorkflowInstances
-
-
-
-
Field Detail
-
wfRepository
protected WorkflowRepository wfRepository
-
engineState
protected volatile EngineState engineState
-
startupBlocker
protected Blocker startupBlocker
-
statisticsCollector
protected RuntimeStatisticsCollector statisticsCollector
-
dependencyInjector
protected DependencyInjector dependencyInjector
-
startupTS
protected java.util.Date startupTS
-
-
Method Detail
-
setStatisticsCollector
public void setStatisticsCollector(RuntimeStatisticsCollector statisticsCollector)
-
getStatisticsCollector
public RuntimeStatisticsCollector getStatisticsCollector()
-
getStatisticsCollectorType
public java.lang.String getStatisticsCollectorType()
- Specified by:
getStatisticsCollectorType
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
setDependencyInjector
public void setDependencyInjector(DependencyInjector dependencyInjector)
-
getDependencyInjectorType
public java.lang.String getDependencyInjectorType()
- Specified by:
getDependencyInjectorType
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
getEngineState
public EngineState getEngineState()
Description copied from interface:ProcessingEngine
returns the engines current state- Specified by:
getEngineState
in interfaceProcessingEngine
- Returns:
- the engine state
-
setEngineIdProvider
public void setEngineIdProvider(EngineIdProvider engineIdProvider)
-
getEngineId
public java.lang.String getEngineId()
Description copied from interface:ProcessingEngine
returns the engines id- Specified by:
getEngineId
in interfaceProcessingEngine
- Specified by:
getEngineId
in interfaceorg.copperengine.management.ProcessingEngineMXBean
- Returns:
- the engine id
-
setIdFactory
public final void setIdFactory(IdFactory idFactory)
-
createUUID
public final java.lang.String createUUID()
- Specified by:
createUUID
in interfaceProcessingEngine
- Returns:
- Creates and returns a Universally Unique Identifier (UUID). The UUID may be used for workflow ids or correlation ids.
-
setWfRepository
public void setWfRepository(WorkflowRepository wfRepository)
-
getWfRepository
public WorkflowRepository getWfRepository()
-
createWorkflowFactory
public final <E> WorkflowFactory<E> createWorkflowFactory(java.lang.String classname) throws java.lang.ClassNotFoundException
- Throws:
java.lang.ClassNotFoundException
-
addShutdownObserver
public void addShutdownObserver(java.lang.Runnable observer)
Description copied from interface:ProcessingEngine
Adds a shutdown observer/hook to the engine. During shutdown of the engine,Runnable.run()
of each registered observer is called subsequently.- Specified by:
addShutdownObserver
in interfaceProcessingEngine
- Parameters:
observer
- the observer/hook to add
-
startup
public void startup()
Description copied from interface:ProcessingEngine
Starts up the engine. The invocation of this method blocks until the startup procedure is finished. This method might even throw an Error, if something fundamentally wents wrong like starting up the workflow repository or database storage.- Specified by:
startup
in interfaceProcessingEngine
-
shutdown
public void shutdown() throws CopperRuntimeException
Description copied from interface:ProcessingEngine
Triggers the shutdown of the engine. The engine tries to end running workflow instances gracefully. The invocation of this method returns immediately.- Specified by:
shutdown
in interfaceProcessingEngine
- Throws:
CopperRuntimeException
- - wraps Exceptions which could happen in different types of configured engines into RuntimeExceptions. Further RuntimeExceptions like IllegalStateException might also be thrown.
-
convert2Wfi
protected org.copperengine.management.model.WorkflowInfo convert2Wfi(Workflow<?> wf)
-
run
protected abstract java.lang.String run(Workflow<?> w) throws CopperException
- Throws:
CopperException
-
run
protected abstract void run(java.util.List<Workflow<?>> w) throws CopperException
- Throws:
CopperException
-
run
public java.lang.String run(java.lang.String wfname, java.lang.Object data) throws CopperException
Description copied from interface:ProcessingEngine
Enqueues the specified workflow instance into the engine for execution.- Specified by:
run
in interfaceProcessingEngine
- Parameters:
wfname
- name or alias of the workflows classdata
- the data to pass to the workflow- Returns:
- workflow instance Id
- Throws:
CopperException
- if the engine can not run the workflow for some reason, e.g. in case of an unknown processor pool id.
-
run
public java.lang.String run(WorkflowInstanceDescr<?> wfInstanceDescr) throws CopperException
Description copied from interface:ProcessingEngine
Enqueues the specified workflow instance description into the engine for execution.- Specified by:
run
in interfaceProcessingEngine
- Parameters:
wfInstanceDescr
- the workflow instance description out of which a workflow is generated and put into the engine for execution- Returns:
- workflow instance Id
- Throws:
CopperException
- if the engine can not run the workflow for some reason, e.g. in case of an unknown processor pool id.
-
createWorkflowInstance
protected Workflow<java.lang.Object> createWorkflowInstance(WorkflowInstanceDescr<?> wfInstanceDescr) throws java.lang.InstantiationException, java.lang.IllegalAccessException, java.lang.ClassNotFoundException
- Throws:
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException
-
runBatch
public void runBatch(java.util.List<WorkflowInstanceDescr<?>> wfInstanceDescr) throws CopperException
Description copied from interface:ProcessingEngine
Enqueues the specified batch of workflow instance descriptions into the engine for execution.- Specified by:
runBatch
in interfaceProcessingEngine
- Parameters:
wfInstanceDescr
- batch or workflow instance descriptions to be put into the engine for execution- Throws:
CopperException
- if the engine can not run the workflows for some reason, e.g. in case of an unknown processor pool id.
-
getWorkflowRepository
public org.copperengine.management.WorkflowRepositoryMXBean getWorkflowRepository()
- Specified by:
getWorkflowRepository
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
injectDependencies
public void injectDependencies(Workflow<?> wf)
-
trackActivity
protected void trackActivity()
-
trackWfiStarted
protected void trackWfiStarted()
-
queryEngineActivity
public org.copperengine.management.model.EngineActivity queryEngineActivity(int minutesInHistory)
- Specified by:
queryEngineActivity
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
filter
protected java.util.List<org.copperengine.management.model.WorkflowInfo> filter(org.copperengine.management.model.WorkflowInstanceFilter filter, java.util.Collection<Workflow<?>> workflowInstances)
-
getInvalidCount
public long getInvalidCount()
- Specified by:
getInvalidCount
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
getErrorCount
public long getErrorCount()
- Specified by:
getErrorCount
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
getDequeuedCount
public long getDequeuedCount()
- Specified by:
getDequeuedCount
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
getRunningCount
public long getRunningCount()
- Specified by:
getRunningCount
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
getFinishedCount
public long getFinishedCount()
- Specified by:
getFinishedCount
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
getWaitingCount
public long getWaitingCount()
- Specified by:
getWaitingCount
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
count
protected long count(org.copperengine.management.model.WorkflowInstanceFilter filter, java.util.Collection<Workflow<?>> workflowInstances)
-
-