use of org.opennms.netmgt.xml.eventconf.EventOrdering in project opennms by OpenNMS.
the class MockEventConfDao method reload.
@Override
public void reload() throws DataAccessException {
InputStream is = null;
InputStreamReader isr = null;
try {
is = m_resource.getInputStream();
isr = new InputStreamReader(is);
final Reader reader = isr;
m_events = JaxbUtils.unmarshal(Events.class, reader);
m_events.loadEventFiles(m_resource);
m_events.initialize(new EnterpriseIdPartition(), new EventOrdering());
} catch (final IOException e) {
throw new DataRetrievalFailureException("Failed to read from " + m_resource.toString(), e);
} finally {
IOUtils.closeQuietly(isr);
IOUtils.closeQuietly(is);
}
}
use of org.opennms.netmgt.xml.eventconf.EventOrdering in project opennms by OpenNMS.
the class DefaultEventConfDao method removeEventFromProgrammaticStore.
@Override
public boolean removeEventFromProgrammaticStore(Event event) {
Events programmaticEvents = m_events.getLoadEventsByFile(m_programmaticStoreRelativePath);
if (programmaticEvents == null)
return false;
programmaticEvents.removeEvent(event);
if (programmaticEvents.getEvents().size() <= 0) {
m_events.removeLoadedEventFile(m_programmaticStoreRelativePath);
}
m_events.initialize(m_partition, new EventOrdering());
return true;
}
use of org.opennms.netmgt.xml.eventconf.EventOrdering in project opennms by OpenNMS.
the class DefaultEventConfDao method reloadConfig.
private synchronized void reloadConfig() throws DataAccessException {
try {
// Load the root event file
Events events = JaxbUtils.unmarshal(Events.class, m_configResource);
// Hash the list of event files for efficient lookup
Set<String> eventFiles = new HashSet<String>();
eventFiles.addAll(events.getEventFiles());
// if and only if they exist in the new root
for (String eventFile : m_events.getEventFiles()) {
if (!eventFiles.contains(eventFile)) {
m_lastModifiedEventFiles.remove(eventFile);
continue;
}
events.addLoadedEventFile(eventFile, m_events.getLoadEventsByFile(eventFile));
}
// Load/reload the event files as necessary
events.loadEventFilesIfModified(m_configResource, m_lastModifiedEventFiles);
// Order the events for efficient searching
events.initialize(m_partition, new EventOrdering());
m_events = events;
} catch (Exception e) {
throw new DataRetrievalFailureException("Unabled to load " + m_configResource, e);
}
}
use of org.opennms.netmgt.xml.eventconf.EventOrdering in project opennms by OpenNMS.
the class DefaultEventConfDao method loadConfig.
private synchronized void loadConfig() throws DataAccessException {
try {
Events events = JaxbUtils.unmarshal(Events.class, m_configResource);
m_lastModifiedEventFiles = events.loadEventFiles(m_configResource);
m_partition = new EnterpriseIdPartition();
events.initialize(m_partition, new EventOrdering());
m_events = events;
} catch (Exception e) {
throw new DataRetrievalFailureException("Unabled to load " + m_configResource, e);
}
}
use of org.opennms.netmgt.xml.eventconf.EventOrdering in project opennms by OpenNMS.
the class DefaultEventConfDao method addEventToProgrammaticStore.
@Override
public void addEventToProgrammaticStore(Event event) {
Events programmaticEvents = m_events.getLoadEventsByFile(m_programmaticStoreRelativePath);
if (programmaticEvents == null) {
programmaticEvents = new Events();
m_events.addLoadedEventFile(m_programmaticStoreRelativePath, programmaticEvents);
}
programmaticEvents.addEvent(event);
m_events.initialize(m_partition, new EventOrdering());
}
Aggregations