use of org.apache.oozie.SLAEventBean in project oozie by apache.
the class SLAEventsXCommand method execute.
@Override
protected List<SLAEventBean> execute() throws CommandException {
try {
JPAService jpaService = Services.get().get(JPAService.class);
List<SLAEventBean> slaEventList = null;
long[] lastSeqId = new long[1];
if (jpaService != null) {
slaEventList = jpaService.execute(new SLAEventsGetForFilterJPAExecutor(seqId, maxNoEvents, filter, lastSeqId));
} else {
LOG.error(ErrorCode.E0610);
}
setLastSeqId(lastSeqId[0]);
return slaEventList;
} catch (XException ex) {
throw new CommandException(ex);
}
}
use of org.apache.oozie.SLAEventBean in project oozie by apache.
the class TestSLAEventsGetForFilterJPAExecutor method testGetSLAEventsWithRange.
public void testGetSLAEventsWithRange() throws Exception {
Map<String, List<String>> filterList = new HashMap();
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
long[] lastSeqId = new long[1];
lastSeqId[0] = -1;
SLAEventsGetForFilterJPAExecutor slaEventsGetCmd = new SLAEventsGetForFilterJPAExecutor(1, 3, filterList, lastSeqId);
List<SLAEventBean> list = jpaService.execute(slaEventsGetCmd);
assertNotNull(list);
assertEquals(3, list.size());
}
use of org.apache.oozie.SLAEventBean in project oozie by apache.
the class TestSLAEventsGetForFilterJPAExecutor method testGetSLAEventsForCombinedWithRange.
public void testGetSLAEventsForCombinedWithRange() throws Exception {
Map<String, List<String>> filterList = createFilterList("jobid", coordId1, coordActionId1, coordId2, coordActionId2);
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
long[] lastSeqId = new long[1];
lastSeqId[0] = -1;
SLAEventsGetForFilterJPAExecutor slaEventsGetCmd = new SLAEventsGetForFilterJPAExecutor(1, 3, filterList, lastSeqId);
List<SLAEventBean> list = jpaService.execute(slaEventsGetCmd);
assertNotNull(list);
assertEquals(3, list.size());
}
use of org.apache.oozie.SLAEventBean in project oozie by apache.
the class CoordActionUpdateXCommand method execute.
@Override
protected Void execute() throws CommandException {
try {
LOG.debug("STARTED CoordActionUpdateXCommand for wfId=[{0}]", workflow.getId());
final CoordinatorAction.Status formerCoordinatorStatus = coordAction.getStatus();
final int formerCoordinatorPending = coordAction.getPending();
Status slaStatus = null;
if (workflow.getStatus() == WorkflowJob.Status.SUCCEEDED) {
coordAction.setStatus(CoordinatorAction.Status.SUCCEEDED);
coordAction.setPending(0);
slaStatus = Status.SUCCEEDED;
} else if (workflow.getStatus() == WorkflowJob.Status.FAILED) {
coordAction.setStatus(CoordinatorAction.Status.FAILED);
coordAction.setPending(0);
slaStatus = Status.FAILED;
} else if (workflow.getStatus() == WorkflowJob.Status.KILLED) {
coordAction.setStatus(CoordinatorAction.Status.KILLED);
coordAction.setPending(0);
slaStatus = Status.KILLED;
} else if (workflow.getStatus() == WorkflowJob.Status.SUSPENDED) {
coordAction.setStatus(CoordinatorAction.Status.SUSPENDED);
coordAction.decrementAndGetPending();
} else if (workflow.getStatus() == WorkflowJob.Status.RUNNING || workflow.getStatus() == WorkflowJob.Status.PREP) {
// resume workflow job and update coord action accordingly
coordAction.setStatus(CoordinatorAction.Status.RUNNING);
coordAction.decrementAndGetPending();
} else {
LOG.warn("Unexpected workflow [{0}] STATUS [{1}]", workflow.getId(), workflow.getStatus());
// update lastModifiedTime
coordAction.setLastModifiedTime(new Date());
CoordActionQueryExecutor.getInstance().executeUpdate(CoordActionQueryExecutor.CoordActionQuery.UPDATE_COORD_ACTION_FOR_MODIFIED_DATE, coordAction);
/* CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(coordAction.getJobId()));
if (!coordJob.isPending()) {
coordJob.setPending();
jpaService.execute(new CoordJobUpdateJPAExecutor(coordJob));
}*/
return null;
}
LOG.info("Updating Coordinator action id: [{0}] status [{1}] to [{2}] pending [{3}] to [{4}]", coordAction.getId(), formerCoordinatorStatus, coordAction.getStatus(), formerCoordinatorPending, coordAction.getPending());
coordAction.setLastModifiedTime(new Date());
updateList.add(new UpdateEntry<CoordActionQuery>(CoordActionQuery.UPDATE_COORD_ACTION_STATUS_PENDING_TIME, coordAction));
/*CoordinatorJobBean coordJob = jpaService.execute(new CoordJobGetJPAExecutor(coordAction.getJobId()));
if (!coordJob.isPending()) {
coordJob.setPending();
jpaService.execute(new CoordJobUpdateJPAExecutor(coordJob));
LOG.info("Updating Coordinator job "+ coordJob.getId() + "pending to true");
}*/
if (slaStatus != null) {
SLAEventBean slaEvent = SLADbOperations.createStatusEvent(coordAction.getSlaXml(), coordAction.getId(), slaStatus, SlaAppType.COORDINATOR_ACTION, LOG);
if (slaEvent != null) {
insertList.add(slaEvent);
}
}
if (workflow.getStatus() != WorkflowJob.Status.SUSPENDED && workflow.getStatus() != WorkflowJob.Status.RUNNING) {
queue(new CoordActionReadyXCommand(coordAction.getJobId()));
}
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, updateList, null);
if (EventHandlerService.isEnabled()) {
generateEvent(coordAction, coordJob.getUser(), coordJob.getAppName(), workflow.getStartTime());
}
LOG.debug("ENDED CoordActionUpdateXCommand for wfId= [{0}]", workflow.getId());
} catch (XException ex) {
LOG.warn("CoordActionUpdate Failed [{0}]", ex.getMessage());
throw new CommandException(ex);
}
return null;
}
use of org.apache.oozie.SLAEventBean in project oozie by apache.
the class CoordMaterializeTransitionXCommand method writeActionSlaRegistration.
private void writeActionSlaRegistration(String actionXml, CoordinatorActionBean actionBean, Configuration jobConf) throws Exception {
Element eAction = XmlUtils.parseXml(actionXml);
Element eSla = eAction.getChild("action", eAction.getNamespace()).getChild("info", eAction.getNamespace("sla"));
SLAEventBean slaEvent = SLADbOperations.createSlaRegistrationEvent(eSla, actionBean.getId(), SlaAppType.COORDINATOR_ACTION, coordJob.getUser(), coordJob.getGroup(), LOG);
if (slaEvent != null) {
insertList.add(slaEvent);
}
// inserting into new table also
SLAOperations.createSlaRegistrationEvent(eSla, actionBean.getId(), actionBean.getJobId(), AppType.COORDINATOR_ACTION, coordJob.getUser(), coordJob.getAppName(), LOG, false, CoordUtils.isSlaAlertDisabled(actionBean, coordJob.getAppName(), jobConf));
}
Aggregations