Search in sources :

Example 61 with WorkflowActionBean

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

the class WorkflowInfoWithActionsSubsetGetJPAExecutor method execute.

/* (non-Javadoc)
     * @see org.apache.oozie.executor.jpa.JPAExecutor#execute(javax.persistence.EntityManager)
     */
@Override
public WorkflowJobBean execute(EntityManager em) throws JPAExecutorException {
    try {
        JPAService jpaService = Services.get().get(JPAService.class);
        if (jpaService != null) {
            this.workflow = jpaService.execute(new WorkflowJobGetJPAExecutor(this.wfJobId));
        } else {
            throw new JPAExecutorException(ErrorCode.E0610, this.wfJobId);
        }
    } catch (Exception ex) {
        if (ex instanceof JPAExecutorException) {
            throw (JPAExecutorException) ex;
        } else {
            throw new JPAExecutorException(ErrorCode.E0603, ex.getMessage(), ex);
        }
    }
    if (this.workflow != null) {
        JPAService jpaService = Services.get().get(JPAService.class);
        List<WorkflowActionBean> actionList;
        if (jpaService != null) {
            actionList = jpaService.execute(new WorkflowActionSubsetGetJPAExecutor(this.wfJobId, start, len));
        } else {
            throw new JPAExecutorException(ErrorCode.E0610, this.wfJobId);
        }
        this.workflow.setActions(actionList);
    } else {
        throw new JPAExecutorException(ErrorCode.E0604, wfJobId);
    }
    return this.workflow;
}
Also used : JPAService(org.apache.oozie.service.JPAService) CommandException(org.apache.oozie.command.CommandException) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 62 with WorkflowActionBean

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

the class WorkflowStore method getBeanForRunningAction.

private WorkflowActionBean getBeanForRunningAction(WorkflowActionBean a) throws SQLException {
    if (a != null) {
        WorkflowActionBean action = new WorkflowActionBean();
        action.setId(a.getId());
        action.setConfBlob(a.getConfBlob());
        action.setConsoleUrl(a.getConsoleUrl());
        action.setDataBlob(a.getDataBlob());
        action.setStatsBlob(a.getStatsBlob());
        action.setExternalChildIDsBlob(a.getExternalChildIDsBlob());
        action.setErrorInfo(a.getErrorCode(), a.getErrorMessage());
        action.setExternalId(a.getExternalId());
        action.setExternalStatus(a.getExternalStatus());
        action.setName(a.getName());
        action.setCred(a.getCred());
        action.setRetries(a.getRetries());
        action.setTrackerUri(a.getTrackerUri());
        action.setTransition(a.getTransition());
        action.setType(a.getType());
        action.setEndTime(a.getEndTime());
        action.setExecutionPath(a.getExecutionPath());
        action.setLastCheckTime(a.getLastCheckTime());
        action.setLogToken(a.getLogToken());
        if (a.isPending() == true) {
            action.setPending();
        }
        action.setPendingAge(a.getPendingAge());
        action.setSignalValue(a.getSignalValue());
        action.setSlaXmlBlob(a.getSlaXmlBlob());
        action.setStartTime(a.getStartTime());
        action.setStatus(a.getStatus());
        action.setJobId(a.getWfId());
        action.setUserRetryCount(a.getUserRetryCount());
        action.setUserRetryInterval(a.getUserRetryInterval());
        action.setUserRetryMax(a.getUserRetryMax());
        return action;
    }
    return null;
}
Also used : WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 63 with WorkflowActionBean

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

the class WorkflowStore method getAction.

/**
 * Load the action data and returns a bean.
 *
 * @param id Action Id
 * @param locking true if the action is to be locked
 * @return Action Bean
 * @throws StoreException If action doesn't exist
 */
public WorkflowActionBean getAction(final String id, final boolean locking) throws StoreException {
    ParamChecker.notEmpty(id, "ActionID");
    WorkflowActionBean action = doOperation("getAction", new Callable<WorkflowActionBean>() {

        public WorkflowActionBean call() throws SQLException, StoreException, WorkflowException, InterruptedException {
            Query q = entityManager.createNamedQuery("GET_ACTION");
            /*
                 * if (locking) { OpenJPAQuery oq = OpenJPAPersistence.cast(q);
                 * FetchPlan fetch = oq.getFetchPlan();
                 * fetch.setReadLockMode(LockModeType.WRITE);
                 * fetch.setLockTimeout(1000); // 1 seconds }
                 */
            WorkflowActionBean action = null;
            q.setParameter("id", id);
            List<WorkflowActionBean> actions = q.getResultList();
            // action = (WorkflowActionBean) q.getSingleResult();
            if (actions.size() > 0) {
                action = actions.get(0);
            } else {
                throw new StoreException(ErrorCode.E0605, id);
            }
            // return action;
            return getBeanForRunningAction(action);
        }
    });
    return action;
}
Also used : OpenJPAQuery(org.apache.openjpa.persistence.OpenJPAQuery) Query(javax.persistence.Query) SQLException(java.sql.SQLException) WorkflowException(org.apache.oozie.workflow.WorkflowException) ArrayList(java.util.ArrayList) List(java.util.List) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 64 with WorkflowActionBean

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

the class TestSLAJobEventListener method createWorkflowAction.

private WorkflowActionBean createWorkflowAction(String id, String parentId) throws Exception {
    List<JsonBean> insertList = new ArrayList<JsonBean>();
    WorkflowActionBean action = new WorkflowActionBean();
    action.setId(id);
    action.setJobId(parentId);
    insertList.add(action);
    BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
    return action;
}
Also used : JsonBean(org.apache.oozie.client.rest.JsonBean) ArrayList(java.util.ArrayList) WorkflowActionBean(org.apache.oozie.WorkflowActionBean)

Example 65 with WorkflowActionBean

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

the class XDataTestCase method createWorkflowAction.

/**
 * Create workflow action bean
 *
 * @param wfId workflow job id
 * @param actionName workflow action name
 * @param status workflow action status
 * @return workflow action bean
 * @throws Exception thrown if unable to create workflow action bean
 */
protected WorkflowActionBean createWorkflowAction(String wfId, String actionName, WorkflowAction.Status status, boolean pending) throws Exception {
    WorkflowActionBean action = new WorkflowActionBean();
    action.setName(actionName);
    action.setId(Services.get().get(UUIDService.class).generateChildId(wfId, actionName));
    action.setJobId(wfId);
    action.setType("map-reduce");
    action.setTransition("transition");
    action.setStatus(status);
    final Date currDate = new Date();
    action.setCreatedTime(currDate);
    action.setStartTime(currDate);
    action.setEndTime(currDate);
    action.setLastCheckTime(currDate);
    action.setStats("dummyStats");
    if (pending) {
        action.setPending();
    } else {
        action.resetPending();
    }
    Path inputDir = new Path(getFsTestCaseDir(), "input");
    Path outputDir = new Path(getFsTestCaseDir(), "output");
    FileSystem fs = getFileSystem();
    Writer w = new OutputStreamWriter(fs.create(new Path(inputDir, "data.txt")));
    w.write("dummy\n");
    w.write("dummy\n");
    w.close();
    String actionXml = "<map-reduce>" + "<job-tracker>" + getJobTrackerUri() + "</job-tracker>" + "<name-node>" + getNameNodeUri() + "</name-node>" + "<configuration>" + "<property><name>mapred.mapper.class</name><value>" + MapperReducerForTest.class.getName() + "</value></property>" + "<property><name>mapred.reducer.class</name><value>" + MapperReducerForTest.class.getName() + "</value></property>" + "<property><name>mapred.input.dir</name><value>" + inputDir.toString() + "</value></property>" + "<property><name>mapred.output.dir</name><value>" + outputDir.toString() + "</value></property>" + "</configuration>" + "</map-reduce>";
    action.setConf(actionXml);
    action.setSlaXml("<sla></sla>");
    action.setData("dummy data");
    action.setStats("dummy stats");
    action.setExternalChildIDs("job_201601011800_0001");
    action.setRetries(2);
    action.setUserRetryCount(1);
    action.setUserRetryMax(2);
    action.setUserRetryInterval(1);
    action.setErrorInfo("dummyErrorCode", "dummyErrorMessage");
    action.setExternalId("application_1234567890123_0001");
    action.setExternalStatus("RUNNING");
    return action;
}
Also used : Path(org.apache.hadoop.fs.Path) MapperReducerForTest(org.apache.oozie.action.hadoop.MapperReducerForTest) FileSystem(org.apache.hadoop.fs.FileSystem) OutputStreamWriter(java.io.OutputStreamWriter) WorkflowActionBean(org.apache.oozie.WorkflowActionBean) Date(java.util.Date) PrintWriter(java.io.PrintWriter) Writer(java.io.Writer) OutputStreamWriter(java.io.OutputStreamWriter) FileWriter(java.io.FileWriter)

Aggregations

WorkflowActionBean (org.apache.oozie.WorkflowActionBean)249 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)164 XConfiguration (org.apache.oozie.util.XConfiguration)84 JPAService (org.apache.oozie.service.JPAService)79 Configuration (org.apache.hadoop.conf.Configuration)56 JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)51 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)51 Path (org.apache.hadoop.fs.Path)48 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)42 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)32 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)32 ArrayList (java.util.ArrayList)30 Date (java.util.Date)29 Element (org.jdom.Element)29 FileSystem (org.apache.hadoop.fs.FileSystem)25 Writer (java.io.Writer)22 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)21 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)21 IOException (java.io.IOException)20 ActionExecutorException (org.apache.oozie.action.ActionExecutorException)18