Interface ScottyDBStorageInterface

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      int countAuditTrailInstances​(org.copperengine.management.model.AuditTrailInstanceFilter filter)  
      int countWorkflowInstances​(org.copperengine.management.model.WorkflowInstanceFilter filter)  
      void deleteBroken​(java.lang.String workflowInstanceId)
      Deletes a broken workflow from the system (i.e.
      void deleteFiltered​(org.copperengine.management.model.WorkflowInstanceFilter filter)  
      void deleteWaiting​(java.lang.String workflowInstanceId)  
      java.util.List<Workflow<?>> dequeue​(java.lang.String ppoolId, int max)
      Dequeues up to max Workflow instances for the specified processor pool from the database.
      void error​(Workflow<?> w, java.lang.Throwable t, Acknowledge callback)
      Marks a workflow instance as failed in the database.
      void finish​(Workflow<?> w, Acknowledge callback)
      Marks a workflow instance as finished or removes it from the underlying database.
      void insert​(java.util.List<Workflow<?>> wfs, java.sql.Connection con)
      Inserts a list of new workflows to the underlying database using the provided connection.
      void insert​(java.util.List<Workflow<?>> wfs, Acknowledge ack)
      Inserts a list of new workflows to the underlying database.
      void insert​(Workflow<?> wf, java.sql.Connection con)
      Inserts a new workflow to the underlying database using the provided connection.
      void insert​(Workflow<?> wf, Acknowledge ack)
      Inserts a new workflow to the underlying database.
      void notify​(java.util.List<Response<?>> responses, java.sql.Connection c)
      Synchronous service to add a list of Responses to the database using a provided database connection.
      void notify​(java.util.List<Response<?>> response, Acknowledge ack)
      Asynchronous service to add a list of Responses to the database.
      void notify​(Response<?> response, Acknowledge ack)
      Asynchronous service to add a Response to the database.
      java.util.List<Workflow<?>> queryAllActive​(java.lang.String className, int max)
      Query all active workflowinstances from the backing storage
      java.util.List<org.copperengine.management.model.AuditTrailInfo> queryAuditTrailInstances​(org.copperengine.management.model.AuditTrailInstanceFilter filter)  
      java.lang.String queryAuditTrailMessage​(long id)  
      java.lang.String queryObjectState​(java.lang.String id)  
      int queryQueueSize​(java.lang.String processorPoolId)  
      java.util.List<Workflow<?>> queryWorkflowInstances​(org.copperengine.management.model.WorkflowInstanceFilter filter)  
      Workflow<?> read​(java.lang.String workflowInstanceId)  
      void registerCallback​(RegisterCall rc, Acknowledge callback)
      Writes a workflow instance that is waiting for one or more asynchronous response back to database.
      void restart​(java.lang.String workflowInstanceId)
      Triggers the restart of a failed workflow instance, i.e.
      void restartAll()  
      void restartFiltered​(org.copperengine.management.model.WorkflowInstanceFilter filter)
      Triggers the restart of all failed workflow instances.
      void setRemoveWhenFinished​(boolean removeWhenFinished)  
      void shutdown()
      Shutdown the service
      void startup()
      Startup the service
    • Method Detail

      • insert

        void insert​(Workflow<?> wf,
                    Acknowledge ack)
             throws DuplicateIdException,
                    java.lang.Exception
        Inserts a new workflow to the underlying database. The implementation may execute the inserts outside the callers context. The completion will be signalled through the Acknowledge object.
        Parameters:
        wf - workflow to be inserted
        ack - acknowledgment to notify about success or exception.
        Throws:
        DuplicateIdException - If a workflow with the same id as the id of wf is already stored in the database.
        java.lang.Exception - For all kinds of other exceptions like losing database connection
      • insert

        void insert​(java.util.List<Workflow<?>> wfs,
                    Acknowledge ack)
             throws DuplicateIdException,
                    java.lang.Exception
        Inserts a list of new workflows to the underlying database. The implementation may execute the inserts outside the callers context. The completion will be signalled through the Acknowledge object.
        Parameters:
        wfs - workflows to be inserted
        ack - acknowledgment to notify about success or exception.
        Throws:
        DuplicateIdException - If a workflow with the same id as the id of wf is already stored in the database.
        java.lang.Exception - For all kinds of other exceptions like losing database connection
      • insert

        void insert​(Workflow<?> wf,
                    java.sql.Connection con)
             throws DuplicateIdException,
                    java.lang.Exception
        Inserts a new workflow to the underlying database using the provided connection. It is up to the caller commit or rollback and close the connection.
        Parameters:
        wf - workflow to be inserted
        con - Connection object on which insertion shall happen. With connection as parameter, the caller get full commit/rollback control and can thus make use of stronger insertion guarantees than possible with using Acknowledgments only.
        Throws:
        DuplicateIdException - If a workflow with the same id as the id of wf is already stored in the database.
        java.lang.Exception - For all kinds of other exceptions like losing database connection
      • insert

        void insert​(java.util.List<Workflow<?>> wfs,
                    java.sql.Connection con)
             throws DuplicateIdException,
                    java.lang.Exception
        Inserts a list of new workflows to the underlying database using the provided connection. It is up to the caller commit or rollback and close the connection.
        Parameters:
        wfs - workflows to be inserted
        con - Connection object on which insertion shall happen. With connection as parameter, the caller get full commit/rollback control and can thus make use of stronger insertion guarantees than possible with using Acknowledgments only.
        Throws:
        DuplicateIdException - If a workflow with the same id as the id of wf is already stored in the database.
        java.lang.Exception - For all kinds of other exceptions like losing database connection
      • finish

        void finish​(Workflow<?> w,
                    Acknowledge callback)
        Marks a workflow instance as finished or removes it from the underlying database. (Depending on how AbstractSqlDialect.setRemoveWhenFinished(boolean) is set. Default is to delete).
        Parameters:
        w - workflow instance which finished
        callback - which is called after operation succeeded or an Exception occurred.
      • dequeue

        java.util.List<Workflow<?>> dequeue​(java.lang.String ppoolId,
                                            int max)
                                     throws java.lang.Exception
        Dequeues up to max Workflow instances for the specified processor pool from the database. It dequeues only such workflow instances that need further processing, e.g. when a response arrived or a timeout occured.
        Parameters:
        ppoolId - the processor pool id of the processor pool to which the workflows shall be dequeued
        max - maximum number of workflows which shall be dequeud by this call
        Returns:
        List of workflows dequeued from database storage
        Throws:
        java.lang.Exception - Any exception which could happen in this procedure like losing database connection.
      • notify

        void notify​(Response<?> response,
                    Acknowledge ack)
             throws java.lang.Exception
        Asynchronous service to add a Response to the database. Regarding to our best practices, this method should be called from "outside COPPER" from some user implemented adapter.
        Parameters:
        response - the response which holds the correlation ID (required to know which workflow is to be waken up if all wait- conditions are met) and the data which shall be provided to the workflow
        ack - An Acknowledge which is notified after a successful operation run or about the exception which occured otherwise.
        Throws:
        java.lang.Exception - Any exception which could happen in this procedure like losing database connection.
      • notify

        void notify​(java.util.List<Response<?>> response,
                    Acknowledge ack)
             throws java.lang.Exception
        Asynchronous service to add a list of Responses to the database.
        Parameters:
        response - the list of responses for which each holds the correlation ID (required to know which workflow is to be waken up if all wait- conditions are met) and the data which shall be provided to the workflow
        ack - An Acknowledge which is notified after a successful operation run or about the exception which occured otherwise.
        Throws:
        java.lang.Exception - Any exception which could happen in this procedure like losing database connection.
      • notify

        void notify​(java.util.List<Response<?>> responses,
                    java.sql.Connection c)
             throws java.lang.Exception
        Synchronous service to add a list of Responses to the database using a provided database connection.
        Parameters:
        responses - the responses for which each holds the correlation ID (required to know which workflow is to be waken up if all wait- conditions are met) and the data which shall be provided to the workflow
        c - Connection object on which notify shall happen. With connection as parameter, the caller get full commit/rollback control and can thus make use of stronger notification-guarantees than possible with using Acknowledgments only.
        Throws:
        java.lang.Exception - Any exception which could happen in this procedure like losing database connection.
      • registerCallback

        void registerCallback​(RegisterCall rc,
                              Acknowledge callback)
                       throws java.lang.Exception
        Writes a workflow instance that is waiting for one or more asynchronous response back to database.
        Parameters:
        rc - class for holding information about the workflow which shall be updated in its processing state. Holds the workflow itself but also more data like the correlation IDs to wait upon and more. All data required for the database update is stored in here.
        callback - Callback which is called on success or error after this operation finished.
        Throws:
        java.lang.Exception - Any unexpected Exception like losing database connection.
      • startup

        void startup()
        Startup the service
      • shutdown

        void shutdown()
        Shutdown the service
      • error

        void error​(Workflow<?> w,
                   java.lang.Throwable t,
                   Acknowledge callback)
        Marks a workflow instance as failed in the database. It may me triggered again later when the error cause has been solved using the restart method.
        Parameters:
        w - The workflow which shall be marked as erroneous
        t - The Throwable which lead the workflow get into this error state.
        callback - callback which notifies about success or error within this operation after it finished.
      • restart

        void restart​(java.lang.String workflowInstanceId)
              throws java.lang.Exception
        Triggers the restart of a failed workflow instance, i.e. resubmitting the given workflow in DBProcessingState.INVALID or DBProcessingState.ERROR to the queue to (re-)start from last stored execution point.
        Parameters:
        workflowInstanceId - workflow id of broken workflow
        Throws:
        java.lang.Exception - Any Exception like losing database connection.
      • setRemoveWhenFinished

        void setRemoveWhenFinished​(boolean removeWhenFinished)
        Parameters:
        removeWhenFinished - If true (default), finished workflow instances are removed from the database.
      • restartFiltered

        void restartFiltered​(org.copperengine.management.model.WorkflowInstanceFilter filter)
                      throws java.lang.Exception
        Triggers the restart of all failed workflow instances. See also restart(String)
        Parameters:
        filter - the WorkflowInstanceFilter
        Throws:
        java.lang.Exception - Any Exception like losing database connection.
      • restartAll

        void restartAll()
                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • deleteBroken

        void deleteBroken​(java.lang.String workflowInstanceId)
                   throws java.lang.Exception
        Deletes a broken workflow from the system (i.e. from all tables)
        Parameters:
        workflowInstanceId - workflow id of broken workflow
        Throws:
        java.lang.Exception - when the delete operation fails
      • deleteWaiting

        void deleteWaiting​(java.lang.String workflowInstanceId)
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • deleteFiltered

        void deleteFiltered​(org.copperengine.management.model.WorkflowInstanceFilter filter)
                     throws java.lang.Exception
        Throws:
        java.lang.Exception
      • read

        Workflow<?> read​(java.lang.String workflowInstanceId)
                  throws java.lang.Exception
        Throws:
        java.lang.Exception
      • queryAllActive

        java.util.List<Workflow<?>> queryAllActive​(java.lang.String className,
                                                   int max)
                                            throws java.lang.Exception
        Query all active workflowinstances from the backing storage
        Parameters:
        className - optional - className of the active workflow instances
        max - limits the number of Workflow instances to read
        Returns:
        list of deserialized workflow instance
        Throws:
        java.lang.Exception - Any Exception like losing database connection.
      • queryQueueSize

        int queryQueueSize​(java.lang.String processorPoolId)
                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • queryObjectState

        java.lang.String queryObjectState​(java.lang.String id)
                                   throws java.lang.Exception
        Throws:
        java.lang.Exception
      • queryWorkflowInstances

        java.util.List<Workflow<?>> queryWorkflowInstances​(org.copperengine.management.model.WorkflowInstanceFilter filter)
                                                    throws java.lang.Exception
        Throws:
        java.lang.Exception
      • countWorkflowInstances

        int countWorkflowInstances​(org.copperengine.management.model.WorkflowInstanceFilter filter)
                            throws java.lang.Exception
        Throws:
        java.lang.Exception
      • queryAuditTrailInstances

        java.util.List<org.copperengine.management.model.AuditTrailInfo> queryAuditTrailInstances​(org.copperengine.management.model.AuditTrailInstanceFilter filter)
                                                                                           throws java.lang.Exception
        Throws:
        java.lang.Exception
      • queryAuditTrailMessage

        java.lang.String queryAuditTrailMessage​(long id)
                                         throws java.lang.Exception
        Throws:
        java.lang.Exception
      • countAuditTrailInstances

        int countAuditTrailInstances​(org.copperengine.management.model.AuditTrailInstanceFilter filter)
                              throws java.lang.Exception
        Throws:
        java.lang.Exception