Search in sources :

Example 1 with EventQueue

use of org.apache.oozie.event.EventQueue in project oozie by apache.

the class EventHandlerService method init.

@Override
public void init(Services services) throws ServiceException {
    try {
        Configuration conf = services.getConf();
        LOG = XLog.getLog(getClass());
        Class<? extends EventQueue> queueImpl = (Class<? extends EventQueue>) ConfigurationService.getClass(conf, CONF_EVENT_QUEUE);
        eventQueue = queueImpl == null ? new MemoryEventQueue() : (EventQueue) queueImpl.newInstance();
        eventQueue.init(conf);
        // initialize app-types to switch on events for
        initApptypes(conf);
        // initialize event listeners
        initEventListeners(conf);
        // initialize worker threads via Scheduler
        initWorkerThreads(conf, services);
        eventsEnabled = true;
        LOG.info("EventHandlerService initialized. Event queue = [{0}], Event listeners configured = [{1}]," + " Events configured for App-types = [{2}], Num Worker Threads = [{3}]", eventQueue.getClass().getName(), listenerMap.toString(), apptypes, numWorkers);
    } catch (Exception ex) {
        throw new ServiceException(ErrorCode.E0100, ex.getMessage(), ex);
    }
}
Also used : Configuration(org.apache.hadoop.conf.Configuration) MemoryEventQueue(org.apache.oozie.event.MemoryEventQueue) EventQueue(org.apache.oozie.event.EventQueue) MemoryEventQueue(org.apache.oozie.event.MemoryEventQueue)

Example 2 with EventQueue

use of org.apache.oozie.event.EventQueue in project oozie by apache.

the class DummySLACalculatorMemory method testNoDuplicateEventsInHA.

public void testNoDuplicateEventsInHA() throws Exception {
    String id1 = "0000001-130521183438837-oozie-test-C@1";
    SLAService slas = Services.get().get(SLAService.class);
    SLACalculatorMemory slaCalcMem = (SLACalculatorMemory) slas.getSLACalculator();
    // loads the job in sla map
    slaCalcMem.init(Services.get().getConf());
    EventHandlerService ehs = Services.get().get(EventHandlerService.class);
    EventQueue ehs_q = ehs.getEventQueue();
    DummyZKOozie dummyOozie_1 = null;
    try {
        // start another dummy oozie instance (dummy sla and event handler services)
        dummyOozie_1 = new DummyZKOozie("a", "http://blah");
        DummySLACalculatorMemory dummySlaCalcMem = new DummySLACalculatorMemory();
        dummySlaCalcMem.init(Services.get().getConf());
        EventHandlerService dummyEhs = new EventHandlerService();
        dummySlaCalcMem.setEventHandlerService(dummyEhs);
        dummyEhs.init(Services.get());
        EventQueue dummyEhs_q = dummyEhs.getEventQueue();
        // get MISS
        Date expectedStartTS = new Date(System.currentTimeMillis() + 2 * 3600 * 1000);
        // get MISS
        Date expectedEndTS = new Date(System.currentTimeMillis() + 1 * 3600 * 1000);
        SLASummaryBean sla = createDBEntryForStarted(id1, expectedStartTS, expectedEndTS, 0);
        sla.setExpectedDuration(-1);
        sla.setLastModifiedTime(new Date());
        SLASummaryQueryExecutor.getInstance().executeUpdate(SLASummaryQuery.UPDATE_SLA_SUMMARY_FOR_EXPECTED_TIMES, sla);
        // Action started on Server 1
        updateCoordAction(id1, "RUNNING");
        slaCalcMem.addJobStatus(id1, CoordinatorAction.Status.RUNNING.name(), EventStatus.STARTED, new Date(), null);
        assertEquals(1, ehs_q.size());
        SLACalcStatus s1 = (SLACalcStatus) ehs_q.poll();
        assertEquals(SLAStatus.IN_PROCESS, s1.getSLAStatus());
        // Action ended on Server 2
        updateCoordAction(id1, "FAILED");
        dummySlaCalcMem.addJobStatus(id1, CoordinatorAction.Status.FAILED.name(), EventStatus.FAILURE, new Date(System.currentTimeMillis() - 1800 * 1000), new Date());
        SLACalcStatus s2 = (SLACalcStatus) dummyEhs_q.poll();
        assertEquals(SLAStatus.MISS, s2.getSLAStatus());
        slaCalcMem.updateAllSlaStatus();
        dummySlaCalcMem.updateAllSlaStatus();
        // no dupe event should be created again by Server 1
        assertEquals(0, ehs_q.size());
    } finally {
        if (dummyOozie_1 != null) {
            dummyOozie_1.teardown();
        }
    }
}
Also used : TestSLAService(org.apache.oozie.sla.TestSLAService) SLAService(org.apache.oozie.sla.service.SLAService) SLACalcStatus(org.apache.oozie.sla.SLACalcStatus) SLACalculatorMemory(org.apache.oozie.sla.SLACalculatorMemory) EventQueue(org.apache.oozie.event.EventQueue) Date(java.util.Date) SLASummaryBean(org.apache.oozie.sla.SLASummaryBean)

Aggregations

EventQueue (org.apache.oozie.event.EventQueue)2 Date (java.util.Date)1 Configuration (org.apache.hadoop.conf.Configuration)1 MemoryEventQueue (org.apache.oozie.event.MemoryEventQueue)1 SLACalcStatus (org.apache.oozie.sla.SLACalcStatus)1 SLACalculatorMemory (org.apache.oozie.sla.SLACalculatorMemory)1 SLASummaryBean (org.apache.oozie.sla.SLASummaryBean)1 TestSLAService (org.apache.oozie.sla.TestSLAService)1 SLAService (org.apache.oozie.sla.service.SLAService)1