use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class SLASummaryGetRecordsOnRestartJPAExecutor method execute.
@SuppressWarnings("unchecked")
@Override
public List<SLASummaryBean> execute(EntityManager em) throws JPAExecutorException {
List<SLASummaryBean> ssBean;
try {
Query q = em.createNamedQuery("GET_SLA_SUMMARY_RECORDS_RESTART");
Timestamp ts = new Timestamp(System.currentTimeMillis() - days * 24 * 60 * 60 * 1000);
q.setParameter("lastModifiedTime", ts);
ssBean = q.getResultList();
return ssBean;
} catch (Exception e) {
throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
}
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class SLACalculatorMemory method addRegistration.
/**
* Register a new job into the map for SLA tracking
* @return true if successful
*/
@Override
public boolean addRegistration(String jobId, SLARegistrationBean reg) throws JPAExecutorException {
try {
if (slaMap.size() < capacity) {
SLACalcStatus slaCalc = new SLACalcStatus(reg);
slaCalc.setSLAStatus(SLAStatus.NOT_STARTED);
slaCalc.setJobStatus(getJobStatus(reg.getAppType()));
List<JsonBean> insertList = new ArrayList<JsonBean>();
final SLASummaryBean summaryBean = new SLASummaryBean(slaCalc);
final Timestamp currentTime = DateUtils.convertDateToTimestamp(new Date());
reg.setCreatedTimestamp(currentTime);
summaryBean.setCreatedTimestamp(currentTime);
insertList.add(reg);
insertList.add(summaryBean);
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insertList, null, null);
putAndIncrement(jobId, slaCalc);
LOG.trace("SLA Registration Event - Job:" + jobId);
return true;
} else {
setLogPrefix(reg.getId());
LOG.error("SLACalculator memory capacity reached. Cannot add or update new SLA Registration entry for job [{0}]", reg.getId());
LogUtils.clearLogPrefix();
}
} catch (JPAExecutorException jpa) {
throw jpa;
}
return false;
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class SLAStore method getSLAEventListNewerSeqLimited.
/**
* Get a list of SLA Events newer than a specific sequence with limit
* clause.
*
* @param seqId sequence id
* @return List of SLA Events
* @throws StoreException
*/
public List<SLAEventBean> getSLAEventListNewerSeqLimited(final long seqId, final int limitLen, long[] lastSeqId) throws StoreException {
ParamChecker.notNull(seqId, "SLAEventListNewerSeqLimited");
ParamChecker.checkGTZero(limitLen, "SLAEventListNewerSeqLimited");
lastSeqId[0] = seqId;
List<SLAEventBean> seBeans = (List<SLAEventBean>) doOperation("getSLAEventListNewerSeqLimited", new Callable<List<SLAEventBean>>() {
public List<SLAEventBean> call() throws StoreException, JPAExecutorException {
List<SLAEventBean> seBeans;
try {
JPAService jpaService = Services.get().get(JPAService.class);
List<SLAEventBean> slaEventList = null;
long[] lastSeqId = new long[1];
if (jpaService != null) {
seBeans = jpaService.execute(new SLAEventsGetForSeqIdJPAExecutor(seqId, limitLen, lastSeqId));
} else {
throw new StoreException(ErrorCode.E0610);
}
} catch (IllegalStateException e) {
throw new StoreException(ErrorCode.E0601, e.getMessage(), e);
} catch (JPAExecutorException e) {
throw new JPAExecutorException(ErrorCode.E0610, e.getMessage(), e);
}
return seBeans;
}
});
List<SLAEventBean> eventList = new ArrayList<SLAEventBean>();
for (SLAEventBean j : seBeans) {
lastSeqId[0] = Math.max(lastSeqId[0], j.getEvent_id());
eventList.add(j);
}
return eventList;
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class TestSLARegistrationGetJPAExecutor method _addRecordToSLARegistrationTable.
private void _addRecordToSLARegistrationTable(String jobId, AppType appType, Date start, Date end, String alertEvent, String alertContact) throws Exception {
SLARegistrationBean reg = new SLARegistrationBean();
reg.setId(jobId);
reg.setAppType(appType);
reg.setExpectedStart(start);
reg.setExpectedEnd(end);
reg.setAlertEvents(alertEvent);
reg.setAlertContact(alertContact);
try {
JPAService jpaService = Services.get().get(JPAService.class);
assertNotNull(jpaService);
List<JsonBean> insert = new ArrayList<JsonBean>();
insert.add(reg);
BatchQueryExecutor.getInstance().executeBatchInsertUpdateDelete(insert, null, null);
} catch (JPAExecutorException je) {
fail("Unable to insert the test sla registration record to table");
throw je;
}
}
use of org.apache.oozie.executor.jpa.JPAExecutorException in project oozie by apache.
the class XDataTestCase method addRecordToWfJobTable.
protected WorkflowJobBean addRecordToWfJobTable(WorkflowApp app, WorkflowJob.Status jobStatus, WorkflowInstance.Status instanceStatus) throws Exception {
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);
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;
}
Aggregations