Examples of SLARegistrationBean


Examples of org.apache.oozie.sla.SLARegistrationBean

        super.tearDown();
    }

    public void testGetUpdateQuery() throws Exception {
        EntityManager em = jpaService.getEntityManager();
        SLARegistrationBean bean = addRecordToSLARegistrationTable("test-application", SLAStatus.MET);

        // UPDATE_SLA_REG_ALL
        Query query = SLARegistrationQueryExecutor.getInstance().getUpdateQuery(SLARegQuery.UPDATE_SLA_REG_ALL, bean,
                em);

        assertEquals(query.getParameterValue("jobId"), bean.getId());
        assertEquals(query.getParameterValue("nominalTime"), bean.getNominalTimestamp());
        assertEquals(query.getParameterValue("expectedStartTime"), bean.getExpectedStartTimestamp());
        assertEquals(query.getParameterValue("expectedEndTime"), bean.getExpectedEndTimestamp());
        assertEquals(query.getParameterValue("expectedDuration"), bean.getExpectedDuration());
        assertEquals(query.getParameterValue("slaConfig"), bean.getSlaConfig());
        assertEquals(query.getParameterValue("notificationMsg"), bean.getNotificationMsg());
        assertEquals(query.getParameterValue("upstreamApps"), bean.getUpstreamApps());
        assertEquals(query.getParameterValue("appType"), bean.getAppType().toString());
        assertEquals(query.getParameterValue("appName"), bean.getAppName());
        assertEquals(query.getParameterValue("user"), bean.getUser());
        assertEquals(query.getParameterValue("parentId"), bean.getParentId());
        assertEquals(query.getParameterValue("jobData"), bean.getJobData());

        em.close();
    }
View Full Code Here

Examples of org.apache.oozie.sla.SLARegistrationBean

        em.close();
    }

    public void testGetSelectQuery() throws Exception {
        EntityManager em = jpaService.getEntityManager();
        SLARegistrationBean bean = addRecordToSLARegistrationTable("test-application", SLAStatus.MET);
        // GET_SLA_REG_ALL
        Query query = SLARegistrationQueryExecutor.getInstance().getSelectQuery(SLARegQuery.GET_SLA_REG_ALL, em,
                bean.getId());
        assertEquals(query.getParameterValue("id"), bean.getId());

        // GET_WORKFLOW_SUSPEND
        query = SLARegistrationQueryExecutor.getInstance().getSelectQuery(SLARegQuery.GET_SLA_REG_ON_RESTART, em,
                bean.getId());
        assertEquals(query.getParameterValue("id"), bean.getId());
    }
View Full Code Here

Examples of org.apache.oozie.sla.SLARegistrationBean

        msgs = greenMail.getReceivedMessages();
        assertEquals(msgs.length, 1);
    }

    private SLACalcStatus _createSLACalcStatus(String actionId) {
        SLARegistrationBean reg = new SLARegistrationBean();
        reg.setId(actionId);
        reg.setAppType(AppType.COORDINATOR_ACTION);
        return new SLACalcStatus(reg);
    }
View Full Code Here

Examples of org.apache.oozie.sla.SLARegistrationBean

        Query query = getSelectQuery(namedQuery, em, parameters);
        Object ret = jpaService.executeGet(namedQuery.name(), query, em);
        if (ret == null && !namedQuery.equals(SLARegQuery.GET_SLA_REG_ALL)) {
            throw new JPAExecutorException(ErrorCode.E0604, query.toString());
        }
        SLARegistrationBean bean = constructBean(namedQuery, ret, parameters);
        return bean;
    }
View Full Code Here

Examples of org.apache.oozie.sla.SLARegistrationBean

        return beanList;
    }

    private SLARegistrationBean constructBean(SLARegQuery namedQuery, Object ret, Object... parameters)
            throws JPAExecutorException {
        SLARegistrationBean bean;
        Object[] arr;
        switch (namedQuery) {
            case GET_SLA_REG_ALL:
                bean = (SLARegistrationBean) ret;
                if(bean != null) {
                    bean.setSlaConfig(bean.getSlaConfig());
                }
                break;
            case GET_SLA_REG_ON_RESTART:
                bean = new SLARegistrationBean();
                arr = (Object[]) ret;
                bean.setNotificationMsg((String) arr[0]);
                bean.setUpstreamApps((String) arr[1]);
                bean.setSlaConfig((String) arr[2]);
                bean.setJobData((String) arr[3]);
                break;
            default:
                throw new JPAExecutorException(ErrorCode.E0603, "QueryExecutor cannot construct job bean for "
                        + namedQuery.name());
        }
View Full Code Here

Examples of org.apache.oozie.sla.SLARegistrationBean

            if (afterDate.compareTo(bean.getNominalTime()) <= 0) {
                // delete SLA registration entry (if any) for action
                if (SLAService.isEnabled()) {
                    Services.get().get(SLAService.class).removeRegistration(actionId);
                }
                SLARegistrationBean slaReg = SLARegistrationQueryExecutor.getInstance().get(SLARegQuery.GET_SLA_REG_ALL, actionId);
                if (slaReg != null) {
                    LOG.debug("Deleting registration bean corresponding to action " + slaReg.getId());
                    deleteList.add(slaReg);
                }
                SLASummaryBean slaSummaryBean = SLASummaryQueryExecutor.getInstance().get(
                        SLASummaryQuery.GET_SLA_SUMMARY, actionId);
                if (slaSummaryBean != null) {
View Full Code Here

Examples of org.apache.oozie.sla.SLARegistrationBean

     * @return
     * @throws Exception
     */
    protected SLARegistrationBean addRecordToSLARegistrationTable(String appName, SLAStatus status)
            throws Exception {
        SLARegistrationBean sla = new SLARegistrationBean();
        Date today = new Date();
        sla.setId(Services.get().get(UUIDService.class).generateId(ApplicationType.COORDINATOR));
        sla.setAppName(appName);
        sla.setAppType(AppType.COORDINATOR_JOB);
        sla.setExpectedDuration(100);
        sla.setExpectedEnd(today);
        sla.setExpectedStart(today);
        sla.setJobData("test-job-data");
        sla.setCreatedTime(today);
        sla.setNominalTime(today);
        sla.setNotificationMsg("test-sla-notification-msg");
        sla.setParentId(Services.get().get(UUIDService.class).generateId(ApplicationType.BUNDLE));
        sla.setSlaConfig("alert-events");
        sla.setUpstreamApps("test-upstream-apps");
        sla.setUser("oozie");
        try {
            SLARegistrationQueryExecutor.getInstance().insert(sla);
        }
        catch (JPAExecutorException je) {
            je.printStackTrace();
View Full Code Here

Examples of org.apache.oozie.sla.SLARegistrationBean

        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

Examples of org.apache.oozie.sla.SLARegistrationBean

        }
    }

    public void testSlaConfigStringToMap() {
        String slaConfig = "{alert_contact=hadoopqa@oozie.com},{alert_events=START_MISS,DURATION_MISS,END_MISS},";
        SLARegistrationBean bean = new SLARegistrationBean();
        bean.setSlaConfig(slaConfig);
        assertEquals(bean.getSlaConfigMap().size(), 2);
        assertEquals(bean.getAlertEvents(), "START_MISS,DURATION_MISS,END_MISS");
        assertEquals(bean.getAlertContact(), "hadoopqa@oozie.com");
    }
View Full Code Here

Examples of org.apache.oozie.sla.SLARegistrationBean

    }

    public void testOnStartMiss() throws Exception {
        String id = "0000000-000000000000001-oozie-wrkf-C@1";
        SLACalcStatus event = _createSLACalcStatus(id);
        SLARegistrationBean eventBean = event.getSLARegistrationBean();
        Date startDate = DateUtils.parseDateUTC("2013-01-01T00:00Z");
        Date actualstartDate = DateUtils.parseDateUTC("2013-01-01T01:00Z");
        event.setEventStatus(EventStatus.START_MISS);
        event.setJobStatus(JobEvent.EventStatus.STARTED.toString());
        event.setId(id);
        eventBean.setParentId("0000000-000000000000001-oozie-wrkf-C");
        eventBean.setAppName("Test-SLA-Start-Miss");
        eventBean.setUser("dummyuser");
        eventBean.setNominalTime(startDate);
        eventBean.setExpectedStart(startDate);
        eventBean.setNotificationMsg("Notification of Missing Expected Start Time");
        eventBean.setAlertContact("alert-receiver@oozie.com");
        event.setActualStart(actualstartDate);
        eventBean.setAppType(AppType.COORDINATOR_ACTION);

        slaEmailListener.onStartMiss(event);

        MimeMessage[] msgs = greenMail.getReceivedMessages();
        MimeMessage msg = msgs[0];
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.