use of org.opennms.netmgt.scheduler.Schedule in project opennms by OpenNMS.
the class PollablesIT method addServiceToNetwork.
private PollableService addServiceToNetwork(final PollableNetwork pNetwork, int nodeId, String nodeLabel, String nodeLocation, String ipAddr, String serviceName, Number svcLostEventId, String svcLostUei, Date svcLostTime, final ScheduleTimer scheduler, final PollerConfig pollerConfig, final PollOutagesConfig pollOutageConfig) {
InetAddress addr = getInetAddress(ipAddr);
Package pkg = findPackageForService(pollerConfig, ipAddr, serviceName);
if (pkg == null) {
MockUtil.println("No package for service " + serviceName + " with ipAddr " + ipAddr);
return null;
}
PollableService svc = pNetwork.createService(nodeId, nodeLabel, nodeLocation, addr, serviceName);
PollableServiceConfig pollConfig = new PollableServiceConfig(svc, pollerConfig, pollOutageConfig, pkg, scheduler, m_persisterFactory, m_resourceStorageDao, m_locationAwarePollerClient);
svc.setPollConfig(pollConfig);
synchronized (svc) {
if (svc.getSchedule() == null) {
Schedule schedule = new Schedule(svc, pollConfig, scheduler);
svc.setSchedule(schedule);
}
}
//MockUtil.println("svcLostEventId for "+svc+" is "+svcLostEventId);
if (svcLostEventId == null) {
if (svc.getParent().getStatus().isUnknown()) {
svc.updateStatus(PollStatus.up());
} else {
svc.updateStatus(svc.getParent().getStatus());
svc.setCause(svc.getParent().getCause());
}
} else {
svc.updateStatus(PollStatus.down());
PollEvent cause = new DbPollEvent(svcLostEventId.intValue(), svcLostUei, svcLostTime);
svc.setCause(cause);
}
return svc;
}
use of org.opennms.netmgt.scheduler.Schedule in project opennms by OpenNMS.
the class PollableNetwork method schedule.
/**
* <p>schedule</p>
*
* @param node a {@link org.opennms.netmgt.snmpinterfacepoller.pollable.PollableSnmpInterface} object.
* @param criteria a {@link java.lang.String} object.
* @param interval a long.
* @param scheduler a {@link org.opennms.netmgt.scheduler.Scheduler} object.
*/
public void schedule(PollableSnmpInterface node, long interval, org.opennms.netmgt.scheduler.Scheduler scheduler) {
PollableSnmpInterfaceConfig nodeconfig = new PollableSnmpInterfaceConfig(scheduler, interval);
node.setSnmppollableconfig(nodeconfig);
synchronized (node) {
if (node.getSchedule() == null) {
Schedule schedule = new Schedule(node, nodeconfig, scheduler);
node.setSchedule(schedule);
}
}
node.schedule();
}
use of org.opennms.netmgt.scheduler.Schedule in project opennms by OpenNMS.
the class Vacuumd method scheduleAutomation.
private void scheduleAutomation(Automation auto) {
if (auto.getActive()) {
AutomationProcessor ap = new AutomationProcessor(auto);
Schedule s = new Schedule(ap, new AutomationInterval(auto.getInterval()), m_scheduler);
ap.setSchedule(s);
s.schedule();
}
}
use of org.opennms.netmgt.scheduler.Schedule in project opennms by OpenNMS.
the class Poller method scheduleService.
private boolean scheduleService(OnmsMonitoredService service) {
final OnmsIpInterface iface = service.getIpInterface();
final Set<OnmsOutage> outages = service.getCurrentOutages();
final OnmsOutage outage = (outages == null || outages.size() < 1 ? null : outages.iterator().next());
final OnmsEvent event = (outage == null ? null : outage.getServiceLostEvent());
final String ipAddr = InetAddressUtils.str(iface.getIpAddress());
final String serviceName = service.getServiceName();
boolean active = "A".equals(service.getStatus());
final Number svcLostEventId = event == null ? null : event.getId();
final Date ifLostService = outage == null ? null : outage.getIfLostService();
final String svcLostUei = event == null ? null : event.getEventUei();
closeOutageIfSvcLostEventIsMissing(outage);
// We don't want to adjust the management state of the service if we're
// on a machine that uses multiple servers with access to the same database
// so check the value of OpennmsServerConfigFactory.getInstance().verifyServer()
// before doing any updates.
final Package pkg = findPackageForService(ipAddr, serviceName);
final boolean verifyServer = OpennmsServerConfigFactory.getInstance().verifyServer();
if (pkg == null) {
if (active && !verifyServer) {
LOG.warn("Active service {} on {} not configured for any package. Marking as Not Polled.", serviceName, ipAddr);
updateServiceStatus(service, "N");
}
return false;
} else if (!active && !verifyServer) {
LOG.info("Active service {} on {} is now configured for a package. Marking as active.", serviceName, ipAddr);
updateServiceStatus(service, "A");
}
ServiceMonitor monitor = m_pollerConfig.getServiceMonitor(serviceName);
if (monitor == null) {
LOG.info("Could not find service monitor associated with service {}", serviceName);
return false;
}
InetAddress addr;
addr = InetAddressUtils.addr(ipAddr);
if (addr == null) {
LOG.error("Could not convert {} as an InetAddress {}", ipAddr, ipAddr);
return false;
}
PollableService svc = getNetwork().createService(service.getNodeId(), iface.getNode().getLabel(), iface.getNode().getLocation().getLocationName(), addr, serviceName);
PollableServiceConfig pollConfig = new PollableServiceConfig(svc, m_pollerConfig, m_pollOutagesConfig, pkg, getScheduler(), m_persisterFactory, m_resourceStorageDao, m_locationAwarePollerClient);
svc.setPollConfig(pollConfig);
synchronized (svc) {
if (svc.getSchedule() == null) {
Schedule schedule = new Schedule(svc, pollConfig, getScheduler());
svc.setSchedule(schedule);
}
}
if (svcLostEventId == null) {
if (svc.getParent().getStatus().isUnknown()) {
svc.updateStatus(PollStatus.up());
} else {
svc.updateStatus(svc.getParent().getStatus());
}
} else {
svc.updateStatus(PollStatus.down());
PollEvent cause = new DbPollEvent(svcLostEventId.intValue(), svcLostUei, ifLostService);
svc.setCause(cause);
}
svc.schedule();
return true;
}
Aggregations