Package org.apache.oozie.sla

Examples of org.apache.oozie.sla.SLARegistrationBean


     */
    public static void updateRegistrationEvent(String jobId) throws CommandException, JPAExecutorException {
        JPAService jpaService = Services.get().get(JPAService.class);
        SLAService slaService = Services.get().get(SLAService.class);
        try {
            SLARegistrationBean reg = jpaService.execute(new SLARegistrationGetJPAExecutor(jobId));
            if (reg != null) { //handle coord rerun with different config without sla
                slaService.updateRegistrationEvent(reg);
            }
        }
        catch (ServiceException e) {
View Full Code Here


            regBeans = q.getResultList();
        }
        catch (Exception e) {
            throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
        }
        SLARegistrationBean slaRegBean = null;
        if (regBeans != null && regBeans.size() > 0) {
            slaRegBean = regBeans.get(0);
            slaRegBean.setSlaConfig(slaRegBean.getSlaConfig());
        }
        return slaRegBean;
    }
View Full Code Here

            throw new JPAExecutorException(ErrorCode.E0603, e.getMessage(), e);
        }
    }

    private SLARegistrationBean getBeanFromObj(Object[] arr) {
        SLARegistrationBean bean = new SLARegistrationBean();
        if (arr[0] != null) {
            bean.setNotificationMsg((String) arr[0]);
        }
        if (arr[1] != null) {
            bean.setUpstreamApps((String) arr[1]);
        }
        if (arr[2] != null) {
            bean.setSlaConfig((String) arr[2]);
        }
        if (arr[3] != null) {
            bean.setJobData((String) arr[3]);
        }
        return bean;
    }
View Full Code Here

            CoordinatorActionBean bean = jpaService.execute(new CoordActionGetJPAExecutor(actionId));
            // delete SLA registration entry (if any) for action
            if (SLAService.isEnabled()) {
                Services.get().get(SLAService.class).removeRegistration(actionId);
            }
            SLARegistrationBean slaReg = jpaService.execute(new SLARegistrationGetJPAExecutor(actionId));
            if (slaReg != null) {
                LOG.debug("Deleting registration bean corresponding to action " + slaReg.getId());
                deleteList.add(slaReg);
            }
            SLASummaryBean slaSummaryBean = jpaService.execute(new SLASummaryGetJPAExecutor(actionId));
            if (slaSummaryBean != null) {
                LOG.debug("Deleting summary bean corresponding to action " + slaSummaryBean.getId());
View Full Code Here

        CoordinatorActionBean ca3 = addRecordToCoordActionTable(job.getId(), 3, CoordinatorAction.Status.WAITING,
                "coord-action-get.xml", 0);
        CoordinatorActionBean ca4 = addRecordToCoordActionTable(job.getId(), 4, CoordinatorAction.Status.WAITING,
                "coord-action-get.xml", 0);

        SLARegistrationBean slaRegBean1 = new SLARegistrationBean();
        slaRegBean1.setId(ca1.getId());
        SLARegistrationBean slaRegBean2 = new SLARegistrationBean();
        slaRegBean2.setId(ca2.getId());
        SLARegistrationBean slaRegBean3 = new SLARegistrationBean();
        slaRegBean3.setId(ca3.getId());
        SLARegistrationBean slaRegBean4 = new SLARegistrationBean();
        slaRegBean4.setId(ca4.getId());
        SLASummaryBean slaSummaryBean1 = new SLASummaryBean();
        slaSummaryBean1.setId(ca1.getId());
        SLASummaryBean slaSummaryBean3 = new SLASummaryBean();
        slaSummaryBean3.setId(ca3.getId());
        List<JsonBean> insertList = new ArrayList<JsonBean>();
        insertList.add(slaRegBean1);
        insertList.add(slaRegBean2);
        insertList.add(slaRegBean3);
        insertList.add(slaRegBean4);
        insertList.add(slaSummaryBean1);
        insertList.add(slaSummaryBean3);

        JPAService jpaService = Services.get().get(JPAService.class);
        jpaService.execute(new SLACalculationInsertUpdateJPAExecutor(insertList, null));

        new CoordChangeXCommand(job.getId(), pauseTimeChangeStr).call();

        CoordJobGetJPAExecutor coordGetCmd = new CoordJobGetJPAExecutor(job.getId());
        CoordinatorJobBean coordJob = jpaService.execute(coordGetCmd);
        assertEquals(DateUtils.formatDateOozieTZ(coordJob.getPauseTime()), DateUtils.formatDateOozieTZ(pauseTime));
        assertEquals(Job.Status.RUNNING, coordJob.getStatus());
        assertEquals(2, coordJob.getLastActionNumber());
        try {
            jpaService.execute(new CoordJobGetActionByActionNumberJPAExecutor(job.getId(), 3));
            fail("Expected to fail as action 3 should have been deleted");
        }
        catch (JPAExecutorException jpae) {
            assertEquals(ErrorCode.E0603, jpae.getErrorCode());
            jpae.printStackTrace();
        }

        try {
            jpaService.execute(new CoordJobGetActionByActionNumberJPAExecutor(job.getId(), 4));
            fail("Expected to fail as action 4 should have been deleted");
        }
        catch (JPAExecutorException jpae) {
            assertEquals(ErrorCode.E0603, jpae.getErrorCode());
            jpae.printStackTrace();
        }

        slaRegBean1 = jpaService.execute(new SLARegistrationGetJPAExecutor(slaRegBean1.getId()));
        assertNotNull(slaRegBean1);
        slaRegBean2 = jpaService.execute(new SLARegistrationGetJPAExecutor(slaRegBean2.getId()));
        assertNotNull(slaRegBean2);
        slaRegBean3 = jpaService.execute(new SLARegistrationGetJPAExecutor(slaRegBean3.getId()));
        assertNull(slaRegBean3);
        slaRegBean4 = jpaService.execute(new SLARegistrationGetJPAExecutor(slaRegBean4.getId()));
        assertNull(slaRegBean4);
        slaSummaryBean3 = jpaService.execute(new SLASummaryGetJPAExecutor(slaSummaryBean3.getId()));
        assertNull(slaSummaryBean3);
        slaSummaryBean1 = jpaService.execute(new SLASummaryGetJPAExecutor(slaSummaryBean1.getId()));
        assertNotNull(slaSummaryBean1);
View Full Code Here

    }

    public void testSLARegistrationGetRecordsOnRestart() throws Exception {
        Date current = new Date();
        final String jobId = "0000000-" + current.getTime() + "-TestSLARegGetRestartJPAExecutor-W";
        SLARegistrationBean reg = new SLARegistrationBean();
        reg.setId(jobId);
        reg.setNotificationMsg("dummyMessage");
        reg.setUpstreamApps("upApps");
        reg.setAlertEvents("miss");
        reg.setAlertContact("abc@y.com");
        reg.setJobData("jobData");
        JPAService jpaService = Services.get().get(JPAService.class);
        List<JsonBean> insert = new ArrayList<JsonBean>();
        insert.add(reg);
        SLACalculationInsertUpdateJPAExecutor slaInsertCmd = new SLACalculationInsertUpdateJPAExecutor(insert, null);
        jpaService.execute(slaInsertCmd);
        assertNotNull(jpaService);
        SLARegistrationGetOnRestartJPAExecutor readCmd = new SLARegistrationGetOnRestartJPAExecutor(jobId);
        SLARegistrationBean bean = jpaService.execute(readCmd);
        assertEquals("dummyMessage", bean.getNotificationMsg());
        assertEquals ("upApps", bean.getUpstreamApps());
        assertEquals ("miss", bean.getAlertEvents());
        assertEquals ("abc@y.com", bean.getAlertContact());
        assertEquals ("jobData", bean.getJobData());
    }
View Full Code Here

                "alert@example.com");
        JPAService jpaService = Services.get().get(JPAService.class);
        assertNotNull(jpaService);

        SLARegistrationGetJPAExecutor readCmd = new SLARegistrationGetJPAExecutor(jobId);
        SLARegistrationBean bean = jpaService.execute(readCmd);
        assertEquals(jobId, bean.getId());
        assertEquals(AppType.WORKFLOW_JOB, bean.getAppType());
        assertEquals(current, bean.getExpectedStart());
        assertEquals(2, bean.getSlaConfigMap().size());
        assertEquals("END_MISS", bean.getAlertEvents());
        assertEquals("alert@example.com", bean.getAlertContact());
    }
View Full Code Here

        assertEquals("alert@example.com", bean.getAlertContact());
    }

    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);
View Full Code Here

TOP

Related Classes of org.apache.oozie.sla.SLARegistrationBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.