Package org.rhq.core.domain.event

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


            throw new RuntimeException("No event definition found, should not happen");
        }

        EventSource[] evSrc = new EventSource[NUM_SOURCES];
        for (int i = 0; i < NUM_SOURCES; i++) {
            evSrc[i] = new EventSource("ESource" + 1, def, res);
        }
        long now = new Date().getTime() - ROUNDS * LINES_PER_REPORT;

        for (int round = 1; round < ROUNDS; round++) {

View Full Code Here


            while (eIter.hasNext()) {
                EventDefinition def = eIter.next();
                if (def.getName().equals("hans")) {
                    found = true;
                    // We got the definition that will vanish later, so attach some stuff to it
                    EventSource source = new EventSource("test location", def, testResource);
                    em.persist(source);

                    Event ev = new Event(def.getName(), source.getLocation(), System.currentTimeMillis(),
                        EventSeverity.INFO, "This is a test");
                    Set<Event> evSet = new HashSet<Event>(1);
                    evSet.add(ev);
                    events.put(source, evSet);
                }
View Full Code Here

    @Path("/source/{id}")
    @ApiOperation(value = "Retrieve the event source with the passed id", responseClass = "EventSourceRest")
    @ApiError(code = 404, reason = "There is no event source with the passed id")
    public EventSourceRest getEventSource(@ApiParam("Id of the source to retrieve") @PathParam("id") int sourceId) {

        EventSource source = findEventSourceById(sourceId);
        EventSourceRest esr = convertEventSource(source);

        return esr;
    }
View Full Code Here

        q.setParameter("location",esr.getLocation());
        q.setParameter("definition",eventDefinition);
        q.setParameter("resourceId",resourceId);
        List<EventSource> sources = q.getResultList();

        EventSource source;
        if (sources.isEmpty()) {
            source = new EventSource(esr.getLocation(),eventDefinition,resource);
            em.persist(source);
        } else if (sources.size()==1) {
            source = sources.get(0);
        } else {
            throw new IllegalStateException("We have more than one EventSource on the same Definition with the same location - must not happen");
View Full Code Here

        @ApiError(code = 404, reason = "Source did not exist and validate was set")
    })
    public Response deleteEventSource(@ApiParam("Id of the source to delete") @PathParam("id"int sourceId,
                                      @ApiParam("Validate if the content exists") @QueryParam("validate") @DefaultValue("false") boolean validate) {

        EventSource source = em.find(EventSource.class,sourceId);
        if (source!=null) {
            em.remove(source); // We have a cascade delete on the events TODO make operation async ?
        }
        else {
            if (validate) {
View Full Code Here

            } catch (Exception e) {
                throw new BadArgumentException("severity",severity + " is bad. Allowed values are DEBUG, INFO, WARN, ERROR, FATAL");
            }
        }

        EventSource source = findEventSourceById(sourceId);

        EventCriteria criteria = new EventCriteria();
        criteria.addSortId(PageOrdering.ASC);
        criteria.addFilterSourceId(source.getId());
        if (startTime>0) {
            criteria.addFilterStartTime(startTime);
        }
        if (endTime>0) {
            criteria.addFilterEndTime(endTime);
View Full Code Here

    @ApiOperation("Submit multiple events for one given event source; the event source in the passed Events is ignored. "+
    "Make sure your events are ordered by timestamp to get alerts fired correctly.")
    public Response addEventsToSource(@ApiParam("Id of the source to add data to"@PathParam("id") int sourceId,
                                      List<EventRest> eventRest) {

        EventSource source = findEventSourceById(sourceId);
        Map<EventSource,Set<Event>> eventMap = new HashMap<EventSource, Set<Event>>();
        Set<Event> events = new LinkedHashSet<Event>(eventRest.size());
        for (EventRest eRest : eventRest) {
            EventSeverity eventSeverity = EventSeverity.valueOf(eRest.getSeverity());
            Event event = new Event(eRest.getTimestamp(),eventSeverity,source,eRest.getDetail());
View Full Code Here

        return er;
    }

    private EventSource findEventSourceById(int sourceId) {

        EventSource source = em.find(EventSource.class,sourceId);
        if (source==null)
            throw new StuffNotFoundException("Event source with id " + sourceId);
        return source;

    }
View Full Code Here

        Event warningEvent;
        String warningMessage;
        long now = System.currentTimeMillis();

        for (Map.Entry<EventSource, Integer> entry : this.eventsDropped.entrySet()) {
            EventSource eventSource = entry.getKey();
            Integer droppedCount = entry.getValue();
            Set<Event> eventSet = getEventsForEventSource(eventSource);

            if (eventSet.size() >= this.maxEventsPerSource) {
                // this event source hit its individual limit
                warningMessage = "Event Report Limit Reached: reached the maximum allowed events ["
                    + this.maxEventsPerSource + "] for this event source - dropped [" + droppedCount + "] events";
            } else {
                // this report reached its total limit, even though this event source did not hit its individual limit
                warningMessage = "Event Report Limit Reached: reached total maximum allowed events ["
                    + this.maxEventsPerReport + "] - dropped [" + droppedCount + "] events";
            }

            warningEvent = new Event(eventSource.getEventDefinition().getName(), eventSource.getLocation(), now,
                EventSeverity.WARN, warningMessage, eventSource);
            eventSet.add(warningEvent);

            this.addedLimitWarningEvents = true;
        }
View Full Code Here

    void publishEvents(@NotNull Set<Event> events, @NotNull Resource resource) {
        this.reportLock.readLock().lock();
        try {
            for (Event event : events) {
                EventSource eventSource = createEventSource(event, resource);
                this.activeReport.addEvent(event, eventSource);
            }
        } catch (Throwable t) {
            log.error("Failed to add Events for " + resource + " to Event report: " + events, t);
        } finally {
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.