use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class HadoopELFunctions method hadoop_counters.
@SuppressWarnings("unchecked")
public static Map<String, Map<String, Long>> hadoop_counters(String nodeName) throws ELEvaluationException {
WorkflowInstance instance = DagELFunctions.getWorkflow().getWorkflowInstance();
Object obj = instance.getTransientVar(nodeName + WorkflowInstance.NODE_VAR_SEPARATOR + HADOOP_COUNTERS);
Map<String, Map<String, Long>> counters = (Map<String, Map<String, Long>>) obj;
if (counters == null) {
counters = getCounters(nodeName);
instance.setTransientVar(nodeName + WorkflowInstance.NODE_VAR_SEPARATOR + HADOOP_COUNTERS, counters);
}
return counters;
}
use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class TestCoordActionsKillXCommand method createDBRecords.
private String[] createDBRecords() throws Exception {
JPAService jpaService = services.get(JPAService.class);
Date startTime = DateUtils.parseDateOozieTZ("2013-08-01T23:59Z");
Date endTime = DateUtils.parseDateOozieTZ("2013-08-02T23:59Z");
CoordinatorJobBean job = addRecordToCoordJobTable(CoordinatorJob.Status.RUNNING, startTime, endTime, false, true, 0);
CoordinatorActionBean action1 = addRecordToCoordActionTable(job.getId(), 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
CoordinatorActionBean action2 = addRecordToCoordActionTable(job.getId(), 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", 0);
action2.setNominalTime(DateUtils.parseDateOozieTZ("2009-12-15T02:00Z"));
action2.setExternalId(null);
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQuery.UPDATE_COORD_ACTION, action2);
WorkflowJobBean wf = new WorkflowJobBean();
WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
wf.setId(action1.getExternalId());
wf.setStatus(WorkflowJob.Status.RUNNING);
WorkflowLib workflowLib = Services.get().get(WorkflowStoreService.class).getWorkflowLibWithNoDB();
WorkflowInstance wfInstance = workflowLib.createInstance(app, new XConfiguration());
((LiteWorkflowInstance) wfInstance).setStatus(WorkflowInstance.Status.RUNNING);
wf.setWorkflowInstance(wfInstance);
jpaService.execute(new WorkflowJobInsertJPAExecutor(wf));
return new String[] { job.getId(), action1.getId(), action2.getId(), wf.getId() };
}
use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class TestPurgeXCommand method testKillJobPurgeXCommand.
/**
* Test : purge killed wf job and action successfully
*
* @throws Exception
*/
public void testKillJobPurgeXCommand() throws Exception {
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.KILLED, WorkflowInstance.Status.KILLED);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.KILLED);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
job = jpaService.execute(wfJobGetCmd);
action = jpaService.execute(wfActionGetCmd);
assertEquals(job.getStatus(), WorkflowJob.Status.KILLED);
assertEquals(action.getStatus(), WorkflowAction.Status.KILLED);
WorkflowInstance wfInstance = job.getWorkflowInstance();
assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.KILLED);
new PurgeXCommand(7, 1, 1, 10).call();
try {
jpaService.execute(wfJobGetCmd);
fail("Workflow Job should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0604, je.getErrorCode());
}
try {
jpaService.execute(wfActionGetCmd);
fail("Workflow Action should have been purged");
} catch (JPAExecutorException je) {
assertEquals(ErrorCode.E0605, je.getErrorCode());
}
}
use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class TestPurgeXCommand method testPurgeXCommandFailed.
/**
* Test : purge wf job and action failed
*
* @throws Exception
*/
public void testPurgeXCommandFailed() throws Exception {
WorkflowJobBean job = this.addRecordToWfJobTableForNegCase(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action = this.addRecordToWfActionTable(job.getId(), "1", WorkflowAction.Status.RUNNING);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action.getId());
job = jpaService.execute(wfJobGetCmd);
action = jpaService.execute(wfActionGetCmd);
assertEquals(job.getStatus(), WorkflowJob.Status.RUNNING);
assertEquals(action.getStatus(), WorkflowAction.Status.RUNNING);
WorkflowInstance wfInstance = job.getWorkflowInstance();
assertEquals(wfInstance.getStatus(), WorkflowInstance.Status.RUNNING);
new PurgeXCommand(7, 1, 1, 10).call();
try {
jpaService.execute(wfJobGetCmd);
} catch (JPAExecutorException ce) {
ce.printStackTrace();
fail("Workflow Job should not have been purged");
}
try {
jpaService.execute(wfActionGetCmd);
} catch (JPAExecutorException ce) {
fail("Workflow Action should have been purged");
}
}
use of org.apache.oozie.workflow.WorkflowInstance in project oozie by apache.
the class TestPurgeXCommand method createWorkflow.
@Override
protected WorkflowJobBean createWorkflow(WorkflowApp app, Configuration conf, WorkflowJob.Status jobStatus, WorkflowInstance.Status instanceStatus) throws Exception {
WorkflowAppService wps = Services.get().get(WorkflowAppService.class);
Configuration protoActionConf = wps.createProtoActionConf(conf, true);
WorkflowLib workflowLib = Services.get().get(WorkflowStoreService.class).getWorkflowLibWithNoDB();
WorkflowInstance wfInstance = workflowLib.createInstance(app, conf);
((LiteWorkflowInstance) wfInstance).setStatus(instanceStatus);
WorkflowJobBean workflow = new WorkflowJobBean();
workflow.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.WORKFLOW));
workflow.setAppName(app.getName());
workflow.setAppPath(conf.get(OozieClient.APP_PATH));
workflow.setConf(XmlUtils.prettyPrint(conf).toString());
workflow.setProtoActionConf(XmlUtils.prettyPrint(protoActionConf).toString());
workflow.setCreatedTime(new Date());
workflow.setLogToken(conf.get(OozieClient.LOG_TOKEN, ""));
workflow.setStatus(jobStatus);
workflow.setRun(0);
workflow.setUser(conf.get(OozieClient.USER_NAME));
workflow.setGroup(conf.get(OozieClient.GROUP_NAME));
workflow.setWorkflowInstance(wfInstance);
workflow.setStartTime(DateUtils.parseDateOozieTZ("2009-12-18T01:00Z"));
workflow.setEndTime(DateUtils.parseDateOozieTZ("2009-12-18T03:00Z"));
return workflow;
}
Aggregations