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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations