Package org.copperengine.core.persistent
Class PersistentScottyEngine
- java.lang.Object
-
- org.copperengine.core.common.AbstractProcessingEngine
-
- org.copperengine.core.persistent.PersistentScottyEngine
-
- All Implemented Interfaces:
PersistentProcessingEngine
,ProcessingEngine
,org.copperengine.management.PersistentProcessingEngineMXBean
,org.copperengine.management.ProcessingEngineMXBean
public class PersistentScottyEngine extends AbstractProcessingEngine implements PersistentProcessingEngine, org.copperengine.management.PersistentProcessingEngineMXBean
COPPER processing engine that offers persistent workflow processing.
-
-
Field Summary
-
Fields inherited from class org.copperengine.core.common.AbstractProcessingEngine
dependencyInjector, engineState, startupBlocker, startupTS, statisticsCollector, wfRepository
-
-
Constructor Summary
Constructors Constructor Description PersistentScottyEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addWaitHook(java.lang.String wfInstanceId, WaitHook waitHook)
Adds the specified WaitHook for the workflow instance with the specified id.protected org.copperengine.management.model.WorkflowInfo
convert2Wfi(Workflow<?> wf)
long
countWorkflowInstances(org.copperengine.management.model.WorkflowInstanceFilter filter)
void
deleteBroken(java.lang.String workflowInstanceId)
void
deleteFiltered(org.copperengine.management.model.WorkflowInstanceFilter filter)
void
deleteWaiting(java.lang.String workflowInstanceId)
ScottyDBStorageInterface
getDbStorage()
org.copperengine.management.DBStorageMXBean
getDBStorage()
java.lang.String
getEngineClusterId()
org.copperengine.management.model.EngineType
getEngineType()
int
getNumberOfWorkflowInstances()
java.util.List<org.copperengine.management.ProcessorPoolMXBean>
getProcessorPools()
java.lang.String
getState()
java.util.List<java.lang.String>
getWorkflowInstanceStates()
void
notify(java.util.List<Response<?>> responses, java.sql.Connection c)
Adds a list of responses to the engine, using the provided jdbc connection.void
notify(Response<?> response, java.sql.Connection c)
Adds a response to the engine, using the provided jdbc connection.void
notify(Response<?> response, Acknowledge ack)
Adds a response to the engine.org.copperengine.management.model.WorkflowInfo
queryActiveWorkflowInstance(java.lang.String id)
java.util.List<org.copperengine.management.model.WorkflowInfo>
queryActiveWorkflowInstances(java.lang.String className, int max)
java.lang.String
queryObjectState(java.lang.String id)
org.copperengine.management.model.WorkflowInfo
queryWorkflowInstance(java.lang.String id)
java.util.List<org.copperengine.management.model.WorkflowInfo>
queryWorkflowInstances()
java.util.List<org.copperengine.management.model.WorkflowInfo>
queryWorkflowInstances(org.copperengine.management.model.WorkflowInstanceFilter filter)
void
registerCallbacks(Workflow<?> w, WaitMode mode, long timeoutMsec, java.lang.String... correlationIds)
Registers a workflow instance to we waiting for a number of correlation ids.void
restart(java.lang.String workflowInstanceId)
Trigger restart a workflow instance that is in the error state.void
restartAll()
Trigger restart of all workflow instances that are in error state.void
restartFiltered(org.copperengine.management.model.WorkflowInstanceFilter filter)
void
run(java.util.List<Workflow<?>> list)
void
run(java.util.List<Workflow<?>> list, java.sql.Connection con)
Enqueues the specified list of workflow instances into the engine for execution.protected java.lang.String
run(Workflow<?> wf)
java.lang.String
run(Workflow<?> wf, java.sql.Connection con)
Enqueues the specified workflow instance into the engine for execution.java.lang.String
run(WorkflowInstanceDescr<?> wfInstanceDescr, java.sql.Connection con)
Enqueues the workflow instance into the engine for execution.void
runBatch(java.util.List<WorkflowInstanceDescr<?>> wfInstanceDescr, java.sql.Connection con)
Enqueues the specified list of workflow instances into the engine for execution.void
setDbStorage(ScottyDBStorageInterface dbStorage)
void
setEngineClusterId(java.lang.String engineClusterId)
Sets engineClusterId for make it possible to group engines into engine cluster.void
setNotifyProcessorPoolsOnResponse(boolean notifyProcessorPoolsOnResponse)
Deprecated.without effect - will be removed in future releasevoid
setProcessorPoolManager(ProcessorPoolManager<? extends PersistentProcessorPool> processorPoolManager)
void
shutdown()
Triggers the shutdown of the engine.void
startup()
Starts up the engine.-
Methods inherited from class org.copperengine.core.common.AbstractProcessingEngine
addShutdownObserver, count, createUUID, createWorkflowFactory, createWorkflowInstance, filter, getDependencyInjectorType, getDequeuedCount, getEngineId, getEngineState, getErrorCount, getFinishedCount, getInvalidCount, getRunningCount, getStatisticsCollector, getStatisticsCollectorType, getWaitingCount, getWfRepository, getWorkflowRepository, injectDependencies, queryEngineActivity, run, run, runBatch, setDependencyInjector, setEngineIdProvider, setIdFactory, setStatisticsCollector, setWfRepository, trackActivity, 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
addShutdownObserver, createUUID, getEngineId, getEngineState, run, run, runBatch
-
-
-
-
Method Detail
-
setNotifyProcessorPoolsOnResponse
@Deprecated public void setNotifyProcessorPoolsOnResponse(boolean notifyProcessorPoolsOnResponse)
Deprecated.without effect - will be removed in future release- Parameters:
notifyProcessorPoolsOnResponse
- specify if processor pools shall be notified on response
-
setDbStorage
public void setDbStorage(ScottyDBStorageInterface dbStorage)
-
getDbStorage
public ScottyDBStorageInterface getDbStorage()
-
setProcessorPoolManager
public void setProcessorPoolManager(ProcessorPoolManager<? extends PersistentProcessorPool> processorPoolManager)
-
notify
public void notify(Response<?> response, Acknowledge ack)
Description copied from interface:ProcessingEngine
Adds a response to the engine. The engine will subsequently try to find the corresponding workflow instance that is waiting for the response. Depending on the workflow instances waitmode and the number of open responses, the workflow may or may not be resumed.- Specified by:
notify
in interfaceProcessingEngine
- Parameters:
response
- the reponseack
- the object to notify upon processing of the message. Note: The ack.waitForAcknowledge returns when the response is processed by the COPPER engine, not when the workflow was waked up with this response.
-
shutdown
public void shutdown()
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
- Overrides:
shutdown
in classAbstractProcessingEngine
-
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
- Overrides:
startup
in classAbstractProcessingEngine
-
registerCallbacks
public void registerCallbacks(Workflow<?> w, WaitMode mode, long timeoutMsec, java.lang.String... correlationIds)
Description copied from interface:ProcessingEngine
Registers a workflow instance to we waiting for a number of correlation ids.- Specified by:
registerCallbacks
in interfaceProcessingEngine
- Parameters:
w
- the workflow instance waiting for one or more responsemode
- the wait modetimeoutMsec
- the relative timeout in milliseconds or0
for no an infinite timeoutcorrelationIds
- the correlation ids of the expected responses
-
run
protected java.lang.String run(Workflow<?> wf) throws CopperException
- Specified by:
run
in classAbstractProcessingEngine
- Throws:
CopperException
-
run
public void run(java.util.List<Workflow<?>> list) throws CopperException
- Specified by:
run
in classAbstractProcessingEngine
- Throws:
CopperException
-
run
public void run(java.util.List<Workflow<?>> list, java.sql.Connection con) throws CopperException
Enqueues the specified list of workflow instances into the engine for execution.- Parameters:
list
- the list of workflow instances to runcon
- connection used for the inserting the workflow to the database- Throws:
CopperException
- if the engine can not run the workflow, e.g. in case of a unkown processor pool id
-
run
public java.lang.String run(Workflow<?> wf, java.sql.Connection con) throws CopperException
Enqueues the specified workflow instance into the engine for execution.- Parameters:
wf
- the workflow instance to runcon
- connection used for the inserting the workflow to the database- Returns:
- workflow id
- Throws:
CopperException
- if the engine can not run the workflow, e.g. in case of a unknown processor pool id
-
restart
public void restart(java.lang.String workflowInstanceId) throws java.lang.Exception
Description copied from interface:PersistentProcessingEngine
Trigger restart a workflow instance that is in the error state.- Specified by:
restart
in interfacePersistentProcessingEngine
- Specified by:
restart
in interfaceorg.copperengine.management.PersistentProcessingEngineMXBean
- Parameters:
workflowInstanceId
- id of workflow which shall be restarted- Throws:
java.lang.Exception
- any exception happening on this request, like sql connection lost. Note: If id doesn't exist or the workflow with this id is not in error/invalid-state, this method just returns with doing nothing.
-
getState
public java.lang.String getState()
- Specified by:
getState
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
queryWorkflowInstance
public org.copperengine.management.model.WorkflowInfo queryWorkflowInstance(java.lang.String id)
- Specified by:
queryWorkflowInstance
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
getNumberOfWorkflowInstances
public int getNumberOfWorkflowInstances()
- Specified by:
getNumberOfWorkflowInstances
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
restartAll
public void restartAll() throws java.lang.Exception
Description copied from interface:PersistentProcessingEngine
Trigger restart of all workflow instances that are in error state.- Specified by:
restartAll
in interfacePersistentProcessingEngine
- Specified by:
restartAll
in interfaceorg.copperengine.management.PersistentProcessingEngineMXBean
- Throws:
java.lang.Exception
-PersistentProcessingEngine.restart(String)
.
-
restartFiltered
public void restartFiltered(org.copperengine.management.model.WorkflowInstanceFilter filter) throws java.lang.Exception
- Specified by:
restartFiltered
in interfacePersistentProcessingEngine
- Specified by:
restartFiltered
in interfaceorg.copperengine.management.PersistentProcessingEngineMXBean
- Throws:
java.lang.Exception
-
deleteBroken
public void deleteBroken(java.lang.String workflowInstanceId) throws java.lang.Exception
- Specified by:
deleteBroken
in interfaceorg.copperengine.management.PersistentProcessingEngineMXBean
- Throws:
java.lang.Exception
-
deleteWaiting
public void deleteWaiting(java.lang.String workflowInstanceId) throws java.lang.Exception
- Specified by:
deleteWaiting
in interfaceorg.copperengine.management.PersistentProcessingEngineMXBean
- Throws:
java.lang.Exception
-
deleteFiltered
public void deleteFiltered(org.copperengine.management.model.WorkflowInstanceFilter filter) throws java.lang.Exception
- Specified by:
deleteFiltered
in interfaceorg.copperengine.management.PersistentProcessingEngineMXBean
- Throws:
java.lang.Exception
-
run
public java.lang.String run(WorkflowInstanceDescr<?> wfInstanceDescr, java.sql.Connection con) throws CopperException
Description copied from interface:PersistentProcessingEngine
Enqueues the workflow instance into the engine for execution.- Specified by:
run
in interfacePersistentProcessingEngine
- Parameters:
wfInstanceDescr
- workflow instance descriptions to runcon
- connection used for the inserting the workflow to the database- Returns:
- workflow instance ID
- Throws:
CopperException
- if the engine can not run the workflow, e.g. in case of a unknown processor pool id
-
runBatch
public void runBatch(java.util.List<WorkflowInstanceDescr<?>> wfInstanceDescr, java.sql.Connection con) throws CopperException
Description copied from interface:PersistentProcessingEngine
Enqueues the specified list of workflow instances into the engine for execution.- Specified by:
runBatch
in interfacePersistentProcessingEngine
- Parameters:
wfInstanceDescr
- the list of workflow instance descriptions to runcon
- connection used for the inserting the workflow to the database- Throws:
CopperException
- if the engine can not run the workflow, e.g. in case of a unknown processor pool id
-
notify
public void notify(Response<?> response, java.sql.Connection c) throws CopperRuntimeException
Description copied from interface:PersistentProcessingEngine
Adds a response to the engine, using the provided jdbc connection. The engine will subsequently try to find the corresponding workflow instance that is waiting for the response. Depending on the workflow instances waitmode and the number of open responses, the workflow may or may not be resumed.- Specified by:
notify
in interfacePersistentProcessingEngine
- Parameters:
response
- the reponsec
- jdbc connection to use- Throws:
CopperRuntimeException
- any exception occuring in this operation (Like SQL connection lost) will be wrapped into this exception.
-
notify
public void notify(java.util.List<Response<?>> responses, java.sql.Connection c) throws CopperRuntimeException
Description copied from interface:PersistentProcessingEngine
Adds a list of responses to the engine, using the provided jdbc connection. The engine will subsequently try to find the corresponding workflow instance that is waiting for the response. Depending on the workflow instances waitmode and the number of open responses, the workflow may or may not be resumed.- Specified by:
notify
in interfacePersistentProcessingEngine
- Parameters:
responses
- the list of reponsesc
- jdbc connection to use- Throws:
CopperRuntimeException
- any exception occuring in this operation (Like SQL connection lost) will be wrapped into this exception.
-
addWaitHook
public void addWaitHook(java.lang.String wfInstanceId, WaitHook waitHook)
Description copied from interface:ProcessingEngine
Adds the specified WaitHook for the workflow instance with the specified id. The WaitHook is called once at the next wait invocation of the specified workflow instance.- Specified by:
addWaitHook
in interfaceProcessingEngine
- Parameters:
wfInstanceId
- workflow instance idwaitHook
- wait hook
-
getProcessorPools
public java.util.List<org.copperengine.management.ProcessorPoolMXBean> getProcessorPools()
- Specified by:
getProcessorPools
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
getEngineType
public org.copperengine.management.model.EngineType getEngineType()
- Specified by:
getEngineType
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
getDBStorage
public org.copperengine.management.DBStorageMXBean getDBStorage()
- Specified by:
getDBStorage
in interfaceorg.copperengine.management.PersistentProcessingEngineMXBean
-
getEngineClusterId
public java.lang.String getEngineClusterId()
- Specified by:
getEngineClusterId
in interfaceorg.copperengine.management.PersistentProcessingEngineMXBean
-
setEngineClusterId
public void setEngineClusterId(java.lang.String engineClusterId)
Sets engineClusterId for make it possible to group engines into engine cluster. Engines in one engines cluster should use same Database, in other case grouping will show incorrect data in copper monitoring. Not used internally by copper engine, but by copper monitoring.- Parameters:
engineClusterId
- ID of engine cluster
-
queryActiveWorkflowInstances
public java.util.List<org.copperengine.management.model.WorkflowInfo> queryActiveWorkflowInstances(java.lang.String className, int max)
- Specified by:
queryActiveWorkflowInstances
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
queryActiveWorkflowInstance
public org.copperengine.management.model.WorkflowInfo queryActiveWorkflowInstance(java.lang.String id)
- Specified by:
queryActiveWorkflowInstance
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
getWorkflowInstanceStates
public java.util.List<java.lang.String> getWorkflowInstanceStates()
- Specified by:
getWorkflowInstanceStates
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
queryObjectState
public java.lang.String queryObjectState(java.lang.String id) throws java.lang.Exception
- Specified by:
queryObjectState
in interfaceorg.copperengine.management.ProcessingEngineMXBean
- Throws:
java.lang.Exception
-
queryWorkflowInstances
public java.util.List<org.copperengine.management.model.WorkflowInfo> queryWorkflowInstances()
- Specified by:
queryWorkflowInstances
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
queryWorkflowInstances
public java.util.List<org.copperengine.management.model.WorkflowInfo> queryWorkflowInstances(org.copperengine.management.model.WorkflowInstanceFilter filter)
- Specified by:
queryWorkflowInstances
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
countWorkflowInstances
public long countWorkflowInstances(org.copperengine.management.model.WorkflowInstanceFilter filter)
- Specified by:
countWorkflowInstances
in interfaceorg.copperengine.management.ProcessingEngineMXBean
-
convert2Wfi
protected org.copperengine.management.model.WorkflowInfo convert2Wfi(Workflow<?> wf)
- Overrides:
convert2Wfi
in classAbstractProcessingEngine
-
-