Package org.apache.oozie.event

Examples of org.apache.oozie.event.WorkflowJobEvent


    public void testEventListener() throws Exception {
        EventHandlerService ehs = _testEventHandlerService();
        /*
         * Workflow Job events
         */
        WorkflowJobEvent event = new WorkflowJobEvent("jobid", "parentid", WorkflowJob.Status.RUNNING, getTestUser(),
                "myapp", null, null);
        ehs.queueEvent(event);
        ehs.new EventWorker().run();
        assertTrue(output.toString().contains("Workflow Job event STARTED"));
        output.setLength(0);

        event.setStatus(WorkflowJob.Status.SUSPENDED);
        ehs.queueEvent(event);
        ehs.new EventWorker().run();
        assertTrue(output.toString().contains("Workflow Job event SUSPEND"));
        output.setLength(0);

        event.setStatus(WorkflowJob.Status.SUCCEEDED);
        ehs.queueEvent(event);
        ehs.new EventWorker().run();
        assertTrue(output.toString().contains("Workflow Job event SUCCESS"));
        output.setLength(0);

        event.setStatus(WorkflowJob.Status.KILLED);
        ehs.queueEvent(event);
        ehs.new EventWorker().run();
        assertTrue(output.toString().contains("Workflow Job event FAILURE"));
        output.setLength(0);

View Full Code Here


    @Test
    public void testEventLogging() throws Exception {
        EventHandlerService ehs = _testEventHandlerService();
        // job event
        WorkflowJobEvent event = new WorkflowJobEvent("jobid", "parentid", WorkflowJob.Status.RUNNING, getTestUser(),
                "myapp", null, null);

        TestLogAppender appender = null;
        Logger logger = null;
        try {
            appender = getTestLogAppender();
            logger = Logger.getLogger(EventHandlerService.class);
            logger.addAppender(appender);
            logger.setLevel(Level.DEBUG);
            ehs.queueEvent(event);

            List<LoggingEvent> log = appender.getLog();
            LoggingEvent logEntry = log.get(0);
            assertEquals(Level.DEBUG, logEntry.getLevel());
            assertTrue(logEntry.getMessage().toString().contains("APP[myapp] JOB[jobid] ACTION[-] Queueing event : ID: jobid"));
            assertEquals("org.apache.oozie.service.EventHandlerService", logEntry.getLoggerName());

            ehs.new EventWorker().run();

            log = appender.getLog();
            logEntry = log.get(1);
            assertEquals(Level.DEBUG, logEntry.getLevel());
            assertTrue(logEntry.getMessage().toString().contains("APP[myapp] JOB[jobid] ACTION[-] Processing event : ID: jobid"));

            // action event
            CoordinatorActionEvent event2 = new CoordinatorActionEvent("jobid2@1", "parentid",
                    CoordinatorAction.Status.WAITING, getTestUser(), "myapp", null, null, null);
            ehs.queueEvent(event2);

            log = appender.getLog();
            logEntry = log.get(2);
            assertTrue(logEntry.getMessage().toString().contains("APP[myapp] JOB[jobid2] ACTION[jobid2@1] Queueing event : ID: jobid2@1"));

            WorkflowJobEvent event3 = new WorkflowJobEvent("jobid-other", "parentid", WorkflowJob.Status.RUNNING, getTestUser(),
                    "myapp-other", null, null);
            ehs.queueEvent(event3);

            log = appender.getLog();
            logEntry = log.get(3);
View Full Code Here

        super(name, type, priority, dryrun);
    }

    protected static void generateEvent(WorkflowJobBean wfJob, String errorCode, String errorMsg) {
        if (eventService.isSupportedApptype(AppType.WORKFLOW_JOB.name())) {
            WorkflowJobEvent event = new WorkflowJobEvent(wfJob.getId(), wfJob.getParentId(), wfJob.getStatus(),
                    wfJob.getUser(), wfJob.getAppName(), wfJob.getStartTime(), wfJob.getEndTime());
            event.setErrorCode(errorCode);
            event.setErrorMessage(errorMsg);
            eventService.queueEvent(event);
        }
    }
View Full Code Here

        SLARegistrationBean job = _createSLARegBean("wf1", AppType.WORKFLOW_JOB);
        job.setExpectedStart(DateUtils.parseDateUTC("2012-07-22T00:00Z"));
        slas.addRegistrationEvent(job);
        assertEquals(1, slas.getSLACalculator().size());
        Date actualStart = DateUtils.parseDateUTC("2012-07-22T01:00Z");
        WorkflowJobEvent wfe = new WorkflowJobEvent("wf1", "caId1", WorkflowJob.Status.RUNNING, "user1",
                "wf-app-name1", actualStart, null);
        listener.onWorkflowJobEvent(wfe);
        SLACalcStatus serviceObj = slas.getSLACalculator().get("wf1");
        // check that start sla has been calculated
        assertEquals(EventStatus.START_MISS, serviceObj.getEventStatus());
View Full Code Here

    public void testEventListener() throws Exception {
        EventHandlerService ehs = _testEventHandlerService();
        /*
         * Workflow Job events
         */
        WorkflowJobEvent event = new WorkflowJobEvent("jobid", "parentid", WorkflowJob.Status.RUNNING, getTestUser(),
                "myapp", null, null);
        ehs.queueEvent(event);
        ehs.new EventWorker().run();
        assertTrue(output.toString().contains("Workflow Job event STARTED"));
        output.setLength(0);

        event.setStatus(WorkflowJob.Status.SUSPENDED);
        ehs.queueEvent(event);
        ehs.new EventWorker().run();
        assertTrue(output.toString().contains("Workflow Job event SUSPEND"));
        output.setLength(0);

        event.setStatus(WorkflowJob.Status.SUCCEEDED);
        ehs.queueEvent(event);
        ehs.new EventWorker().run();
        assertTrue(output.toString().contains("Workflow Job event SUCCESS"));
        output.setLength(0);

        event.setStatus(WorkflowJob.Status.KILLED);
        ehs.queueEvent(event);
        ehs.new EventWorker().run();
        assertTrue(output.toString().contains("Workflow Job event FAILURE"));
        output.setLength(0);

View Full Code Here

        super(name, type, priority, dryrun);
    }

    protected static void generateEvent(WorkflowJobBean wfJob, String errorCode, String errorMsg) {
        if (eventService.isSupportedApptype(AppType.WORKFLOW_JOB.name())) {
            WorkflowJobEvent event = new WorkflowJobEvent(wfJob.getId(), wfJob.getParentId(), wfJob.getStatus(),
                    wfJob.getUser(), wfJob.getAppName(), wfJob.getStartTime(), wfJob.getEndTime());
            event.setErrorCode(errorCode);
            event.setErrorMessage(errorMsg);
            eventService.queueEvent(event);
        }
    }
View Full Code Here

        SLARegistrationBean job = _createSLARegBean("wf1", AppType.WORKFLOW_JOB);
        job.setExpectedStart(DateUtils.parseDateUTC("2012-07-22T00:00Z"));
        slas.addRegistrationEvent(job);
        assertEquals(1, slas.getSLACalculator().size());
        Date actualStart = DateUtils.parseDateUTC("2012-07-22T01:00Z");
        WorkflowJobEvent wfe = new WorkflowJobEvent("wf1", "caId1", WorkflowJob.Status.RUNNING, "user1",
                "wf-app-name1", actualStart, null);
        listener.onWorkflowJobEvent(wfe);
        SLACalcStatus serviceObj = slas.getSLACalculator().get("wf1");
        // check that start sla has been calculated
        assertEquals(EventStatus.START_MISS, serviceObj.getEventStatus());
View Full Code Here

TOP

Related Classes of org.apache.oozie.event.WorkflowJobEvent

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.