/** * <p>Constructor for DemoPollService.</p> * * @param repetitions a int. */ public DemoPollService(int repetitions) { this(repetitions, PollStatus.up()); }
/** * <p>up</p> * * @return a {@link org.opennms.netmgt.poller.PollStatus} object. */ public static PollStatus up() { return up(null); }
/** * <p>Constructor for DemoPollService.</p> * * @param repetitions a int. */ public DemoPollService(int repetitions) { this(repetitions, PollStatus.up()); }
@Override public PollStatus getPollStatus() { return PollStatus.up(); }
/** * <p>Constructor for MockService.</p> * * @param iface a {@link org.opennms.netmgt.mock.MockInterface} object. * @param svcName a {@link java.lang.String} object. * @param serviceId a int. */ public MockService(MockInterface iface, String svcName, int serviceId) { super(iface); m_id = ID_COUNTER.getAndIncrement(); m_svcName = svcName; m_serviceId = serviceId; m_pollStatus = PollStatus.up(); m_pollCount = 0; }
/** * <p>bringUp</p> */ public void bringUp() { setServicePollStatus(PollStatus.up()); }
/** * <p>getStatus</p> * * @param nodeLabel a {@link java.lang.String} object. * @param ipAddr a {@link java.lang.String} object. * @param svcName a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.poller.PollStatus} object. */ public PollStatus getStatus(String nodeLabel, String ipAddr, String svcName) { //FIXME: Throw a log or exception here if this method is called and the this class hasn't been initialized PollStatus status = (m_statusTable == null ? PollStatus.unknown() : m_statusTable.get(new PassiveStatusKey(nodeLabel, ipAddr, svcName))); return (status == null ? PollStatus.up() : status); }
/** * <p>poll</p> * * @return a {@link org.opennms.netmgt.poller.PollStatus} object. */ @Override public PollStatus poll() { PollableElement leaf = selectPollElement(); if (leaf == null) return PollStatus.up(); return poll(leaf); }
/** {@inheritDoc} */ @Override public PollStatus poll(PolledService polledService) { PollStatus status = m_currentStatus; m_pollCount++; if (m_pollCount % m_repetitions == 0) { m_currentStatus = (m_currentStatus.isDown() ? PollStatus.up(100.0+m_pollCount) : PollStatus.down("pollCount is "+m_pollCount)); } return status; }
/** {@inheritDoc} */ @Override public PollStatus poll(PolledService polledService) { PollStatus status = m_currentStatus; m_pollCount++; if (m_pollCount % m_repetitions == 0) { m_currentStatus = (m_currentStatus.isDown() ? PollStatus.up(100.0+m_pollCount) : PollStatus.down("pollCount is "+m_pollCount)); } return status; }
/** * <p>getPollStatus</p> * * @return a {@link org.opennms.netmgt.poller.PollStatus} object. */ @Override public PollStatus getPollStatus() { for (MockElement element : m_members.values()) { if (element.getPollStatus().isUp()) { return PollStatus.up(); } } return PollStatus.down(); }
@Override public void forEachElement(PollableElement elem) { if (elem != member) { if (elem.poll().isUp()) setResult(PollStatus.up()); } } };
@Override public void forEachElement(PollableElement elem) { if (elem.getStatus().isUp()) setResult(PollStatus.up()); }
private void assertUp(PollableElement elem) { assertEquals(PollStatus.up(), elem.getStatus()); } private void assertDown(PollableElement elem) {
@Test public void testSetStatus() { testSetStatus("localhost", "127.0.0.1", "PSV", PollStatus.up()); }
/** * <p>recalculateStatus</p> */ @Override public void recalculateStatus() { PollableService criticalSvc = getCriticalService(); if (criticalSvc != null) { criticalSvc.recalculateStatus(); updateStatus(criticalSvc.getStatus().isUp() ? PollStatus.up() : PollStatus.down()); } else { super.recalculateStatus(); } }
public void testPoll() throws UnknownHostException { PassiveStatusKeeper psk = PassiveStatusKeeper.getInstance(); psk.setStatus("localhost", "127.0.0.1", "my-passive-service", PollStatus.get(PollStatus.SERVICE_UNAVAILABLE, "testing failure")); ServiceMonitor sm = new PassiveServiceMonitor(); MonitoredService ms = createMonitoredService(1, "localhost", null, "127.0.0.1", "my-passive-service"); PollStatus ps = sm.poll(ms, new HashMap<String, Object>()); assertEquals(PollStatus.down("fail."), ps); psk.setStatus("localhost", "127.0.0.1", "my-passive-service", PollStatus.get(PollStatus.SERVICE_AVAILABLE, "testing failure")); ps = sm.poll(ms, new HashMap<String, Object>()); assertEquals(PollStatus.up(), ps); }
private void anticipateUp(MockElement element, boolean force) { if (force || !element.getPollStatus().equals(PollStatus.up())) { Event event = element.createUpEvent(); m_eventMgr.getEventAnticipator().anticipateEvent(event); for (Event outageResolvedEvent: m_outageAnticipator.anticipateOutageClosed(element, event)){ m_eventMgr.getEventAnticipator().anticipateEvent(outageResolvedEvent); } } }
private void anticipateUp(MockElement element, boolean force) { if (force || !element.getPollStatus().equals(PollStatus.up())) { Event event = element.createUpEvent(); m_eventMgr.getEventAnticipator().anticipateEvent(event); for (Event outageResovedEvent: m_outageAnticipator.anticipateOutageClosed(element, event)) { m_eventMgr.getEventAnticipator().anticipateEvent(outageResovedEvent); } } }
@Test public void testInterfaceStatus() throws Exception { pDot2Smtp.updateStatus(PollStatus.down()); m_network.recalculateStatus(); assertDown(pDot2Smtp); assertUp(pDot2Smtp.getInterface()); pDot2Smtp.updateStatus(PollStatus.up()); m_network.recalculateStatus(); assertUp(pDot2Smtp); assertUp(pDot2Smtp.getInterface()); pDot2Icmp.updateStatus(PollStatus.down()); m_network.recalculateStatus(); assertDown(pDot2Icmp); assertDown(pDot2Icmp.getInterface()); }