Search in sources :

Example 66 with WorkflowJobBean

use of org.apache.oozie.WorkflowJobBean in project oozie by apache.

the class WorkflowsJobGetJPAExecutor method getBeanForWorkflowFromArray.

private WorkflowJobBean getBeanForWorkflowFromArray(Object[] arr) {
    WorkflowJobBean wfBean = new WorkflowJobBean();
    wfBean.setId((String) arr[0]);
    if (arr[1] != null) {
        wfBean.setAppName((String) arr[1]);
    }
    if (arr[2] != null) {
        wfBean.setStatus(Status.valueOf((String) arr[2]));
    }
    if (arr[3] != null) {
        wfBean.setRun((Integer) arr[3]);
    }
    if (arr[4] != null) {
        wfBean.setUser((String) arr[4]);
    }
    if (arr[5] != null) {
        wfBean.setGroup((String) arr[5]);
    }
    if (arr[6] != null) {
        wfBean.setCreatedTime((Timestamp) arr[6]);
    }
    if (arr[7] != null) {
        wfBean.setStartTime((Timestamp) arr[7]);
    }
    if (arr[8] != null) {
        wfBean.setLastModifiedTime((Timestamp) arr[8]);
    }
    if (arr[9] != null) {
        wfBean.setEndTime((Timestamp) arr[9]);
    }
    if (arr[10] != null) {
        wfBean.setExternalId((String) arr[10]);
    }
    if (arr[11] != null) {
        wfBean.setParentId((String) arr[11]);
    }
    return wfBean;
}
Also used : WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Example 67 with WorkflowJobBean

use of org.apache.oozie.WorkflowJobBean in project oozie by apache.

the class WorkflowStore method getWorkflowOnly.

private WorkflowJobBean getWorkflowOnly(final String id, boolean locking) throws SQLException, InterruptedException, StoreException {
    WorkflowJobBean wfBean = null;
    Query q = entityManager.createNamedQuery("GET_WORKFLOW");
    /*
         * if (locking) { // q.setHint("openjpa.FetchPlan.ReadLockMode","READ");
         * OpenJPAQuery oq = OpenJPAPersistence.cast(q); FetchPlan fetch =
         * oq.getFetchPlan(); fetch.setReadLockMode(LockModeType.WRITE);
         * fetch.setLockTimeout(-1); // unlimited }
         */
    q.setParameter("id", id);
    List<WorkflowJobBean> w = q.getResultList();
    if (w.size() > 0) {
        wfBean = w.get(0);
    }
    return wfBean;
// return getBeanForRunningWorkflow(wfBean);
}
Also used : OpenJPAQuery(org.apache.openjpa.persistence.OpenJPAQuery) Query(javax.persistence.Query) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Example 68 with WorkflowJobBean

use of org.apache.oozie.WorkflowJobBean in project oozie by apache.

the class WorkflowStore method getWorkflowInfo.

/**
 * Load the Workflow and all Action details and return a WorkflowJobBean. Workflow Instance is not loaded
 *
 * @param id Workflow Id
 * @return Workflow Bean
 * @throws StoreException If Workflow doesn't exist
 */
public WorkflowJobBean getWorkflowInfo(final String id) throws StoreException {
    ParamChecker.notEmpty(id, "WorkflowID");
    WorkflowJobBean wfBean = doOperation("getWorkflowInfo", new Callable<WorkflowJobBean>() {

        public WorkflowJobBean call() throws SQLException, StoreException, InterruptedException {
            WorkflowJobBean wfBean = null;
            wfBean = getWorkflowforInfo(id, false);
            if (wfBean == null) {
                throw new StoreException(ErrorCode.E0604, id);
            } else {
                wfBean.setActions(getActionsForWorkflow(id, false));
            }
            return wfBean;
        }
    });
    return wfBean;
}
Also used : SQLException(java.sql.SQLException) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Example 69 with WorkflowJobBean

use of org.apache.oozie.WorkflowJobBean in project oozie by apache.

the class WorkflowStore method getBeanForWorkflowFromArray.

private WorkflowJobBean getBeanForWorkflowFromArray(Object[] arr) {
    WorkflowJobBean wfBean = new WorkflowJobBean();
    wfBean.setId((String) arr[0]);
    if (arr[1] != null) {
        wfBean.setAppName((String) arr[1]);
    }
    if (arr[2] != null) {
        wfBean.setStatus(Status.valueOf((String) arr[2]));
    }
    if (arr[3] != null) {
        wfBean.setRun((Integer) arr[3]);
    }
    if (arr[4] != null) {
        wfBean.setUser((String) arr[4]);
    }
    if (arr[5] != null) {
        wfBean.setGroup((String) arr[5]);
    }
    if (arr[6] != null) {
        wfBean.setCreatedTime((Timestamp) arr[6]);
    }
    if (arr[7] != null) {
        wfBean.setStartTime((Timestamp) arr[7]);
    }
    if (arr[8] != null) {
        wfBean.setLastModifiedTime((Timestamp) arr[8]);
    }
    if (arr[9] != null) {
        wfBean.setEndTime((Timestamp) arr[9]);
    }
    return wfBean;
}
Also used : WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Example 70 with WorkflowJobBean

use of org.apache.oozie.WorkflowJobBean in project oozie by apache.

the class WorkflowStore method getWorkflow.

/**
 * 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.
 *
 * @param id Workflow ID
 * @param locking true if Workflow is to be locked
 * @return WorkflowJobBean
 * @throws StoreException
 */
public WorkflowJobBean getWorkflow(final String id, final boolean locking) throws StoreException {
    ParamChecker.notEmpty(id, "WorkflowID");
    WorkflowJobBean wfBean = doOperation("getWorkflow", new Callable<WorkflowJobBean>() {

        public WorkflowJobBean call() throws SQLException, StoreException, WorkflowException, InterruptedException {
            WorkflowJobBean wfBean = null;
            wfBean = getWorkflowOnly(id, locking);
            if (wfBean == null) {
                throw new StoreException(ErrorCode.E0604, id);
            }
            /*
                 * WorkflowInstance wfInstance; //krishna and next line
                 * wfInstance = workflowLib.get(id); wfInstance =
                 * wfBean.get(wfBean.getWfInstance());
                 * wfBean.setWorkflowInstance(wfInstance);
                 * wfBean.setWfInstance(wfInstance);
                 */
            return wfBean;
        }
    });
    return wfBean;
}
Also used : SQLException(java.sql.SQLException) WorkflowException(org.apache.oozie.workflow.WorkflowException) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Aggregations

WorkflowJobBean (org.apache.oozie.WorkflowJobBean)304 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)164 JPAService (org.apache.oozie.service.JPAService)95 XConfiguration (org.apache.oozie.util.XConfiguration)94 Configuration (org.apache.hadoop.conf.Configuration)66 Date (java.util.Date)60 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)58 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)57 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)53 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)53 Path (org.apache.hadoop.fs.Path)50 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)47 ArrayList (java.util.ArrayList)46 Test (org.junit.Test)32 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)30 Element (org.jdom.Element)28 WorkflowInstance (org.apache.oozie.workflow.WorkflowInstance)26 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)25 HashMap (java.util.HashMap)23 BundleJobBean (org.apache.oozie.BundleJobBean)21