Examples of EventDefinition


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

    public void testRenameServer() throws Exception {

        Resource testResource = null;
        MeasurementSchedule sched = null;
        MeasurementBaseline baseline = null;
        EventDefinition eDef = null;

        // Note, plugins are registered in new transactions. for tests, this means
        // you can't do everything in a trans and roll back at the end. You must clean up
        // manually.  Still, some work can be performed transactionally, as done below.
        try {
            registerPlugin("update6-1.xml");
            ResourceType server = getResourceType("testServer1");

            getTransactionManager().begin();

            getPluginId();

            Set<MeasurementDefinition> definitions1 = server.getMetricDefinitions();
            // for metric counts, add one for the built in AvailabilityType metric
            assert definitions1.size() == 2;

            /*
             * Create a Fake Resource and a MeasurementSchedule
             */
            testResource = new Resource("-test-", "-test resource-", server);
            testResource.setUuid("" + new Random().nextInt());
            em.persist(testResource);

            sched = new MeasurementSchedule(definitions1.iterator().next(), testResource);
            em.persist(sched);

            em.flush();

            baseline = new MeasurementBaseline();
            baseline.setSchedule(sched);
            baseline.setUserEntered(true);
            em.persist(baseline);

            eDef = new EventDefinition(server, "-test event definition-");
            em.persist(eDef);

            setUpAgent(testResource);

            getTransactionManager().commit();
View Full Code Here

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

            }
        }

        // Persist new definitions
        for (EventDefinition eDef : newOnes) {
            EventDefinition e2 = new EventDefinition(existingType, eDef.getName());
            e2.setDescription(eDef.getDescription());
            e2.setDisplayName(eDef.getDisplayName());
            entityMgr.persist(e2);
            existingType.addEventDefinition(e2);
        }

        // and finally remove deleted ones. First flush the EM to be on the save side
View Full Code Here

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

    public void publishEvent(@NotNull Event event) {
        //noinspection ConstantConditions
        if (event == null)
            throw new IllegalArgumentException("event parameter must not be null.");
        EventDefinition eventDefinition = EventUtility.getEventDefinition(event.getType(),
            this.resource.getResourceType());
        if (eventDefinition == null)
            throw new IllegalArgumentException("Event has unknown event type - no EventDefinition exists with name '"
                + event.getType() + "'.");
        Set<Event> events = new HashSet<Event>();
View Full Code Here

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

    public Resource getResource() {
        return resource;
    }

    private void registerEventPollerInternal(final EventPoller poller, int pollingInterval, final String sourceLocation) {
        EventDefinition eventDefinition = EventUtility.getEventDefinition(poller.getEventType(),
            this.resource.getResourceType());
        if (eventDefinition == null)
            throw new IllegalArgumentException("Poller has unknown event type - no EventDefinition exists with name '"
                + poller.getEventType() + "'.");
        final int adjustedPollingInterval = Math.max(EventContext.MINIMUM_POLLING_INTERVAL, pollingInterval);
View Full Code Here

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

        final int adjustedPollingInterval = Math.max(EventContext.MINIMUM_POLLING_INTERVAL, pollingInterval);
        eventManager.registerEventPoller(poller, adjustedPollingInterval, resource, sourceLocation);
    }

    private void unregisterEventPollerInternal(String eventType, String sourceLocation) {
        EventDefinition eventDefinition = EventUtility.getEventDefinition(eventType, this.resource.getResourceType());
        if (eventDefinition == null)
            throw new IllegalArgumentException("Unknown event type - no EventDefinition exists with name '" + eventType
                + "'.");
        eventManager.unregisterEventPoller(this.resource, eventType, sourceLocation);
    }
View Full Code Here

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

            this.pollerThreads.remove(pollerKey);
        }
    }

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

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

public class EventReportTest {

    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();
View Full Code Here

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

    }

    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);
View Full Code Here

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

    }

    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);
View Full Code Here

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

    }

    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);
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.