Search in sources :

Example 56 with JPAExecutorException

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);
    }
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) Query(javax.persistence.Query) Timestamp(java.sql.Timestamp) SLASummaryBean(org.apache.oozie.sla.SLASummaryBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException)

Example 57 with JPAExecutorException

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;
}
Also used : JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JsonBean(org.apache.oozie.client.rest.JsonBean) ArrayList(java.util.ArrayList) Timestamp(java.sql.Timestamp) Date(java.util.Date)

Example 58 with JPAExecutorException

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;
}
Also used : SLAEventsGetForSeqIdJPAExecutor(org.apache.oozie.executor.jpa.SLAEventsGetForSeqIdJPAExecutor) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) JPAService(org.apache.oozie.service.JPAService) SLAEventBean(org.apache.oozie.SLAEventBean) Callable(java.util.concurrent.Callable)

Example 59 with JPAExecutorException

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;
    }
}
Also used : SLARegistrationBean(org.apache.oozie.sla.SLARegistrationBean) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) JsonBean(org.apache.oozie.client.rest.JsonBean) ArrayList(java.util.ArrayList) JPAService(org.apache.oozie.service.JPAService)

Example 60 with JPAExecutorException

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;
}
Also used : Path(org.apache.hadoop.fs.Path) JPAExecutorException(org.apache.oozie.executor.jpa.JPAExecutorException) Configuration(org.apache.hadoop.conf.Configuration) XConfiguration(org.apache.oozie.util.XConfiguration) WorkflowJobInsertJPAExecutor(org.apache.oozie.executor.jpa.WorkflowJobInsertJPAExecutor) JPAService(org.apache.oozie.service.JPAService) WorkflowJobBean(org.apache.oozie.WorkflowJobBean)

Aggregations

JPAExecutorException (org.apache.oozie.executor.jpa.JPAExecutorException)195 JPAService (org.apache.oozie.service.JPAService)137 CoordinatorJobBean (org.apache.oozie.CoordinatorJobBean)65 CommandException (org.apache.oozie.command.CommandException)63 CoordinatorActionBean (org.apache.oozie.CoordinatorActionBean)55 Date (java.util.Date)53 CoordJobGetJPAExecutor (org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor)49 WorkflowActionBean (org.apache.oozie.WorkflowActionBean)45 WorkflowJobBean (org.apache.oozie.WorkflowJobBean)43 CoordActionGetJPAExecutor (org.apache.oozie.executor.jpa.CoordActionGetJPAExecutor)37 WorkflowJobGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowJobGetJPAExecutor)33 WorkflowActionGetJPAExecutor (org.apache.oozie.executor.jpa.WorkflowActionGetJPAExecutor)31 IOException (java.io.IOException)26 BundleJobBean (org.apache.oozie.BundleJobBean)24 CoordJobInsertJPAExecutor (org.apache.oozie.executor.jpa.CoordJobInsertJPAExecutor)19 BundleActionBean (org.apache.oozie.BundleActionBean)18 Configuration (org.apache.hadoop.conf.Configuration)15 BundleJobGetJPAExecutor (org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor)15 BundleActionGetJPAExecutor (org.apache.oozie.executor.jpa.BundleActionGetJPAExecutor)14 XConfiguration (org.apache.oozie.util.XConfiguration)14