/** * Determine if this severity is more severe than that of other * @param other EventSeverity to compare * @return if more severe */ public boolean isMoreSevereThan(EventSeverity other) { if (other == null) // If other is null, our severity is always higher return true; return (ordinal() > other.ordinal()); }
public String toString() { return name(); } }
public EventSeverity[] getValues() { return values(); }
private EventSourceRest convertEventSource(EventSource source) { EventSourceRest esr = new EventSourceRest(); esr.setId(source.getId()); esr.setDescription(source.getEventDefinition().getDescription()); esr.setDisplayName(source.getEventDefinition().getDisplayName()); esr.setName(source.getEventDefinition().getName()); esr.setLocation(source.getLocation()); esr.setResourceId(source.getResourceId()); return esr; }
EventSource eventSource = entry.getKey(); Integer droppedCount = entry.getValue(); Set<Event> eventSet = getEventsForEventSource(eventSource); warningEvent = new Event(eventSource.getEventDefinition().getName(), eventSource.getLocation(), now, EventSeverity.WARN, warningMessage, eventSource); eventSet.add(warningEvent);
private EventRest convertEvent(Event event) { EventRest er = new EventRest(); er.setDetail(event.getDetail()); er.setId(event.getId()); er.setSeverity(event.getSeverity().toString()); er.setTimestamp(event.getTimestamp()); er.setSourceId(event.getSource().getId()); return er; }
public static EventDefinition parseEventsMetadata(EventDescriptor eventDescriptor, ResourceType resourceType) { EventDefinition eventDefinition = new EventDefinition(resourceType, eventDescriptor.getName()); if (eventDescriptor.getDisplayName() != null) { eventDefinition.setDisplayName(eventDescriptor.getDisplayName()); } else { eventDefinition.setDisplayName(StringUtils.deCamelCase(eventDescriptor.getName())); } eventDefinition.setDescription(eventDescriptor.getDescription()); return eventDefinition; } }
Resource resource = source.getResource(); List<EventCacheElement> cacheElements = lookupEventCacheElements(resource.getId()); i.remove(); int matched = stats.matched; processCacheElements(cacheElements, event.getSeverity(), event.getTimestamp(), stats, "sourceLocation=" + source.getLocation(), event.getDetail()); if (matched < stats.matched) { break;
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 return new EventSource(event.getSourceLocation(), eventDefinition, resource); }
private void addEventForCurrentEntry(Set<Event> events, LogEntry currentEntry) { if (currentEntry != null) { if (currentEntry.getSeverity().isAtLeastAsSevereAs(this.minimumSeverity) && (this.includesPattern == null || this.includesPattern.matcher(currentEntry.getDetail()).find())) { Event event = new Event(this.eventType, this.logFile.getPath(), currentEntry.getDate().getTime(), currentEntry.getSeverity(), currentEntry.getDetail()); events.add(event); } } }
@Override public String toString() { return this.getClass().getName().substring(this.getClass().getName().lastIndexOf(".") + 1) + "[" + "id=" + this.id + ", " + "eventDefinition.name=" + ((this.eventDefinition != null) ? this.eventDefinition.getName() : "null") + ", " + "resource.name=" + ((this.resource != null) ? this.resource.getName() : "null") + ", " + "location=" + this.location + "]"; } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null || !(obj instanceof EventSource)) return false; EventSource that = (EventSource) obj; if (!eventDefinition.equals(that.eventDefinition)) return false; if (resourceId != that.resourceId) return false; if (!location.equals(that.location)) return false; return true; }
public Event(@NotNull long timestamp, @NotNull EventSeverity severity, @NotNull EventSource source, @NotNull String detail) { if(source==null) throw new IllegalArgumentException("Source must not be null."); this.timestamp = timestamp; this.severity = severity; this.detail = detail; this.sourceLocation = source.getLocation(); this.source = source; }
@Override public int hashCode() { int result; result = eventDefinition.hashCode(); result = 31 * result + resourceId; result = 31 * result + location.hashCode(); return result; }
@Override public int hashCode() { int result = 31 + (int) (timestamp ^ (timestamp >>> 32)); result = 31 * result + severity.hashCode(); result = 31 * result + detail.hashCode(); return result; }
private Integer getAgentId(EventSource source) { try { int resourceId = source.getResource().getId(); Integer agentId = agentManager.getAgentIdByResourceId(resourceId); return agentId; } catch (Throwable t) { log.error("Error looking up agent by EventSource", t); } return null; }
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>(); events.add(event); eventManager.publishEvents(events, this.resource); }
/** * Returns the EventDefinition with the specified name for the given Resource type, or null if no EventDefintion * by that name exists. * * @param name the name of the EventDefinition * @param resourceType a resource type * * @return the EventDefinition with the specified name for the given Resource type, or null if no EventDefintion * by that name exists */ @Nullable public static EventDefinition getEventDefinition(String name, ResourceType resourceType) { Set<EventDefinition> eventDefinitions = resourceType.getEventDefinitions(); if (eventDefinitions != null) { for (EventDefinition eventDefinition : eventDefinitions) { if (eventDefinition.getName().equals(name)) { return eventDefinition; } } } return null; }
/** * Determine if this severity is at least as severe as that of other * @param other EventSeverity to compare * @return if at least as severe */ public boolean isAtLeastAsSevereAs(EventSeverity other) { if (other == null) // If other is null, our severity is always higher return true; return (ordinal() >= other.ordinal()); }
/** * Getter for use in JSP pages * @return the same value as {@link EventSeverity#ordinal()} */ public int getOrdinal() { return ordinal(); }