org.apache.oozie.store
Class CoordinatorStore

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

public class CoordinatorStore
extends Store

DB Implementation of Coord Store


Field Summary
static int LOCK_TIMEOUT
           
 
Constructor Summary
CoordinatorStore(boolean selectForUpdate)
           
CoordinatorStore(Store store, boolean selectForUpdate)
           
 
Method Summary
 void close()
           
 void commit()
           
 CoordinatorActionBean getAction(String id, boolean b)
           
 List<CoordinatorActionBean> getActionsForCoordinatorJob(String jobId, boolean locking)
          Loads all actions for the given Coordinator job.
 List<CoordinatorActionBean> getActionsSubsetForCoordinatorJob(String jobId, int start, int len)
          Loads given number of actions for the given Coordinator job.
protected  CoordinatorActionBean getBeanForRunningCoordAction(CoordinatorActionBean a)
           
 CoordinatorActionBean getCoordActionForNominalTime(String jobId, Date nominalTime)
          Get coordinator action bean for given date
 List<CoordinatorActionBean> getCoordActionsForDates(String jobId, Date startDate, Date endDate)
          Get coordinator action beans for given start date and end date
 CoordinatorActionBean getCoordinatorAction(String id, boolean locking)
          Load the CoordinatorAction into a Bean and return it.
 CoordinatorActionBean getCoordinatorActionForExternalId(String externalId)
           
 List<CoordinatorActionBean> getCoordinatorActionsForJob(String id, int numResults, String executionOrder)
          Return CoordinatorActions for a jobID.
 CoordinatorJobInfo getCoordinatorInfo(Map<String,List<String>> filter, int start, int len)
           
 CoordinatorJobBean getCoordinatorJob(String id, boolean locking)
          Load the CoordinatorJob into a Bean and return it.
 CoordinatorJobBean getCoordinatorJobs(String id)
           
 List<CoordinatorJobBean> getCoordinatorJobsOlderThanStatus(long checkAgeSecs, String status, int limit, boolean locking)
          A list of Coordinator Jobs that are matched with the status and have last materialized time' older than checkAgeSecs will be returned.
 List<CoordinatorJobBean> getCoordinatorJobsToBeMaterialized(Date d, int limit)
          Get a list of Coordinator Jobs that should be materialized.
 int getCoordinatorRunningActionsCount(String id)
          Return CoordinatorActions for a jobID.
 List<String> getRecoveryActionsGroupByJobId(long checkAgeSecs)
           
 List<CoordinatorActionBean> getRecoveryActionsOlderThan(long checkAgeSecs, boolean locking)
           
 List<CoordinatorActionBean> getRunningActionsForCoordinatorJob(String jobId, boolean locking)
           
 List<CoordinatorActionBean> getRunningActionsOlderThan(long checkAgeSecs, boolean locking)
           
 void insertCoordinatorAction(CoordinatorActionBean action)
          Create a new Action record in the ACTIONS table with the given Bean.
 void insertCoordinatorJob(CoordinatorJobBean coordinatorJob)
          Create a CoordJobBean.
 void purge(long olderThanDays, int limit)
          Purge the coordinators completed older than given days.
 void updateCoordActionMin(CoordinatorActionBean action)
          Update the given action bean to DB.
 void updateCoordinatorAction(CoordinatorActionBean action)
          Update the given action bean to DB.
 void updateCoordinatorJob(CoordinatorJobBean job)
          Update the given coordinator job bean to DB.
 void updateCoordinatorJobStatus(CoordinatorJobBean job)
           
 
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

CoordinatorStore

public CoordinatorStore(boolean selectForUpdate)
                 throws StoreException
Throws:
StoreException

CoordinatorStore

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

insertCoordinatorJob

public void insertCoordinatorJob(CoordinatorJobBean coordinatorJob)
                          throws StoreException
Create a CoordJobBean. It also creates the process instance for the job.

Parameters:
workflow - workflow bean
Throws:
StoreException

getCoordinatorJob

public CoordinatorJobBean getCoordinatorJob(String id,
                                            boolean locking)
                                     throws StoreException
Load the CoordinatorJob 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 - Job ID
locking - Flag for Table Lock
Returns:
CoordinatorJobBean
Throws:
StoreException

getCoordinatorJobsToBeMaterialized

public List<CoordinatorJobBean> getCoordinatorJobsToBeMaterialized(Date d,
                                                                   int limit)
                                                            throws StoreException
Get a list of Coordinator Jobs that should be materialized. Jobs with a 'last materialized time' older than the argument will be returned.

Parameters:
d - Date
Returns:
List of Coordinator Jobs that have a last materialized time older than input date
Throws:
StoreException

getCoordinatorJobsOlderThanStatus

public List<CoordinatorJobBean> getCoordinatorJobsOlderThanStatus(long checkAgeSecs,
                                                                  String status,
                                                                  int limit,
                                                                  boolean locking)
                                                           throws StoreException
A list of Coordinator Jobs that are matched with the status and have last materialized time' older than checkAgeSecs will be returned.

Parameters:
checkAgeSecs - Job age in Seconds
status - Coordinator Job Status
limit - Number of results to return
locking - Flag for Table Lock
Returns:
List of Coordinator Jobs that are matched with the parameters.
Throws:
StoreException

getCoordinatorAction

public CoordinatorActionBean getCoordinatorAction(String id,
                                                  boolean locking)
                                           throws StoreException
Load the CoordinatorAction into a Bean and return it.

Parameters:
id - action ID
Returns:
CoordinatorActionBean
Throws:
StoreException

getCoordinatorActionsForJob

public List<CoordinatorActionBean> getCoordinatorActionsForJob(String id,
                                                               int numResults,
                                                               String executionOrder)
                                                        throws StoreException
Return CoordinatorActions for a jobID. Action should be in READY state. Number of returned actions should be <= concurrency number. Sort returned actions based on execution order (FIFO, LIFO, LAST_ONLY)

Parameters:
id - job ID
numResults - number of results to return
executionOrder - execution for this job - FIFO, LIFO, LAST_ONLY
Returns:
List of CoordinatorActionBean
Throws:
StoreException

getCoordinatorRunningActionsCount

public int getCoordinatorRunningActionsCount(String id)
                                      throws StoreException
Return CoordinatorActions for a jobID. Action should be in READY state. Number of returned actions should be <= concurrency number.

Parameters:
id - job ID
Returns:
Number of running actions
Throws:
StoreException

insertCoordinatorAction

public void insertCoordinatorAction(CoordinatorActionBean 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

updateCoordinatorAction

public void updateCoordinatorAction(CoordinatorActionBean action)
                             throws StoreException
Update the given action bean to DB.

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

updateCoordActionMin

public void updateCoordActionMin(CoordinatorActionBean action)
                          throws StoreException
Update the given action bean to DB.

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

updateCoordinatorJob

public void updateCoordinatorJob(CoordinatorJobBean job)
                          throws StoreException
Update the given coordinator job bean to DB.

Parameters:
jobbean - Coordinator Job Bean
Throws:
StoreException - if action doesn't exist

updateCoordinatorJobStatus

public void updateCoordinatorJobStatus(CoordinatorJobBean job)
                                throws StoreException
Throws:
StoreException

purge

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

Parameters:
olderThanDays - number of days for which to preserve the coordinators
limit - maximum number of coordinator jobs to be purged
Throws:
StoreException

commit

public void commit()
            throws StoreException
Throws:
StoreException

close

public void close()
           throws StoreException
Throws:
StoreException

getCoordinatorJobs

public CoordinatorJobBean getCoordinatorJobs(String id)

getCoordinatorInfo

public CoordinatorJobInfo getCoordinatorInfo(Map<String,List<String>> filter,
                                             int start,
                                             int len)
                                      throws StoreException
Throws:
StoreException

getActionsForCoordinatorJob

public List<CoordinatorActionBean> getActionsForCoordinatorJob(String jobId,
                                                               boolean locking)
                                                        throws StoreException
Loads all actions for the given Coordinator job.

Parameters:
jobId - coordinator job id
locking - true if Actions are to be locked
Returns:
A List of CoordinatorActionBean
Throws:
StoreException

getActionsSubsetForCoordinatorJob

public List<CoordinatorActionBean> getActionsSubsetForCoordinatorJob(String jobId,
                                                                     int start,
                                                                     int len)
                                                              throws StoreException
Loads given number of actions for the given Coordinator job.

Parameters:
jobId - coordinator job id
start - offset for select statement
len - number of Workflow Actions to be returned
Returns:
A List of CoordinatorActionBean
Throws:
StoreException

getBeanForRunningCoordAction

protected CoordinatorActionBean getBeanForRunningCoordAction(CoordinatorActionBean a)

getAction

public CoordinatorActionBean getAction(String id,
                                       boolean b)

getCoordinatorActionForExternalId

public CoordinatorActionBean getCoordinatorActionForExternalId(String externalId)
                                                        throws StoreException
Throws:
StoreException

getRunningActionsForCoordinatorJob

public List<CoordinatorActionBean> getRunningActionsForCoordinatorJob(String jobId,
                                                                      boolean locking)
                                                               throws StoreException
Throws:
StoreException

getRunningActionsOlderThan

public List<CoordinatorActionBean> getRunningActionsOlderThan(long checkAgeSecs,
                                                              boolean locking)
                                                       throws StoreException
Throws:
StoreException

getRecoveryActionsOlderThan

public List<CoordinatorActionBean> getRecoveryActionsOlderThan(long checkAgeSecs,
                                                               boolean locking)
                                                        throws StoreException
Throws:
StoreException

getCoordActionsForDates

public List<CoordinatorActionBean> getCoordActionsForDates(String jobId,
                                                           Date startDate,
                                                           Date endDate)
                                                    throws StoreException
Get coordinator action beans for given start date and end date

Parameters:
startDate -
endDate -
Returns:
list of coordinator action beans
Throws:
StoreException

getCoordActionForNominalTime

public CoordinatorActionBean getCoordActionForNominalTime(String jobId,
                                                          Date nominalTime)
                                                   throws StoreException
Get coordinator action bean for given date

Parameters:
nominalTime -
Returns:
CoordinatorActionBean
Throws:
StoreException

getRecoveryActionsGroupByJobId

public List<String> getRecoveryActionsGroupByJobId(long checkAgeSecs)
                                            throws StoreException
Throws:
StoreException


Copyright © 2012 Apache Software Foundation. All Rights Reserved.