use of org.apache.oozie.WorkflowJobBean in project oozie by apache.
the class MockDagEngineService method createDummyWorkflow.
private static WorkflowJob createDummyWorkflow(int idx, String conf) {
WorkflowJobBean workflow = new WorkflowJobBean();
workflow.setId(JOB_ID + idx + JOB_ID_END);
workflow.setAppPath("hdfs://blah/blah/" + idx + "-blah");
workflow.setStatus((idx % 2) == 0 ? WorkflowJob.Status.RUNNING : WorkflowJob.Status.SUCCEEDED);
workflow.setRun(idx);
workflow.setCreatedTime(new Date());
workflow.setStartTime(new Date());
workflow.setEndTime((idx % 2) == 0 ? null : (new Date()));
workflow.setConf(conf);
workflow.setAppName("workflow-" + idx);
workflow.setGroup(GROUP);
workflow.setUser(USER);
List<WorkflowActionBean> actions = new ArrayList<WorkflowActionBean>();
for (int i = 0; i < idx; i++) {
actions.add(createDummyAction(i));
}
workflow.setActions(actions);
return workflow;
}
use of org.apache.oozie.WorkflowJobBean in project oozie by apache.
the class TestStatusTransitService method addRecordToWfJobTable.
protected WorkflowJobBean addRecordToWfJobTable(String wfId, WorkflowJob.Status jobStatus, WorkflowInstance.Status instanceStatus) throws Exception {
WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
Configuration conf = new Configuration();
Path appUri = new Path(getAppPath(), "workflow.xml");
conf.set(OozieClient.APP_PATH, appUri.toString());
conf.set(OozieClient.LOG_TOKEN, "testToken");
conf.set(OozieClient.USER_NAME, getTestUser());
WorkflowJobBean wfBean = createWorkflow(app, conf, jobStatus, instanceStatus);
wfBean.setId(wfId);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowJobInsertJPAExecutor wfInsertCmd = new WorkflowJobInsertJPAExecutor(wfBean);
jpaService.execute(wfInsertCmd);
} catch (JPAExecutorException je) {
je.printStackTrace();
fail("Unable to insert the test wf job record to table");
throw je;
}
return wfBean;
}
use of org.apache.oozie.WorkflowJobBean in project oozie by apache.
the class TestStatusTransitService method testBundleStatusTransitServiceRunningWithError.
/**
* Test : kill one coord job and keep the other running. Check whether the bundle job's status
* is updated to RUNNINGWITHERROR
* @throws Exception
*/
public void testBundleStatusTransitServiceRunningWithError() throws Exception {
Services.get().destroy();
setSystemProperty(StatusTransitService.CONF_BACKWARD_SUPPORT_FOR_STATES_WITHOUT_ERROR, "false");
services = new Services();
setClassesToBeExcluded(services.getConf(), excludedServices);
services.init();
BundleJobBean bundleJob = this.addRecordToBundleJobTable(Job.Status.RUNNING, true);
final JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
final String bundleId = bundleJob.getId();
addRecordToBundleActionTable(bundleId, "action1-C", 1, Job.Status.RUNNING);
addRecordToBundleActionTable(bundleId, "action2-C", 1, Job.Status.RUNNING);
String currentDatePlusMonth = XDataTestCase.getCurrentDateafterIncrementingInMonths(1);
Date start = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
Date end = DateUtils.parseDateOozieTZ(currentDatePlusMonth);
addRecordToCoordJobTableWithBundle(bundleId, "action1-C", CoordinatorJob.Status.RUNNING, start, end, false, true, 2);
addRecordToCoordJobTableWithBundle(bundleId, "action2-C", CoordinatorJob.Status.RUNNING, start, end, true, false, 2);
WorkflowJobBean wfJob1_1 = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowJobBean wfJob1_2 = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowJobBean wfJob1_3 = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowJobBean wfJob1_4 = addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
final CoordinatorActionBean coordAction1_1 = addRecordToCoordActionTable("action1-C", 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJob1_1.getId(), wfJob1_1.getStatusStr(), 0);
final CoordinatorActionBean coordAction1_2 = addRecordToCoordActionTable("action1-C", 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJob1_2.getId(), wfJob1_2.getStatusStr(), 0);
final CoordinatorActionBean coordAction1_3 = addRecordToCoordActionTable("action2-C", 1, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJob1_3.getId(), wfJob1_3.getStatusStr(), 1);
final CoordinatorActionBean coordAction1_4 = addRecordToCoordActionTable("action2-C", 2, CoordinatorAction.Status.RUNNING, "coord-action-get.xml", wfJob1_4.getId(), wfJob1_4.getStatusStr(), 1);
new CoordKillXCommand("action1-C").call();
waitFor(5 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
WorkflowJobBean wfJob = jpaService.execute(new WorkflowJobGetJPAExecutor(coordAction1_1.getExternalId()));
return wfJob.getStatus().equals(Job.Status.KILLED);
}
});
Runnable runnable = new StatusTransitRunnable();
runnable.run();
waitFor(5 * 1000, new Predicate() {
public boolean evaluate() throws Exception {
BundleJobBean bundle = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
return bundle.isPending() == false;
}
});
bundleJob = jpaService.execute(new BundleJobGetJPAExecutor(bundleId));
assertTrue(bundleJob.isPending());
assertEquals(Job.Status.RUNNINGWITHERROR, bundleJob.getStatus());
BundleActionBean bundleAction1 = jpaService.execute(new BundleActionGetJPAExecutor(bundleId, "action1-C"));
assertFalse(bundleAction1.isPending());
assertEquals(Job.Status.KILLED, bundleAction1.getStatus());
CoordinatorJobBean coordJob1 = jpaService.execute(new CoordJobGetJPAExecutor("action1-C"));
assertFalse(coordJob1.isPending());
assertEquals(Job.Status.KILLED, coordJob1.getStatus());
BundleActionBean bundleAction2 = jpaService.execute(new BundleActionGetJPAExecutor(bundleId, "action2-C"));
assertTrue(bundleAction2.isPending());
assertEquals(Job.Status.RUNNING, bundleAction2.getStatus());
CoordinatorJobBean coordJob2 = jpaService.execute(new CoordJobGetJPAExecutor("action2-C"));
assertTrue(coordJob2.isPending());
assertEquals(Job.Status.RUNNING, coordJob2.getStatus());
}
use of org.apache.oozie.WorkflowJobBean in project oozie by apache.
the class TestAuthorizationService method testErrors.
public void testErrors() throws Exception {
init(false, true);
services.setService(ForTestAuthorizationService.class);
AuthorizationService as = services.get(AuthorizationService.class);
Configuration conf = new Configuration();
HadoopAccessorService has = Services.get().get(HadoopAccessorService.class);
URI uri = getFileSystem().getUri();
Configuration fsConf = has.createConfiguration(uri.getAuthority());
FileSystem fileSystem = has.createFileSystem(getTestUser(), uri, fsConf);
try {
as.authorizeForGroup(getTestUser3(), getTestGroup());
fail();
} catch (AuthorizationException ex) {
assertEquals(ErrorCode.E0502, ex.getErrorCode());
}
try {
as.authorizeForAdmin(getTestUser(), true);
fail();
} catch (AuthorizationException ex) {
assertEquals(ErrorCode.E0503, ex.getErrorCode());
}
try {
Path app = new Path(getFsTestCaseDir(), "w");
as.authorizeForApp(getTestUser(), getTestGroup(), app.toString(), conf);
fail();
} catch (AuthorizationException ex) {
assertEquals(ErrorCode.E0504, ex.getErrorCode());
}
try {
Path app = new Path(getFsTestCaseDir(), "w");
fileSystem.mkdirs(app);
as.authorizeForApp(getTestUser(), getTestGroup(), app.toString(), conf);
fail();
} catch (AuthorizationException ex) {
assertEquals(ErrorCode.E0505, ex.getErrorCode());
}
try {
Path app = new Path(getFsTestCaseDir(), "w");
Path wf = new Path(app, "workflow.xml");
fileSystem.mkdirs(wf);
as.authorizeForApp(getTestUser(), getTestGroup(), app.toString(), conf);
fail();
} catch (AuthorizationException ex) {
assertEquals(ErrorCode.E0506, ex.getErrorCode());
}
try {
Path app = new Path(getFsTestCaseDir(), "ww");
fileSystem.mkdirs(app);
Path wf = new Path(app, "workflow.xml");
fileSystem.create(wf).close();
FsPermission fsPermission = new FsPermission(FsAction.READ, FsAction.NONE, FsAction.NONE);
fileSystem.setPermission(app, fsPermission);
as.authorizeForApp(getTestUser2(), getTestGroup() + "-invalid", app.toString(), conf);
fail();
} catch (AuthorizationException ex) {
assertEquals(ErrorCode.E0507, ex.getErrorCode());
}
try {
as.authorizeForJob(getTestUser(), "1", true);
fail();
} catch (AuthorizationException ex) {
assertEquals(ErrorCode.E0604, ex.getErrorCode());
}
WorkflowJobBean job = this.addRecordToWfJobTable(WorkflowJob.Status.PREP, WorkflowInstance.Status.PREP);
try {
as.authorizeForJob(getTestUser3(), job.getId(), true);
fail();
} catch (AuthorizationException ex) {
assertEquals(ErrorCode.E0508, ex.getErrorCode());
}
}
use of org.apache.oozie.WorkflowJobBean in project oozie by apache.
the class DummySLACalculatorMemory method createWorkflow.
private WorkflowJobBean createWorkflow(String id) throws Exception {
List<JsonBean> insertList = new ArrayList<JsonBean>();
WorkflowJobBean workflow = new WorkflowJobBean();
workflow.setId(id);
workflow.setStatusStr("PREP");
workflow.setStartTime(new Date());
workflow.setSlaXml("<sla></sla>");
insertList.add(workflow);
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
return workflow;
}
Aggregations