Examples of EventReport


Examples of com.dianping.cat.consumer.event.model.entity.EventReport

    }
    model.setGroupIps(m_configManager.queryIpByDomainAndGroup(domain, group));
    model.setGroups(m_configManager.queryDomainGroup(payload.getDomain()));
    switch (action) {
    case HOURLY_REPORT:
      EventReport report = getHourlyReport(payload);

      report = m_mergeManager.mergerAllIp(report, ipAddress);
      calculateTps(payload, report);
      if (report != null) {
        model.setReport(report);
View Full Code Here

Examples of com.dianping.cat.consumer.event.model.entity.EventReport

    }
    return report;
  }

  public EventReport mergerAllName(EventReport report, String ipAddress, String allName) {
    EventReport temp = mergerAllIp(report, ipAddress);

    return mergerAllName(temp, allName);
  }
View Full Code Here

Examples of org.rhq.core.domain.event.transfer.EventReport

    private final Map<PollerKey, Runnable> pollerThreads;
    private SigarProxy sigar;

    public EventManager(PluginContainerConfiguration configuration) {
        pcConfig = configuration;
        activeReport = new EventReport(pcConfig.getEventReportMaxPerSource(), pcConfig.getEventReportMaxTotal());
        senderThreadPool = new ScheduledThreadPoolExecutor(SENDER_THREAD_POOL_CORE_SIZE, new LoggingThreadFactory(
            SENDER_THREAD_POOL_NAME, true));
        // Set up a thread pool for polling threads. Polling threads will be added to the pool via calls to
        // registerEventPoller().
        pollerThreadPool = new ScheduledThreadPoolExecutor(POLLER_THREAD_POOL_CORE_SIZE, new LoggingThreadFactory(
View Full Code Here

Examples of org.rhq.core.domain.event.transfer.EventReport

    }

    EventReport swapReport() {
        this.reportLock.writeLock().lock();
        try {
            EventReport previousReport = this.activeReport;
            this.activeReport = new EventReport(this.pcConfig.getEventReportMaxPerSource(), this.pcConfig
                .getEventReportMaxTotal());
            return previousReport;
        } finally {
            this.reportLock.writeLock().unlock();
        }
View Full Code Here

Examples of org.rhq.core.domain.event.transfer.EventReport

    public EventSenderRunner(EventManager eventManager) {
        this.eventManager = eventManager;
    }

    public EventReport call() throws Exception {
        EventReport report = this.eventManager.swapReport();
        this.eventManager.sendEventReport(report);
        return report;
    }
View Full Code Here

Examples of org.rhq.core.domain.event.transfer.EventReport

        log.info("listening...");
        boolean success = false;
        for (int i = 0; i < 16; i++) {
            Thread.sleep(250);
            EventSenderRunner esr = new EventSenderRunner(eventManager);
            EventReport eventReport = esr.call();
            Map<EventSource, Set<Event>> events = eventReport.getEvents();
            log.info("events " + events);
            if (events.size() > 0) {
                success = true;
                break;
            }
View Full Code Here

Examples of org.rhq.core.domain.event.transfer.EventReport

    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;
        assert allEvents.get(eventSource2).size() == 1;

        // make sure they are the ones we expect
View Full Code Here

Examples of org.rhq.core.domain.event.transfer.EventReport

    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();
        allEvents = report.getEvents();
        assert allEvents.size() == 2;
        assert allEvents.get(eventSource).size() == 2; // the original one plus a warning event
        assert allEvents.get(eventSource2).size() == 1; // our new one (no warning events here)

        // make sure they are the ones we expect
View Full Code Here

Examples of org.rhq.core.domain.event.transfer.EventReport

    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();
        allEvents = report.getEvents();
        assert allEvents.size() == 2; // both are here, the second one just has a single limit warning event
        assert allEvents.get(eventSource).size() == 2;
        assert allEvents.containsKey(eventSource2) == true; // even though the "real" event never made it, we have a limit warn event
        assert allEvents.get(eventSource2).size() == 1; // this isn't the "real" bar event, its the limit warn event
        assert allEvents.get(eventSource2).iterator().next().getDetail().contains("Event Report Limit Reached:");
View Full Code Here

Examples of org.rhq.core.domain.event.transfer.EventReport

    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!
        assert ensureSerializable(report).getEvents().values().iterator().next().size() == 2;
    }
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.