Class ContextMachine
- java.lang.Object
-
- org.ikasan.job.orchestration.core.machine.ContextMachine
-
public class ContextMachine extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classContextMachine.InboundQueueMessageRunnerprotected classContextMachine.OutboundQueueMessageRunner
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringMANUAL_SUBMISSION
-
Constructor Summary
Constructors Constructor Description ContextMachine(org.ikasan.spec.scheduled.context.model.ContextTemplate context, org.ikasan.spec.scheduled.instance.model.ContextInstance contextInstance, org.ikasan.spec.scheduled.instance.service.ScheduledContextInstanceService scheduledContextInstanceService, java.util.Map<java.lang.String,org.ikasan.spec.scheduled.instance.model.GlobalEventJobInstance> globalEventJobInstanceMap, java.util.Map<java.lang.String,org.ikasan.spec.scheduled.instance.model.QuartzScheduleDrivenJobInstance> quartzScheduleDrivenJobInstanceMap, java.util.Map<java.lang.String,org.ikasan.spec.scheduled.instance.model.InternalEventDrivenJobInstance> internalEventDrivenJobInstances, java.lang.String queueDir, java.util.Map<java.lang.String,org.ikasan.spec.metadata.ModuleMetaData> agents, org.ikasan.spec.scheduled.context.model.JobLockCache jobLockCache, org.ikasan.spec.scheduled.instance.service.ContextParametersInstanceService contextParametersInstanceService, org.ikasan.spec.scheduled.context.service.ScheduledContextService scheduledContextService, org.ikasan.spec.scheduled.instance.service.SchedulerJobInstanceService schedulerJobInstanceService, org.ikasan.spec.scheduled.joblock.service.JobLockCacheInitialisationService jobLockCacheInitialisationService, org.ikasan.spec.scheduled.instance.service.ContextInstancePublicationService<org.ikasan.spec.scheduled.instance.model.ContextInstance> contextInstancePublicationService)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddContextInstanceStateChangeEventListener(org.ikasan.spec.scheduled.core.listener.ContextInstanceStateChangeEventListener listener)protected voidaddOutboundListener()voidaddQueuedSchedulerJobInitiationEvent(org.ikasan.spec.scheduled.event.model.SchedulerJobInitiationEvent event)voidaddSchedulerJobStateChangeEventListener(org.ikasan.spec.scheduled.core.listener.SchedulerJobInstanceStateChangeEventListener listener)voidbroadcastGlobalEvents(org.ikasan.spec.scheduled.event.model.SchedulerJobInitiationEvent schedulerJobInitiationEvent, boolean ignoreEnvironmentGroup, boolean forceSending)Helper method to broadcast global events to all running instances of a context optionally within an environment.voiddisableQuartzBasedJobs()Method to disable the quartz based jobs associated with the context instance.voidenableQuartzBasedJobs()Method to enable the quartz based jobs associated with the context instance.voideventReceived(java.lang.String bigQueueMessage)protected java.util.List<org.ikasan.spec.scheduled.event.model.SchedulerJobInitiationEvent>eventReceived(org.ikasan.spec.scheduled.event.model.ContextualisedScheduledProcessEvent scheduledProcessEvent)org.ikasan.spec.scheduled.instance.model.ContextInstancegetContext()Get the context by name.org.ikasan.spec.scheduled.instance.model.ContextInstancegetContext(java.lang.String contextName)Get the context by name.org.ikasan.job.orchestration.model.status.ContextInstanceStatusgetContextInstanceStatus()org.ikasan.spec.scheduled.instance.model.InstanceStatusgetContextStatus(java.lang.String contextName)Get the context status by context name.java.util.List<org.ikasan.spec.scheduled.event.model.SchedulerJobInitiationEvent>getEventsThatCanRun(org.ikasan.spec.scheduled.event.model.ContextualisedScheduledProcessEvent contextualisedScheduledProcessEvent)This method is responsible for providing a view onto jobs that can be run based on the receipt of an input event, without impacting the state of the underlying context data model.protected java.util.Map<java.lang.String,org.ikasan.spec.scheduled.instance.model.GlobalEventJobInstance>getGlobalEventJobInstanceMap()org.ikasan.bigqueue.IBigQueuegetInboundQueue()java.lang.StringgetInboundQueueName()java.util.Map<java.lang.String,org.ikasan.spec.scheduled.instance.model.InternalEventDrivenJobInstance>getInternalEventDrivenJobInstancesMap()org.ikasan.spec.scheduled.instance.model.InstanceStatusgetJobStatus(java.lang.String contextName, java.lang.String jobIdentifier)Get the job status by context name and job name.org.ikasan.bigqueue.IBigQueuegetOutboundQueue()java.lang.StringgetOutboundQueueName()voidholdJob(java.lang.String jobIdentifier, java.lang.String childContextName)Helper method to hold a job.voidinit()booleanisDryRun()voidraiseEvent(org.ikasan.spec.scheduled.event.model.ContextualisedScheduledProcessEvent contextualisedScheduledProcessEvent)voidregisterToNotificationMonitors()voidreleaseJob(java.lang.String jobIdentifier, java.lang.String childContextName)voidremoveContextInstanceStateChangeEventListener(org.ikasan.spec.scheduled.core.listener.ContextInstanceStateChangeEventListener listener)voidremoveSchedulerJobStateChangeEventListener(org.ikasan.spec.scheduled.core.listener.SchedulerJobInstanceStateChangeEventListener listener)voidresetContextInstance(boolean holdCommandJobs, boolean initiateWithSameParameters, java.util.List<org.ikasan.spec.scheduled.instance.model.ContextParameterInstance> contextParameterInstances)Helper method to reset the context instance held by the context machine.voidresetJob(java.lang.String jobIdentifier, java.lang.String childContextName)voidrunContextUntilManuallyEnded()voidsaveContext()booleanservesAgent(java.lang.String agentName)Indicates if this machine is supports a given agentvoidsetDryRunParameters(org.ikasan.spec.scheduled.event.model.DryRunParameters dryRunParameters)voidsetSchedulerJobInitiationEventRaisedListener(org.ikasan.spec.scheduled.core.listener.SchedulerJobInitiationEventRaisedListener listener)voidskipJob(java.lang.String jobIdentifier, java.lang.String childContextName, boolean skipFlag)Method to set a job as skipped.voidskipJobs(java.lang.String childContextName, boolean skipFlag)Method to set a job as skipped for all jobs under a context.voidteardown()Method to tear down context machine internals.voidunregisterToNotificationMonitors()
-
-
-
Field Detail
-
MANUAL_SUBMISSION
public static final java.lang.String MANUAL_SUBMISSION
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ContextMachine
public ContextMachine(org.ikasan.spec.scheduled.context.model.ContextTemplate context, org.ikasan.spec.scheduled.instance.model.ContextInstance contextInstance, org.ikasan.spec.scheduled.instance.service.ScheduledContextInstanceService scheduledContextInstanceService, java.util.Map<java.lang.String,org.ikasan.spec.scheduled.instance.model.GlobalEventJobInstance> globalEventJobInstanceMap, java.util.Map<java.lang.String,org.ikasan.spec.scheduled.instance.model.QuartzScheduleDrivenJobInstance> quartzScheduleDrivenJobInstanceMap, java.util.Map<java.lang.String,org.ikasan.spec.scheduled.instance.model.InternalEventDrivenJobInstance> internalEventDrivenJobInstances, java.lang.String queueDir, java.util.Map<java.lang.String,org.ikasan.spec.metadata.ModuleMetaData> agents, org.ikasan.spec.scheduled.context.model.JobLockCache jobLockCache, org.ikasan.spec.scheduled.instance.service.ContextParametersInstanceService contextParametersInstanceService, org.ikasan.spec.scheduled.context.service.ScheduledContextService scheduledContextService, org.ikasan.spec.scheduled.instance.service.SchedulerJobInstanceService schedulerJobInstanceService, org.ikasan.spec.scheduled.joblock.service.JobLockCacheInitialisationService jobLockCacheInitialisationService, org.ikasan.spec.scheduled.instance.service.ContextInstancePublicationService<org.ikasan.spec.scheduled.instance.model.ContextInstance> contextInstancePublicationService)
-
-
Method Detail
-
init
public void init() throws java.io.IOException- Throws:
java.io.IOException
-
registerToNotificationMonitors
public void registerToNotificationMonitors()
-
unregisterToNotificationMonitors
public void unregisterToNotificationMonitors()
-
getOutboundQueueName
public java.lang.String getOutboundQueueName()
-
getInboundQueueName
public java.lang.String getInboundQueueName()
-
getInboundQueue
public org.ikasan.bigqueue.IBigQueue getInboundQueue()
-
getOutboundQueue
public org.ikasan.bigqueue.IBigQueue getOutboundQueue()
-
resetContextInstance
public void resetContextInstance(boolean holdCommandJobs, boolean initiateWithSameParameters, java.util.List<org.ikasan.spec.scheduled.instance.model.ContextParameterInstance> contextParameterInstances) throws java.io.IOException, org.ikasan.spec.scheduled.instance.service.exception.SchedulerJobInstanceInitialisationExceptionHelper method to reset the context instance held by the context machine.- Throws:
com.fasterxml.jackson.core.JsonProcessingExceptionjava.io.IOExceptionorg.ikasan.spec.scheduled.instance.service.exception.SchedulerJobInstanceInitialisationException
-
teardown
public void teardown() throws java.io.IOExceptionMethod to tear down context machine internals.- Throws:
java.io.IOException
-
setSchedulerJobInitiationEventRaisedListener
public void setSchedulerJobInitiationEventRaisedListener(org.ikasan.spec.scheduled.core.listener.SchedulerJobInitiationEventRaisedListener listener)
- Parameters:
listener-
-
eventReceived
public void eventReceived(java.lang.String bigQueueMessage) throws java.io.IOException- Parameters:
bigQueueMessage-- Throws:
java.io.IOException
-
raiseEvent
public void raiseEvent(org.ikasan.spec.scheduled.event.model.ContextualisedScheduledProcessEvent contextualisedScheduledProcessEvent) throws java.io.IOException- Throws:
java.io.IOException
-
getContextStatus
public org.ikasan.spec.scheduled.instance.model.InstanceStatus getContextStatus(java.lang.String contextName)
Get the context status by context name.- Parameters:
contextName-- Returns:
-
getJobStatus
public org.ikasan.spec.scheduled.instance.model.InstanceStatus getJobStatus(java.lang.String contextName, java.lang.String jobIdentifier)Get the job status by context name and job name.- Parameters:
contextName-- Returns:
-
getContextInstanceStatus
public org.ikasan.job.orchestration.model.status.ContextInstanceStatus getContextInstanceStatus()
- Returns:
-
getContext
public org.ikasan.spec.scheduled.instance.model.ContextInstance getContext(java.lang.String contextName)
Get the context by name.- Parameters:
contextName-- Returns:
-
getContext
public org.ikasan.spec.scheduled.instance.model.ContextInstance getContext()
Get the context by name.- Returns:
-
addSchedulerJobStateChangeEventListener
public void addSchedulerJobStateChangeEventListener(org.ikasan.spec.scheduled.core.listener.SchedulerJobInstanceStateChangeEventListener listener)
- Parameters:
listener-
-
removeSchedulerJobStateChangeEventListener
public void removeSchedulerJobStateChangeEventListener(org.ikasan.spec.scheduled.core.listener.SchedulerJobInstanceStateChangeEventListener listener)
- Parameters:
listener-
-
addContextInstanceStateChangeEventListener
public void addContextInstanceStateChangeEventListener(org.ikasan.spec.scheduled.core.listener.ContextInstanceStateChangeEventListener listener)
- Parameters:
listener-
-
removeContextInstanceStateChangeEventListener
public void removeContextInstanceStateChangeEventListener(org.ikasan.spec.scheduled.core.listener.ContextInstanceStateChangeEventListener listener)
- Parameters:
listener-
-
setDryRunParameters
public void setDryRunParameters(org.ikasan.spec.scheduled.event.model.DryRunParameters dryRunParameters)
- Parameters:
dryRunParameters-
-
isDryRun
public boolean isDryRun()
- Returns:
-
disableQuartzBasedJobs
public void disableQuartzBasedJobs()
Method to disable the quartz based jobs associated with the context instance.
-
enableQuartzBasedJobs
public void enableQuartzBasedJobs()
Method to enable the quartz based jobs associated with the context instance.
-
runContextUntilManuallyEnded
public void runContextUntilManuallyEnded()
-
skipJob
public void skipJob(java.lang.String jobIdentifier, java.lang.String childContextName, boolean skipFlag)Method to set a job as skipped.- Parameters:
jobIdentifier-childContextName-skipFlag-
-
skipJobs
public void skipJobs(java.lang.String childContextName, boolean skipFlag)Method to set a job as skipped for all jobs under a context.- Parameters:
childContextName-skipFlag-
-
holdJob
public void holdJob(java.lang.String jobIdentifier, java.lang.String childContextName)Helper method to hold a job.- Parameters:
jobIdentifier-childContextName-
-
resetJob
public void resetJob(java.lang.String jobIdentifier, java.lang.String childContextName)
-
releaseJob
public void releaseJob(java.lang.String jobIdentifier, java.lang.String childContextName)
-
getEventsThatCanRun
public java.util.List<org.ikasan.spec.scheduled.event.model.SchedulerJobInitiationEvent> getEventsThatCanRun(org.ikasan.spec.scheduled.event.model.ContextualisedScheduledProcessEvent contextualisedScheduledProcessEvent)
This method is responsible for providing a view onto jobs that can be run based on the receipt of an input event, without impacting the state of the underlying context data model.- Parameters:
contextualisedScheduledProcessEvent-- Returns:
-
servesAgent
public boolean servesAgent(java.lang.String agentName)
Indicates if this machine is supports a given agent- Parameters:
agentName- to be checked- Returns:
- true if the contextMachine is used to service the given agent.
-
eventReceived
protected java.util.List<org.ikasan.spec.scheduled.event.model.SchedulerJobInitiationEvent> eventReceived(org.ikasan.spec.scheduled.event.model.ContextualisedScheduledProcessEvent scheduledProcessEvent)
- Parameters:
scheduledProcessEvent-- Returns:
-
addQueuedSchedulerJobInitiationEvent
public void addQueuedSchedulerJobInitiationEvent(org.ikasan.spec.scheduled.event.model.SchedulerJobInitiationEvent event)
-
saveContext
public void saveContext()
-
broadcastGlobalEvents
public void broadcastGlobalEvents(org.ikasan.spec.scheduled.event.model.SchedulerJobInitiationEvent schedulerJobInitiationEvent, boolean ignoreEnvironmentGroup, boolean forceSending) throws java.io.IOExceptionHelper method to broadcast global events to all running instances of a context optionally within an environment.- Parameters:
schedulerJobInitiationEvent-ignoreEnvironmentGroup- set to true to target all active context instance regardless of what group it belongs to.forceSending- set to true to override the checking of globalEventJobInstance, used when event comes from outside the current context machine- Throws:
java.io.IOException
-
addOutboundListener
protected void addOutboundListener()
-
getGlobalEventJobInstanceMap
protected java.util.Map<java.lang.String,org.ikasan.spec.scheduled.instance.model.GlobalEventJobInstance> getGlobalEventJobInstanceMap()
-
getInternalEventDrivenJobInstancesMap
public java.util.Map<java.lang.String,org.ikasan.spec.scheduled.instance.model.InternalEventDrivenJobInstance> getInternalEventDrivenJobInstancesMap()
-
-