use of org.apache.oozie.command.wf.KillXCommand in project oozie by apache.
the class CoordActionsKillXCommand method killChildren.
@Override
public void killChildren() throws CommandException {
InstrumentUtils.incrJobCounter(getName(), 1, getInstrumentation());
for (CoordinatorActionBean coordAction : coordActions) {
coordAction.setStatus(CoordinatorAction.Status.KILLED);
coordAction.setLastModifiedTime(new Date());
// kill Workflow job associated with this Coord action
if (coordAction.getExternalId() != null) {
queue(new KillXCommand(coordAction.getExternalId()));
coordAction.incrementAndGetPending();
} else {
coordAction.setPending(0);
}
updateList.add(new UpdateEntry(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, coordAction));
if (EventHandlerService.isEnabled()) {
CoordinatorXCommand.generateEvent(coordAction, coordJob.getUser(), coordJob.getAppName(), coordAction.getCreatedTime());
}
queue(new CoordActionNotificationXCommand(coordAction), 100);
}
CoordinatorActionInfo coordInfo = new CoordinatorActionInfo(coordActions);
ret = coordInfo;
}
use of org.apache.oozie.command.wf.KillXCommand in project oozie by apache.
the class TestEventGeneration method testWorkflowJobEvent.
@Test
public void testWorkflowJobEvent() throws Exception {
assertEquals(0, queue.size());
WorkflowApp app = new LiteWorkflowApp("testApp", "<workflow-app/>", new StartNodeDef(LiteWorkflowStoreService.LiteControlNodeHandler.class, "fs-node")).addNode(new ActionNodeDef("fs-node", "", TestLiteWorkflowLib.TestActionNodeHandler.class, "end", "end")).addNode(new EndNodeDef("end", LiteWorkflowStoreService.LiteControlNodeHandler.class));
WorkflowJobBean job = addRecordToWfJobTable(app, WorkflowJob.Status.PREP, WorkflowInstance.Status.PREP);
// Starting job
new StartXCommand(job.getId()).call();
WorkflowJobGetJPAExecutor wfJobGetCmd = new WorkflowJobGetJPAExecutor(job.getId());
job = jpaService.execute(wfJobGetCmd);
assertEquals(WorkflowJob.Status.RUNNING, job.getStatus());
assertEquals(1, queue.size());
JobEvent event = (JobEvent) queue.poll();
assertNotNull(event);
assertEquals(EventStatus.STARTED, event.getEventStatus());
assertEquals(AppType.WORKFLOW_JOB, event.getAppType());
assertEquals(job.getId(), event.getId());
assertEquals(job.getUser(), event.getUser());
assertEquals(job.getAppName(), event.getAppName());
assertEquals(job.getStartTime(), event.getStartTime());
assertEquals(0, queue.size());
// Suspending job
new SuspendXCommand(job.getId()).call();
job = jpaService.execute(wfJobGetCmd);
assertEquals(WorkflowJob.Status.SUSPENDED, job.getStatus());
assertEquals(1, queue.size());
event = (JobEvent) queue.poll();
assertNotNull(event);
assertEquals(EventStatus.SUSPEND, event.getEventStatus());
assertEquals(AppType.WORKFLOW_JOB, event.getAppType());
assertEquals(job.getId(), event.getId());
assertEquals(job.getUser(), event.getUser());
assertEquals(job.getAppName(), event.getAppName());
assertEquals(0, queue.size());
// Resuming job
new ResumeXCommand(job.getId()).call();
job = jpaService.execute(wfJobGetCmd);
assertEquals(WorkflowJob.Status.RUNNING, job.getStatus());
assertEquals(1, queue.size());
event = (JobEvent) queue.poll();
assertNotNull(event);
assertEquals(AppType.WORKFLOW_JOB, event.getAppType());
assertEquals(job.getId(), event.getId());
assertEquals(job.getUser(), event.getUser());
assertEquals(job.getAppName(), event.getAppName());
assertEquals(job.getStartTime(), event.getStartTime());
assertEquals(0, queue.size());
// Killing job
new KillXCommand(job.getId()).call();
job = jpaService.execute(wfJobGetCmd);
assertEquals(WorkflowJob.Status.KILLED, job.getStatus());
assertEquals(1, queue.size());
event = (JobEvent) queue.poll();
assertNotNull(event);
assertEquals(EventStatus.FAILURE, event.getEventStatus());
assertEquals(AppType.WORKFLOW_JOB, event.getAppType());
assertEquals(job.getId(), event.getId());
assertEquals(job.getUser(), event.getUser());
assertEquals(job.getAppName(), event.getAppName());
assertEquals(job.getStartTime(), event.getStartTime());
assertEquals(job.getEndTime(), event.getEndTime());
assertEquals(0, queue.size());
// Successful job (testing SignalX)
job = _createWorkflowJob();
LiteWorkflowInstance wfInstance = (LiteWorkflowInstance) job.getWorkflowInstance();
wfInstance.start();
job.setWorkflowInstance(wfInstance);
WorkflowJobQueryExecutor.getInstance().executeUpdate(WorkflowJobQuery.UPDATE_WORKFLOW_STATUS_INSTANCE_MODIFIED, job);
WorkflowActionBean wfAction = jpaService.execute(new WorkflowActionGetJPAExecutor(job.getId() + "@one"));
new SignalXCommand(job.getId(), wfAction.getId()).call();
job = jpaService.execute(new WorkflowJobGetJPAExecutor(job.getId()));
assertEquals(WorkflowJob.Status.SUCCEEDED, job.getStatus());
assertEquals(1, queue.size());
event = (JobEvent) queue.poll();
assertNotNull(event);
assertEquals(AppType.WORKFLOW_JOB, event.getAppType());
assertEquals(job.getId(), event.getId());
assertEquals(job.getUser(), event.getUser());
assertEquals(job.getAppName(), event.getAppName());
assertEquals(job.getStartTime(), event.getStartTime());
assertEquals(job.getEndTime(), event.getEndTime());
}
use of org.apache.oozie.command.wf.KillXCommand in project oozie by apache.
the class DagEngine method kill.
/**
* Kill a job.
*
* @param jobId job Id.
* @throws DagEngineException thrown if the job could not be killed.
*/
@Override
public void kill(String jobId) throws DagEngineException {
// failure.
try {
new KillXCommand(jobId).call();
LOG.info("User " + user + " killed the WF job " + jobId);
} catch (CommandException e) {
throw new DagEngineException(e);
}
}
use of org.apache.oozie.command.wf.KillXCommand in project oozie by apache.
the class CoordKillXCommand method killChildren.
@Override
public void killChildren() throws CommandException {
if (actionList != null) {
for (CoordinatorActionBean action : actionList) {
// queue a WorkflowKillXCommand to delete the workflow job and actions
if (action.getExternalId() != null) {
queue(new KillXCommand(action.getExternalId()));
// As the kill command for children is queued, set pending flag for coord action to be true
updateCoordAction(action, true);
LOG.debug("Killed coord action = [{0}], new status = [{1}], pending = [{2}] and queue KillXCommand for [{3}]", action.getId(), action.getStatus(), action.getPending(), action.getExternalId());
} else {
// As killing children is not required, set pending flag for coord action to be false
updateCoordAction(action, false);
LOG.debug("Killed coord action = [{0}], current status = [{1}], pending = [{2}]", action.getId(), action.getStatus(), action.getPending());
}
String pushMissingDeps = action.getPushMissingDependencies();
if (pushMissingDeps != null) {
CoordPushDependencyCheckXCommand.unregisterMissingDependencies(Arrays.asList(DependencyChecker.dependenciesAsArray(pushMissingDeps)), action.getId());
}
}
}
coordJob.setDoneMaterialization();
coordJob.setLastModifiedTime(new Date());
LOG.debug("Killed coord actions for the coordinator=[{0}]", jobId);
}
use of org.apache.oozie.command.wf.KillXCommand in project oozie by apache.
the class TestEventGeneration method testWorkflowJobEventError.
@Test
public void testWorkflowJobEventError() throws Exception {
final WorkflowJobBean job = addRecordToWfJobTable(WorkflowJob.Status.FAILED, WorkflowInstance.Status.FAILED);
// create event with error code and message
WorkflowXCommand<Void> myCmd = new KillXCommand(job.getId()) {
@Override
protected Void execute() {
WorkflowXCommand.generateEvent(job, "errorCode", "errorMsg");
return null;
}
};
myCmd.call();
WorkflowJobEvent event = (WorkflowJobEvent) queue.poll();
assertNotNull(event);
assertEquals("errorCode", event.getErrorCode());
assertEquals("errorMsg", event.getErrorMessage());
assertEquals(EventStatus.FAILURE, event.getEventStatus());
}
Aggregations