use of org.opennms.netmgt.config.poller.outages.Outage in project opennms by OpenNMS.
the class PollOutagesConfigManagerTest method testPerformance.
@Test
public void testPerformance() throws Exception {
long start = System.currentTimeMillis();
for (int i = 1; i <= 200; i++) {
String outageName = "o" + Integer.toString(i);
Outage outage = m_manager.getOutage(outageName);
assertTrue(outage != null);
assertTrue(m_manager.isNodeIdInOutage(i, outageName));
}
long end = System.currentTimeMillis();
System.out.println("Test took " + (end - start) + " ms");
}
use of org.opennms.netmgt.config.poller.outages.Outage in project opennms by OpenNMS.
the class PollOutagesConfigManager method isTimeInOutage.
/**
* {@inheritDoc}
*
* Return if time is part of specified outage.
*/
@Override
public boolean isTimeInOutage(final long time, final String outName) {
final Outage out = getOutage(outName);
if (out == null)
return false;
final Calendar cal = Calendar.getInstance();
cal.setTimeInMillis(time);
return isTimeInOutage(cal, out);
}
use of org.opennms.netmgt.config.poller.outages.Outage in project opennms by OpenNMS.
the class MockPollerConfig method addScheduledOutage.
/**
* Adds a scehduled outage to pkg from begin to end, for the nodeid
* @param pkg - the package to which
* @param outageName - a name, arbitrary
* @param begin - time, in seconds since epoch, when the outage starts
* @param end - time, in seconds since the epoch, when the outage ends
* @param nodeid - the node the outage applies to
*/
public void addScheduledOutage(Package pkg, String outageName, long begin, long end, int nodeid) {
Outage outage = new Outage();
outage.setName(outageName);
Node node = new Node();
node.setId(nodeid);
outage.addNode(node);
Time time = new Time();
Date beginDate = new Date(begin);
Date endDate = new Date(end);
time.setBegins(new SimpleDateFormat(BasicScheduleUtils.FORMAT1).format(beginDate));
time.setEnds(new SimpleDateFormat(BasicScheduleUtils.FORMAT1).format(endDate));
outage.addTime(time);
getObject().addOutage(outage);
pkg.addOutageCalendar(outageName);
}
use of org.opennms.netmgt.config.poller.outages.Outage in project opennms by OpenNMS.
the class ThresholdingSet method updateScheduledOutages.
protected void updateScheduledOutages() {
synchronized (m_scheduledOutages) {
m_scheduledOutages.clear();
ThreshdConfigManager configManager = ThreshdConfigFactory.getInstance();
for (org.opennms.netmgt.config.threshd.Package pkg : configManager.getConfiguration().getPackages()) {
for (String outageCal : pkg.getOutageCalendars()) {
LOG.info("updateScheduledOutages[node={}]: checking scheduled outage '{}'", m_nodeId, outageCal);
try {
Outage outage = PollOutagesConfigFactory.getInstance().getOutage(outageCal);
if (outage == null) {
LOG.info("updateScheduledOutages[node={}]: scheduled outage '{}' is not defined.", m_nodeId, outageCal);
} else {
LOG.debug("updateScheduledOutages[node={}]: outage calendar '{}' found on package '{}'", m_nodeId, outage.getName(), pkg.getName());
m_scheduledOutages.add(outageCal);
}
} catch (Exception e) {
LOG.info("updateScheduledOutages[node={}]: scheduled outage '{}' does not exist.", m_nodeId, outageCal);
}
}
}
}
}
use of org.opennms.netmgt.config.poller.outages.Outage in project opennms by OpenNMS.
the class MockPollerConfig method addScheduledOutage.
public void addScheduledOutage(Package pkg, String outageName, long begin, long end, String ipAddr) {
Outage outage = new Outage();
outage.setName(outageName);
Interface iface = new Interface();
iface.setAddress(ipAddr);
outage.addInterface(iface);
Time time = new Time();
Date beginDate = new Date(begin);
Date endDate = new Date(end);
time.setBegins(new SimpleDateFormat(BasicScheduleUtils.FORMAT1).format(beginDate));
time.setEnds(new SimpleDateFormat(BasicScheduleUtils.FORMAT1).format(endDate));
outage.addTime(time);
getObject().addOutage(outage);
pkg.addOutageCalendar(outageName);
}
Aggregations