org.apache.oozie.store
Class WorkflowStore

java.lang.Object
  extended by org.apache.oozie.store.Store
      extended by org.apache.oozie.store.WorkflowStore

public class WorkflowStore
extends Store

DB Implementation of Workflow Store


Field Summary
static int LOCK_TIMEOUT
           
 
Constructor Summary
WorkflowStore()
           
WorkflowStore(boolean selectForUpdate)
           
WorkflowStore(Connection connection, boolean selectForUpdate)
           
WorkflowStore(Connection connection, Store store, boolean selectForUpdate)
           
WorkflowStore(Store store, boolean selectForUpdate)
           
 
Method Summary
 void deleteAction(String id)
          Delete the Action with given id.
 WorkflowActionBean getAction(String id, boolean locking)
          Load the action data and returns a bean.
 List<WorkflowActionBean> getActionsForWorkflow(String wfId, boolean locking)
          Loads all the actions for the given Workflow.
 List<WorkflowActionBean> getActionsSubsetForWorkflow(String wfId, int start, int len)
          Loads given number of actions for the given Workflow.
 List<WorkflowActionBean> getPendingActions(long minimumPendingAgeSecs)
          Load All the actions that are pending for more than given time.
 List<WorkflowActionBean> getRetryAndManualActions(String wfId)
          Load All the actions that are START_RETRY or START_MANUAL or END_RETRY or END_MANUAL.
 List<WorkflowActionBean> getRunningActions(long checkAgeSecs)
          Load All the actions that are running and were last checked after now - miminumCheckAgeSecs
 WorkflowJobBean getWorkflow(String id, boolean locking)
          Load the Workflow into a Bean and return it.
 int getWorkflowCountWithStatus(String status)
          Get the number of Workflows with the given status.
 int getWorkflowCountWithStatusInLastNSeconds(String status, int secs)
          Get the number of Workflows with the given status which was modified in given time limit.
 String getWorkflowIdForExternalId(String externalId)
          Get the Workflow ID with given external ID which will be assigned for the subworkflows.
 WorkflowJobBean getWorkflowInfo(String id)
          Load the Workflow and all Action details and return a WorkflowJobBean.
 WorkflowJobBean getWorkflowInfoWithActionsSubset(String id, int start, int len)
          Load the Workflow and subset Actions details and return a WorkflowJobBean.
 WorkflowsInfo getWorkflowsInfo(Map<String,List<String>> filter, int start, int len)
          Loads all the jobs that are satisfying the given filter condition.
 void insertAction(WorkflowActionBean action)
          Create a new Action record in the ACTIONS table with the given Bean.
 void insertWorkflow(WorkflowJobBean workflow)
          Create a Workflow and return a WorkflowJobBean.
 void purge(long olderThanDays, int limit)
          Purge the Workflows Completed older than given days.
 void updateAction(WorkflowActionBean action)
          Update the given action bean to DB.
 void updateWorkflow(WorkflowJobBean wfBean)
          Update the data from Workflow Bean to DB along with the workflow instance data.
 
Methods inherited from class org.apache.oozie.store.Store
beginTrx, closeTrx, commitTrx, contains, getConnection, getEntityManager, getFlushMode, isActive, isClosed, isDetached, rollbackTrx
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOCK_TIMEOUT

public static final int LOCK_TIMEOUT
See Also:
Constant Field Values
Constructor Detail

WorkflowStore

public WorkflowStore()

WorkflowStore

public WorkflowStore(Connection connection,
                     boolean selectForUpdate)
              throws StoreException
Throws:
StoreException

WorkflowStore

public WorkflowStore(Connection connection,
                     Store store,
                     boolean selectForUpdate)
              throws StoreException
Throws:
StoreException

WorkflowStore

public WorkflowStore(boolean selectForUpdate)
              throws StoreException
Throws:
StoreException

WorkflowStore

public WorkflowStore(Store store,
                     boolean selectForUpdate)
              throws StoreException
Throws:
StoreException
Method Detail

insertWorkflow

public void insertWorkflow(WorkflowJobBean workflow)
                    throws StoreException
Create a Workflow and return a WorkflowJobBean. It also creates the process instance for the job.

Parameters:
workflow - workflow bean
Throws:
StoreException

getWorkflow

public WorkflowJobBean getWorkflow(String id,
                                   boolean locking)
                            throws StoreException
Load the Workflow into a Bean and return it. Also load the Workflow Instance into the bean. And lock the Workflow depending on the locking parameter.

Parameters:
id - Workflow ID
locking - true if Workflow is to be locked
Returns:
WorkflowJobBean
Throws:
StoreException

getWorkflowCountWithStatus

public int getWorkflowCountWithStatus(String status)
                               throws StoreException
Get the number of Workflows with the given status.

Parameters:
status - Workflow Status.
Returns:
number of Workflows with given status.
Throws:
StoreException

getWorkflowCountWithStatusInLastNSeconds

public int getWorkflowCountWithStatusInLastNSeconds(String status,
                                                    int secs)
                                             throws StoreException
Get the number of Workflows with the given status which was modified in given time limit.

Parameters:
status - Workflow Status.
secs - No. of seconds within which the workflow got modified.
Returns:
number of Workflows modified within given time with given status.
Throws:
StoreException

updateWorkflow

public void updateWorkflow(WorkflowJobBean wfBean)
                    throws StoreException
Update the data from Workflow Bean to DB along with the workflow instance data. Action table is not updated

Parameters:
wfBean - Workflow Bean
Throws:
StoreException - If Workflow doesn't exist

insertAction

public void insertAction(WorkflowActionBean action)
                  throws StoreException
Create a new Action record in the ACTIONS table with the given Bean.

Parameters:
action - WorkflowActionBean
Throws:
StoreException - If the action is already present

getAction

public WorkflowActionBean getAction(String id,
                                    boolean locking)
                             throws StoreException
Load the action data and returns a bean.

Parameters:
id - Action Id
locking - true if the action is to be locked
Returns:
Action Bean
Throws:
StoreException - If action doesn't exist

updateAction

public void updateAction(WorkflowActionBean action)
                  throws StoreException
Update the given action bean to DB.

Parameters:
action - Action Bean
Throws:
StoreException - if action doesn't exist

deleteAction

public void deleteAction(String id)
                  throws StoreException
Delete the Action with given id.

Parameters:
id - Action ID
Throws:
StoreException - if Action doesn't exist

getActionsForWorkflow

public List<WorkflowActionBean> getActionsForWorkflow(String wfId,
                                                      boolean locking)
                                               throws StoreException
Loads all the actions for the given Workflow. Also locks all the actions if locking is true.

Parameters:
wfId - Workflow ID
locking - true if Actions are to be locked
Returns:
A List of WorkflowActionBean
Throws:
StoreException

getActionsSubsetForWorkflow

public List<WorkflowActionBean> getActionsSubsetForWorkflow(String wfId,
                                                            int start,
                                                            int len)
                                                     throws StoreException
Loads given number of actions for the given Workflow. Also locks all the actions if locking is true.

Parameters:
wfId - Workflow ID
start - offset for select statement
len - number of Workflow Actions to be returned
locking - true if Actions are to be locked
Returns:
A List of WorkflowActionBean
Throws:
StoreException

getPendingActions

public List<WorkflowActionBean> getPendingActions(long minimumPendingAgeSecs)
                                           throws StoreException
Load All the actions that are pending for more than given time.

Parameters:
minimumPendingAgeSecs - Minimum Pending age in seconds
Returns:
List of action beans
Throws:
StoreException

getRunningActions

public List<WorkflowActionBean> getRunningActions(long checkAgeSecs)
                                           throws StoreException
Load All the actions that are running and were last checked after now - miminumCheckAgeSecs

Parameters:
checkAgeSecs - check age in seconds.
Returns:
List of action beans.
Throws:
StoreException

getRetryAndManualActions

public List<WorkflowActionBean> getRetryAndManualActions(String wfId)
                                                  throws StoreException
Load All the actions that are START_RETRY or START_MANUAL or END_RETRY or END_MANUAL.

Parameters:
wfId - String
Returns:
List of action beans
Throws:
StoreException

getWorkflowsInfo

public WorkflowsInfo getWorkflowsInfo(Map<String,List<String>> filter,
                                      int start,
                                      int len)
                               throws StoreException
Loads all the jobs that are satisfying the given filter condition. Filters can be applied on user, group, appName, status.

Parameters:
filter - Filter condition
start - offset for select statement
len - number of Workflows to be returned
Returns:
A list of workflows
Throws:
StoreException

getWorkflowInfo

public WorkflowJobBean getWorkflowInfo(String id)
                                throws StoreException
Load the Workflow and all Action details and return a WorkflowJobBean. Workflow Instance is not loaded

Parameters:
id - Workflow Id
Returns:
Workflow Bean
Throws:
StoreException - If Workflow doesn't exist

getWorkflowInfoWithActionsSubset

public WorkflowJobBean getWorkflowInfoWithActionsSubset(String id,
                                                        int start,
                                                        int len)
                                                 throws StoreException
Load the Workflow and subset Actions details and return a WorkflowJobBean. Workflow Instance is not loaded

Parameters:
id - Workflow Id
start - offset for select statement for actions
len - number of Workflow Actions to be returned
Returns:
Workflow Bean
Throws:
StoreException - If Workflow doesn't exist

getWorkflowIdForExternalId

public String getWorkflowIdForExternalId(String externalId)
                                  throws StoreException
Get the Workflow ID with given external ID which will be assigned for the subworkflows.

Parameters:
externalId - external ID
Returns:
Workflow ID
Throws:
StoreException - if there is no job with external ID

purge

public void purge(long olderThanDays,
                  int limit)
           throws StoreException
Purge the Workflows Completed older than given days.

Parameters:
olderThanDays - number of days for which to preserve the workflows
Throws:
StoreException


Copyright © 2013 Apache Software Foundation. All Rights Reserved.