use of org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor in project oozie by apache.
the class TestActionCheckXCommand method addRecordToWfActionTable.
@Override
protected WorkflowActionBean addRecordToWfActionTable(String wfId, String actionName, WorkflowAction.Status status) throws Exception {
WorkflowActionBean action = createWorkflowActionSetPending(wfId, status);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action);
jpaService.execute(actionInsertCmd);
} catch (JPAExecutorException ce) {
ce.printStackTrace();
fail("Unable to insert the test wf action record to table");
throw ce;
}
return action;
}
use of org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor in project oozie by apache.
the class TestActionStartXCommand method addRecordToWfActionTableWithEscapedStringAndCDATA.
/**
* Create workflow action with action configuration with CDATA section and escaped string as value in parameter.
*
* @param wfId workflow job id
* @param status action status
* @return workflow action bean
* @throws Exception thrown if failed to create workflow action
*/
private WorkflowActionBean addRecordToWfActionTableWithEscapedStringAndCDATA(String wfId, WorkflowAction.Status status) throws Exception {
WorkflowActionBean action = createWorkflowActionSetPendingWithEscapedStringAndCDATA(wfId, status);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action);
jpaService.execute(actionInsertCmd);
} catch (JPAExecutorException ce) {
ce.printStackTrace();
fail("Unable to insert the test wf action record to table");
}
return action;
}
use of org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor in project oozie by apache.
the class TestRecoveryService method testWorkflowActionRecoveryUserRetry.
/**
* Tests functionality of the Recovery Service Runnable command. </p> Starts an action with USER_RETRY status.
* Runs the recovery runnable, and ensures the state changes to OK and the job completes successfully.
*
* @throws Exception
*/
public void testWorkflowActionRecoveryUserRetry() throws Exception {
final JPAService jpaService = Services.get().get(JPAService.class);
WorkflowJobBean job1 = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action1 = this.addRecordToWfActionTable(job1.getId(), "1", WorkflowAction.Status.USER_RETRY);
WorkflowJobBean job2 = this.addRecordToWfJobTable(WorkflowJob.Status.RUNNING, WorkflowInstance.Status.RUNNING);
WorkflowActionBean action2 = createWorkflowActionSetPending(job2.getId(), WorkflowAction.Status.USER_RETRY);
// Default recovery created time is 7 days.
action2.setCreatedTime(new Date(new Date().getTime() - 8 * RecoveryService.ONE_DAY_MILLISCONDS));
WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action2);
jpaService.execute(actionInsertCmd);
Runnable recoveryRunnable = new RecoveryRunnable(0, 60, 60);
recoveryRunnable.run();
sleep(3000);
final WorkflowActionGetJPAExecutor wfActionGetCmd = new WorkflowActionGetJPAExecutor(action1.getId());
waitFor(5000, new Predicate() {
public boolean evaluate() throws Exception {
WorkflowActionBean a = jpaService.execute(wfActionGetCmd);
return a.getExternalId() != null;
}
});
action1 = jpaService.execute(wfActionGetCmd);
assertNotNull(action1.getExternalId());
assertEquals(WorkflowAction.Status.RUNNING, action1.getStatus());
// Action 2 should not get recover as it's created time is older then 7 days
action2 = WorkflowActionQueryExecutor.getInstance().get(WorkflowActionQuery.GET_ACTION, action2.getId());
assertNull(action2.getExternalId());
assertEquals(WorkflowAction.Status.USER_RETRY, action2.getStatus());
ActionExecutorContext context = new ActionXCommand.ActionExecutorContext(job1, action1, false, false);
MapReduceActionExecutor actionExecutor = new MapReduceActionExecutor();
Configuration conf = actionExecutor.createBaseHadoopConf(context, XmlUtils.parseXml(action1.getConf()));
String launcherId = action1.getExternalId();
waitUntilYarnAppDoneAndAssertSuccess(launcherId);
Map<String, String> actionData = LauncherHelper.getActionData(getFileSystem(), context.getActionDir(), conf);
assertTrue(LauncherHelper.hasIdSwap(actionData));
}
use of org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor in project oozie by apache.
the class TestRecoveryService method addRecordToWfActionTable.
@Override
protected WorkflowActionBean addRecordToWfActionTable(String wfId, String actionName, WorkflowAction.Status status) throws Exception {
WorkflowActionBean action = createWorkflowActionSetPending(wfId, status);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
WorkflowActionInsertJPAExecutor actionInsertCmd = new WorkflowActionInsertJPAExecutor(action);
jpaService.execute(actionInsertCmd);
} catch (JPAExecutorException ce) {
ce.printStackTrace();
fail("Unable to insert the test wf action record to table");
throw ce;
}
return action;
}
use of org.apache.oozie.executor.jpa.WorkflowActionInsertJPAExecutor in project oozie by apache.
the class TestSLACalculatorMemory method testWorkflowActionSLAStatusOnRestart.
@Test
public void testWorkflowActionSLAStatusOnRestart() throws Exception {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
SLACalculatorMemory slaCalcMemory = new SLACalculatorMemory();
slaCalcMemory.init(Services.get().get(ConfigurationService.class).getConf());
SLARegistrationBean slaRegBean1 = _createSLARegistration("job-W@1", AppType.WORKFLOW_ACTION);
String jobId1 = slaRegBean1.getId();
slaRegBean1.setExpectedEnd(sdf.parse("2013-03-07"));
slaRegBean1.setExpectedStart(sdf.parse("2012-03-07"));
slaCalcMemory.addRegistration(jobId1, slaRegBean1);
SLACalcStatus calc1 = slaCalcMemory.get(jobId1);
calc1.setEventProcessed(1);
calc1.setSLAStatus(SLAEvent.SLAStatus.IN_PROCESS);
calc1.setJobStatus(WorkflowAction.Status.RUNNING.name());
calc1.setLastModifiedTime(new Date());
SLASummaryBean slaSummaryBean = new SLASummaryBean(calc1);
SLASummaryQueryExecutor.getInstance().executeUpdate(SLASummaryQuery.UPDATE_SLA_SUMMARY_ALL, slaSummaryBean);
// Simulate a lost success event
WorkflowActionBean wab = new WorkflowActionBean();
wab.setId(jobId1);
wab.setStatus(WorkflowAction.Status.OK);
wab.setStartTime(sdf.parse("2012-02-07"));
wab.setEndTime(sdf.parse("2013-02-07"));
WorkflowActionInsertJPAExecutor wfInsertCmd = new WorkflowActionInsertJPAExecutor(wab);
jpaService.execute(wfInsertCmd);
slaCalcMemory = new SLACalculatorMemory();
slaCalcMemory.init(Services.get().get(ConfigurationService.class).getConf());
slaCalcMemory.updateAllSlaStatus();
assertEquals(0, slaCalcMemory.size());
SLASummaryBean slaSummary = SLASummaryQueryExecutor.getInstance().get(SLASummaryQuery.GET_SLA_SUMMARY, jobId1);
assertEquals("job-W@1", slaSummary.getId());
assertEquals(8, slaSummary.getEventProcessed());
assertEquals(AppType.WORKFLOW_ACTION, slaSummary.getAppType());
assertEquals("OK", slaSummary.getJobStatus());
assertEquals(SLAEvent.SLAStatus.MET, slaSummary.getSLAStatus());
assertEquals(sdf.parse("2012-02-07"), slaSummary.getActualStart());
assertEquals(sdf.parse("2013-02-07"), slaSummary.getActualEnd());
assertEquals(sdf.parse("2013-02-07").getTime() - sdf.parse("2012-02-07").getTime(), slaSummary.getActualDuration());
}
Aggregations