Package org.rhq.core.domain.event

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


     * @param tweets
     */
    public void addTweets(List<Tweet> tweets) {
        synchronized (events) {
            for (Tweet tweet: tweets) {
                Event ev = new Event(getEventType(),
                        tweet.getFromUser(),
                        tweet.getCreatedAt().getTime(),
                        EventSeverity.INFO,
                        tweet.getText());
                events.add(ev);
View Full Code Here


                    if (newest > lastCollectedEventId[i]) {
                        for (int eventId = lastCollectedEventId[i] + 1; eventId <= newest; eventId++) {
                            eventsChecked++;

                            EventLogRecord event = eventLogs[i].read(eventId);
                            Event convertedEvent = handleEvent(event);

                            if (null != convertedEvent) {
                                if (null == convertedEvents) {
                                    convertedEvents = new HashSet<Event>();
                                }
View Full Code Here

        if (!convertSeverity(event.getEventType()).isAtLeastAsSevereAs(minimumSeverity)) {
            return null;
        }

        Event convertedEvent = new Event(EVENT_TYPE, event.getLogName(), event.getTimeGenerated() * 1000,
            convertSeverity(event.getEventType()), event.getMessage());
        eventsFired++;
        return convertedEvent;
    }
View Full Code Here

     * @return the event, or <code>null</code> if the event didn't match our regex, wasn't of the minimum severity
     *         or couldn't be parsed successfully
     */
    protected Event convertLine(String syslogMessage) {

        Event event = null;

        try {
            if (this.parserRegex != null) {
                event = convertLineParserRegEx(syslogMessage);
            } else {
                event = convertLineDefaultFormat(syslogMessage); // no parser regex, use best attempt with our default format
            }

            // if we could not parse the event, just use the entire log as the event detail
            if (event == null) {
                event = convertAnyLine(syslogMessage);
            }

            // filter the event if it doesn't meet our minimum severity requirement or it doesn't match the includes regex
            if (event != null) {
                if (this.minimumEventSeverity != null
                    && !event.getSeverity().isAtLeastAsSevereAs(this.minimumEventSeverity)) {
                    if (log.isTraceEnabled()) {
                        log.trace("event is not at minimum severity: " + event);
                    }
                    event = null;
                } else if (this.includesPattern != null && !this.includesPattern.matcher(event.getDetail()).matches()) {
                    if (log.isTraceEnabled()) {
                        log.trace("event does not match includes pattern [" + this.includesPattern + "]: " + event);
                    }
                    event = null;
                }
View Full Code Here

        return event;
    }

    protected Event convertLineParserRegEx(String syslogMessage) {
        Event event;
        try {
            Matcher matcher = this.parserRegex.matcher(syslogMessage);
            if (matcher.find() && (matcher.groupCount() == 3)) {
                String dateTimeString = matcher.group(1);
                String severityString = matcher.group(2);
                String detailsString = matcher.group(3);
                long timestamp = getTimestamp(dateTimeString);
                EventSeverity severity = getSeverity(severityString);
                event = new Event(EVENT_LOG_TYPE, this.sourceLocation, timestamp, severity, detailsString);
            } else {
                event = null;
                if (log.isTraceEnabled()) {
                    log.trace("Message [" + syslogMessage + "] did not match parser regex: "
                        + this.parserRegex.pattern());
View Full Code Here

    }

    protected Event convertLineDefaultFormat(String syslogMessage) {
        // "%timegenerated:::date-rfc3339%,%syslogpriority-text%,%syslogfacility-text%:%msg%\n"

        Event event;
        try {
            String[] messageParts = syslogMessage.split("\\,", 3);
            if (messageParts == null || messageParts.length < 3) {
                return null; // message doesn't seem to match the syntax of our default format
            }

            String dateTimeString = messageParts[0];
            String severityString = messageParts[1];
            String detailsString = messageParts[2];

            long timestamp = getTimestamp(dateTimeString);
            EventSeverity severity = getSeverity(severityString);
            event = new Event(EVENT_LOG_TYPE, this.sourceLocation, timestamp, severity, detailsString);
        } catch (Exception e) {
            event = null;
            if (log.isTraceEnabled()) {
                log.trace("defaultFormat: Failed to convert syslog message [" + syslogMessage + "] to event: " + e);
            }
View Full Code Here

        }
        return event;
    }

    protected Event convertAnyLine(String syslogMessage) {
        Event event;
        try {
            long timestamp = System.currentTimeMillis();
            EventSeverity severity = EventSeverity.INFO;
            event = new Event(EVENT_LOG_TYPE, this.sourceLocation, timestamp, severity, syslogMessage);
        } catch (Exception e) {
            event = null;
            if (log.isTraceEnabled()) {
                log.trace("anyLine: Failed to convert syslog message [" + syslogMessage + "] to event: " + e);
            }
View Full Code Here

                String line = reader.readLine(); // prime the pump and read the first line

                try {
                    while (this.run && line != null) {
                        Event e = convertLine(line);
                        if (e != null) {
                            getEventContext().publishEvent(e);
                        }
                        line = reader.readLine(); // read the next line
                    }
View Full Code Here

    public Set<Event> processLines(BufferedReader bufferedReader) throws IOException {
        // Use a LinkedHashSet so the Events are in the same order as the log entries they correspond to.
        Set<Event> events = new LinkedHashSet<Event>();
        String line;
        while ((line = bufferedReader.readLine()) != null) {
            Event event = convertLine(line);
            if (event != null) {
                events.add(event);
            }
        }
        return events;
View Full Code Here

TOP

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

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.