Class PersistentScottyEngine

    • Constructor Detail

      • PersistentScottyEngine

        public PersistentScottyEngine()
    • 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
      • 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 interface ProcessingEngine
        Parameters:
        response - the reponse
        ack - 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.
      • 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 interface ProcessingEngine
        Overrides:
        startup in class AbstractProcessingEngine
      • 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 interface ProcessingEngine
        Parameters:
        w - the workflow instance waiting for one or more response
        mode - the wait mode
        timeoutMsec - the relative timeout in milliseconds or 0 for no an infinite timeout
        correlationIds - the correlation ids of the expected responses
      • 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 run
        con - 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 run
        con - 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 interface PersistentProcessingEngine
        Specified by:
        restart in interface org.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 interface org.copperengine.management.ProcessingEngineMXBean
      • queryWorkflowInstance

        public org.copperengine.management.model.WorkflowInfo queryWorkflowInstance​(java.lang.String id)
        Specified by:
        queryWorkflowInstance in interface org.copperengine.management.ProcessingEngineMXBean
      • getNumberOfWorkflowInstances

        public int getNumberOfWorkflowInstances()
        Specified by:
        getNumberOfWorkflowInstances in interface org.copperengine.management.ProcessingEngineMXBean
      • restartFiltered

        public void restartFiltered​(org.copperengine.management.model.WorkflowInstanceFilter filter)
                             throws java.lang.Exception
        Specified by:
        restartFiltered in interface PersistentProcessingEngine
        Specified by:
        restartFiltered in interface org.copperengine.management.PersistentProcessingEngineMXBean
        Throws:
        java.lang.Exception
      • deleteBroken

        public void deleteBroken​(java.lang.String workflowInstanceId)
                          throws java.lang.Exception
        Specified by:
        deleteBroken in interface org.copperengine.management.PersistentProcessingEngineMXBean
        Throws:
        java.lang.Exception
      • deleteWaiting

        public void deleteWaiting​(java.lang.String workflowInstanceId)
                           throws java.lang.Exception
        Specified by:
        deleteWaiting in interface org.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 interface org.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 interface PersistentProcessingEngine
        Parameters:
        wfInstanceDescr - workflow instance descriptions to run
        con - 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 interface PersistentProcessingEngine
        Parameters:
        wfInstanceDescr - the list of workflow instance descriptions to run
        con - 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 interface PersistentProcessingEngine
        Parameters:
        response - the reponse
        c - 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 interface PersistentProcessingEngine
        Parameters:
        responses - the list of reponses
        c - 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 interface ProcessingEngine
        Parameters:
        wfInstanceId - workflow instance id
        waitHook - wait hook
      • getProcessorPools

        public java.util.List<org.copperengine.management.ProcessorPoolMXBean> getProcessorPools()
        Specified by:
        getProcessorPools in interface org.copperengine.management.ProcessingEngineMXBean
      • getEngineType

        public org.copperengine.management.model.EngineType getEngineType()
        Specified by:
        getEngineType in interface org.copperengine.management.ProcessingEngineMXBean
      • getDBStorage

        public org.copperengine.management.DBStorageMXBean getDBStorage()
        Specified by:
        getDBStorage in interface org.copperengine.management.PersistentProcessingEngineMXBean
      • getEngineClusterId

        public java.lang.String getEngineClusterId()
        Specified by:
        getEngineClusterId in interface org.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 interface org.copperengine.management.ProcessingEngineMXBean
      • queryActiveWorkflowInstance

        public org.copperengine.management.model.WorkflowInfo queryActiveWorkflowInstance​(java.lang.String id)
        Specified by:
        queryActiveWorkflowInstance in interface org.copperengine.management.ProcessingEngineMXBean
      • getWorkflowInstanceStates

        public java.util.List<java.lang.String> getWorkflowInstanceStates()
        Specified by:
        getWorkflowInstanceStates in interface org.copperengine.management.ProcessingEngineMXBean
      • queryObjectState

        public java.lang.String queryObjectState​(java.lang.String id)
                                          throws java.lang.Exception
        Specified by:
        queryObjectState in interface org.copperengine.management.ProcessingEngineMXBean
        Throws:
        java.lang.Exception
      • queryWorkflowInstances

        public java.util.List<org.copperengine.management.model.WorkflowInfo> queryWorkflowInstances()
        Specified by:
        queryWorkflowInstances in interface org.copperengine.management.ProcessingEngineMXBean
      • queryWorkflowInstances

        public java.util.List<org.copperengine.management.model.WorkflowInfo> queryWorkflowInstances​(org.copperengine.management.model.WorkflowInstanceFilter filter)
        Specified by:
        queryWorkflowInstances in interface org.copperengine.management.ProcessingEngineMXBean
      • countWorkflowInstances

        public long countWorkflowInstances​(org.copperengine.management.model.WorkflowInstanceFilter filter)
        Specified by:
        countWorkflowInstances in interface org.copperengine.management.ProcessingEngineMXBean