Package org.rhq.core.domain.event

Examples of org.rhq.core.domain.event.EventSource


        if (eventDefinition == null) {
            throw new IllegalArgumentException("Unknown type - no EventDefinition found with name '" + event.getType()
                + "'.");
        }
        //noinspection ConstantConditions
        return new EventSource(event.getSourceLocation(), eventDefinition, resource);
    }
View Full Code Here


    public void testEventReport() {
        ResourceType resourceType = new ResourceType("foo", "foo", ResourceCategory.PLATFORM, null);
        Resource resource = new Resource(1);
        EventDefinition eventDefinition = new EventDefinition(resourceType, "foo");
        EventSource eventSource = new EventSource("foo", eventDefinition, resource);
        EventReport report = new EventReport(10, 10);
        report.addEvent(new Event("foo", "foo", 0, EventSeverity.DEBUG, "foo-first", eventSource), eventSource);
        report.addLimitWarningEvents(); // should do nothing
        Map<EventSource, Set<Event>> allEvents = report.getEvents();
        assert allEvents.size() == 1;
        assert allEvents.get(eventSource).size() == 1;

        report.addEvent(new Event("foo", "foo", 1, EventSeverity.DEBUG, "foo-second", eventSource), eventSource);
        report.addLimitWarningEvents(); // should do nothing
        allEvents = report.getEvents();
        assert allEvents.size() == 1; // only one event source still!
        assert allEvents.get(eventSource).size() == 2;

        // make sure they are the ones we expect
        for (Event e : allEvents.get(eventSource)) {
            assert e.getDetail().startsWith("foo-");
        }

        // use a second event source
        EventSource eventSource2 = new EventSource("bar", eventDefinition, resource);
        report.addEvent(new Event("bar", "bar", 2, EventSeverity.DEBUG, "bar-first", eventSource2), eventSource2);
        report.addLimitWarningEvents(); // should do nothing
        allEvents = report.getEvents();
        assert allEvents.size() == 2;
        assert allEvents.get(eventSource).size() == 2;
View Full Code Here

    public void testEventReportMaxPerSource() {
        ResourceType resourceType = new ResourceType("foo", "foo", ResourceCategory.PLATFORM, null);
        Resource resource = new Resource(1);
        EventDefinition eventDefinition = new EventDefinition(resourceType, "foo");
        EventSource eventSource = new EventSource("foo", eventDefinition, resource);
        EventReport report = new EventReport(1, 10);

        // add the first
        addEvent(report, "foo", "first", eventSource);
        report.addLimitWarningEvents(); // should do nothing
        Map<EventSource, Set<Event>> allEvents = report.getEvents();
        assert allEvents.size() == 1; // only one event source still!
        assert allEvents.get(eventSource).size() == 1;

        // add the second (this is over the max)
        addEvent(report, "foo", "second", eventSource); // OVER MAX SO THIS NEVER MAKES IT!
        report.addLimitWarningEvents();
        allEvents = report.getEvents();
        assert allEvents.size() == 1; // only one event source still!
        assert allEvents.get(eventSource).size() == 2; // the second one is our "over the max" message
        int foo_count = 0;
        int limit_count = 0;
        for (Event e : allEvents.get(eventSource)) {
            if (e.getDetail().startsWith("foo-")) {
                foo_count++;
                continue;
            }
            if (e.getDetail().contains("Event Report Limit Reached:")) {
                limit_count++;
                continue;
            }
            assert false : "this event was unexpected: " + e;
        }
        assert foo_count == 1 : "there should have only been one of our events in the report: " + foo_count;
        assert limit_count == 1 : "there should have been an event warning of the limit breach: " + limit_count;

        // add the third (this is over the max)
        report = stripLimitWarningEvents(report);
        addEvent(report, "foo", "second", eventSource); // OVER MAX SO THIS NEVER MAKES IT!
        addEvent(report, "foo", "third", eventSource); // STILL OVER MAX SO THIS NEVER MAKES IT EITHER!
        report.addLimitWarningEvents();
        allEvents = report.getEvents();
        assert allEvents.size() == 1; // only one event source still!
        assert allEvents.get(eventSource).size() == 2; // no others have been added, this includes our "over the max" event
        foo_count = 0;
        limit_count = 0;
        for (Event e : allEvents.get(eventSource)) {
            if (e.getDetail().startsWith("foo-")) {
                foo_count++;
                continue;
            }
            if (e.getDetail().contains("Event Report Limit Reached:")) {
                limit_count++;
                continue;
            }
            assert false : "this event was unexpected: " + e;
        }

        // use a second event source - since we didn't hit our max total, this should work
        EventSource eventSource2 = new EventSource("bar", eventDefinition, resource);
        report = stripLimitWarningEvents(report);
        addEvent(report, "foo", "second", eventSource); // OVER MAX SO THIS NEVER MAKES IT!
        addEvent(report, "foo", "third", eventSource); // STILL OVER MAX SO THIS NEVER MAKES IT EITHER!
        addEvent(report, "bar", "first", eventSource2);
        report.addLimitWarningEvents();
View Full Code Here

    public void testEventReportMaxTotal() {
        ResourceType resourceType = new ResourceType("foo", "foo", ResourceCategory.PLATFORM, null);
        Resource resource = new Resource(1);
        EventDefinition eventDefinition = new EventDefinition(resourceType, "foo");
        EventSource eventSource = new EventSource("foo", eventDefinition, resource);
        EventReport report = new EventReport(10, 1); // max total takes precedence!

        // add the first
        addEvent(report, "foo", "first", eventSource);
        report.addLimitWarningEvents(); // should do nothing
        Map<EventSource, Set<Event>> allEvents = report.getEvents();
        assert allEvents.size() == 1; // only one event source still!
        assert allEvents.get(eventSource).size() == 1;

        // add the second (this is over the max)
        addEvent(report, "foo", "second", eventSource); // OVER MAX SO THIS NEVER MAKES IT!
        report.addLimitWarningEvents();
        allEvents = report.getEvents();
        assert allEvents.size() == 1; // only one event source still!
        assert allEvents.get(eventSource).size() == 2; // the second one is our "over the max" message
        int foo_count = 0;
        int limit_count = 0;
        for (Event e : allEvents.get(eventSource)) {
            if (e.getDetail().startsWith("foo-")) {
                foo_count++;
                continue;
            }
            if (e.getDetail().contains("Event Report Limit Reached:")) {
                limit_count++;
                continue;
            }
            assert false : "this event was unexpected: " + e;
        }
        assert foo_count == 1 : "there should have only been one of our events in the report: " + foo_count;
        assert limit_count == 1 : "there should have been an event warning of the limit breach: " + limit_count;

        // use a second event source - since we are over the total, this should add nothing
        EventSource eventSource2 = new EventSource("bar", eventDefinition, resource);
        report = stripLimitWarningEvents(report);
        addEvent(report, "foo", "second", eventSource); // OVER MAX SO THIS NEVER MAKES IT!
        addEvent(report, "foo", "third", eventSource); // STILL OVER MAX SO THIS NEVER MAKES IT EITHER!
        addEvent(report, "bar", "first", eventSource2); // WE ARE OVER THE TOTAL MAX, SO THIS NEVER MAKES IT EITHER!
        report.addLimitWarningEvents();
View Full Code Here

    // this creates a new report with the same debug/test events but without the limi warn events
    private EventReport stripLimitWarningEvents(EventReport report) {
        EventReport newReport = new EventReport(report.getMaxEventsPerSource(), report.getMaxEventsPerReport());

        for (Map.Entry<EventSource, Set<Event>> entry : report.getEvents().entrySet()) {
            EventSource eventSource = entry.getKey();
            for (Event event : entry.getValue()) {
                if (event.getSeverity() == EventSeverity.DEBUG) {
                    newReport.addEvent(event, eventSource);
                }
            }
View Full Code Here

    public void testEventReport() {
        ResourceType resourceType = new ResourceType("foo", "foo", ResourceCategory.PLATFORM, null);
        Resource resource = new Resource(1);
        EventDefinition eventDefinition = new EventDefinition(resourceType, "foo");
        EventSource eventSource = new EventSource("foo", eventDefinition, resource);
        EventReport report = new EventReport(2, 2);
        report.addEvent(new Event("foo", "foo", 0, EventSeverity.DEBUG, ""), eventSource);
        assert ensureSerializable(report).getEvents().size() == 1;
        report.addEvent(new Event("foo", "foo", 1, EventSeverity.DEBUG, ""), eventSource);
        assert ensureSerializable(report).getEvents().size() == 1; // only one event source still!
View Full Code Here

            // check availabilities, remember, a new resource gets one initial avail record
            List<Availability> avails = res.getAvailability();
            assertEquals("didn't purge availabilities", 1, avails.size());

            // check events
            EventSource es = res.getEventSources().iterator().next();
            assertEquals("didn't purge all events", 0, es.getEvents().size());

            // check calltime data
            int calltimeScheduleId = 0;
            for (MeasurementSchedule sched : res.getSchedules()) {
                if (sched.getDefinition().getDataType() == DataType.CALLTIME) {
View Full Code Here

            count, persistedData.get(0).getCount());
    }

    private void createNewEvents(Resource res, long timestamp, int count) {
        EventDefinition ed = res.getResourceType().getEventDefinitions().iterator().next();
        EventSource source = new EventSource("datapurgejobtest", ed, res);
        Map<EventSource, Set<Event>> eventMap = new HashMap<EventSource, Set<Event>>();
        Set<Event> events = new HashSet<Event>();
        for (int i = 0; i < count; i++) {
            events.add(new Event(ed.getName(), source.getLocation(), timestamp + i, EventSeverity.DEBUG, "details"));
        }
        eventMap.put(source, events);

        EventManagerLocal mgr = LookupUtil.getEventManager();
        mgr.addEventData(eventMap);
View Full Code Here

                EventDefinition eDef = createEventDefinition(resource);
                em.persist(eDef);

                long now = System.currentTimeMillis();
                EventSource evSrc = new EventSource("ESource", eDef, resource);
                Event ev = new Event("EType", "ESource", now, EventSeverity.INFO, "This is a test", evSrc);
                //Set<Event> eventSet = newEventSet();
                //eventSet.add(ev);
                //Map<EventSource, Set<Event>> events = new HashMap<EventSource, Set<Event>>();
                //events.put(evSrc, eventSet);
View Full Code Here

                EventDefinition eDef = createEventDefinition(resource);
                em.persist(eDef);
                em.flush();

                long now = System.currentTimeMillis();
                EventSource evSrc = new EventSource("ESource", eDef, resource);
                Event ev = new Event("EType", "ESource", now, EventSeverity.INFO, "This is a 2nd test", evSrc);
                //em.persist(evSrc);
                //em.persist(ev);
                //em.flush();
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.event.EventSource

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.