Class ContextMachine


  • public class ContextMachine
    extends java.lang.Object
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String MANUAL_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
      void addContextInstanceStateChangeEventListener​(org.ikasan.spec.scheduled.core.listener.ContextInstanceStateChangeEventListener listener)  
      protected void addOutboundListener()  
      void addQueuedSchedulerJobInitiationEvent​(org.ikasan.spec.scheduled.event.model.SchedulerJobInitiationEvent event)  
      void addSchedulerJobStateChangeEventListener​(org.ikasan.spec.scheduled.core.listener.SchedulerJobInstanceStateChangeEventListener listener)  
      void broadcastGlobalEvents​(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.
      void disableQuartzBasedJobs()
      Method to disable the quartz based jobs associated with the context instance.
      void enableQuartzBasedJobs()
      Method to enable the quartz based jobs associated with the context instance.
      void eventReceived​(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.ContextInstance getContext()
      Get the context by name.
      org.ikasan.spec.scheduled.instance.model.ContextInstance getContext​(java.lang.String contextName)
      Get the context by name.
      org.ikasan.job.orchestration.model.status.ContextInstanceStatus getContextInstanceStatus()  
      org.ikasan.spec.scheduled.instance.model.InstanceStatus getContextStatus​(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.IBigQueue getInboundQueue()  
      java.lang.String getInboundQueueName()  
      java.util.Map<java.lang.String,​org.ikasan.spec.scheduled.instance.model.InternalEventDrivenJobInstance> getInternalEventDrivenJobInstancesMap()  
      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.
      org.ikasan.bigqueue.IBigQueue getOutboundQueue()  
      java.lang.String getOutboundQueueName()  
      void holdJob​(java.lang.String jobIdentifier, java.lang.String childContextName)
      Helper method to hold a job.
      void init()  
      boolean isDryRun()  
      void raiseEvent​(org.ikasan.spec.scheduled.event.model.ContextualisedScheduledProcessEvent contextualisedScheduledProcessEvent)  
      void registerToNotificationMonitors()  
      void releaseJob​(java.lang.String jobIdentifier, java.lang.String childContextName)  
      void removeContextInstanceStateChangeEventListener​(org.ikasan.spec.scheduled.core.listener.ContextInstanceStateChangeEventListener listener)  
      void removeSchedulerJobStateChangeEventListener​(org.ikasan.spec.scheduled.core.listener.SchedulerJobInstanceStateChangeEventListener listener)  
      void resetContextInstance​(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.
      void resetJob​(java.lang.String jobIdentifier, java.lang.String childContextName)  
      void runContextUntilManuallyEnded()  
      void saveContext()  
      boolean servesAgent​(java.lang.String agentName)
      Indicates if this machine is supports a given agent
      void setDryRunParameters​(org.ikasan.spec.scheduled.event.model.DryRunParameters dryRunParameters)  
      void setSchedulerJobInitiationEventRaisedListener​(org.ikasan.spec.scheduled.core.listener.SchedulerJobInitiationEventRaisedListener listener)  
      void skipJob​(java.lang.String jobIdentifier, java.lang.String childContextName, boolean skipFlag)
      Method to set a job as skipped.
      void skipJobs​(java.lang.String childContextName, boolean skipFlag)
      Method to set a job as skipped for all jobs under a context.
      void teardown()
      Method to tear down context machine internals.
      void unregisterToNotificationMonitors()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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.SchedulerJobInstanceInitialisationException
        Helper method to reset the context instance held by the context machine.
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException
        java.io.IOException
        org.ikasan.spec.scheduled.instance.service.exception.SchedulerJobInstanceInitialisationException
      • teardown

        public void teardown()
                      throws java.io.IOException
        Method 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.IOException
        Helper 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()