/** * @deprecated We should specify a reason on every PollStatus object. * * @return a {@link org.opennms.netmgt.poller.PollStatus} object. */ public static PollStatus down() { return down(null); }
@Override public PollStatus onUnknown(Throwable cause) { LOG.error("Unexpected exception while polling {}. Marking service as DOWN", m_service, e); return PollStatus.down("Unexpected exception while polling "+m_service+". "+e); } });
/** * <p>bringDown</p> * * @param reason a {@link java.lang.String} object. */ public void bringDown(String reason) { setServicePollStatus(PollStatus.down(reason)); }
@Override public void processRow(ResultSet rs) throws SQLException { PassiveStatusKey key = new PassiveStatusKey(rs.getString("nodeLabel"), rs.getString("ipAddr"), rs.getString("serviceName")); m_statusTable.put(key, PollStatus.down()); }
/** * <p>bringDown</p> */ public void bringDown() { setServicePollStatus(PollStatus.down()); }
/** {@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 visitElement(PollableElement e) { e.updateStatus(PollStatus.down()); } };
/** {@inheritDoc} */ @Override protected PollEvent doExtrapolateCause() { // find the member cause with the largest scope PollEvent cause = extrapolateMemberCauseWithLargestScope(); // use this largest scope as the cause for the container setCause(cause); if (cause != null) { // we must be down set set status appropriately updateStatus(PollStatus.down()); } // return the cause to parent container return cause; }
@Override public void run() { SimpleIter<PollStatus> iter = new SimpleIter<PollStatus>(PollStatus.down()) { @Override public void forEachElement(PollableElement elem) { elem.recalculateStatus(); if (elem.getStatus().isUp()) setResult(PollStatus.up()); } }; forEachMember(iter); updateStatus(iter.getResult()); } };
/** {@inheritDoc} */ @Override protected PollStatus poll(PollableElement elem) { PollableService critSvc = getCriticalService(); if (getStatus().isUp() || critSvc == null || elem == critSvc) return super.poll(elem); return PollStatus.down(); }
private void assertDown(PollableElement elem) { assertEquals(PollStatus.down(), elem.getStatus()); }
/** * <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(); } }
@Override public void visitElement(PollableElement e) { assertEquals(PollStatus.down(), e.getStatus()); assertEquals(true, e.isStatusChanged()); } };
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); }
@Test public void testPollStatus() { //Compare construction via constant PollStatus statusDown1 = PollStatus.down("test down 1"); PollStatus statusDown2 = PollStatus.down("test down 2"); assertTrue(statusDown1.getStatusCode() == statusDown2.getStatusCode()); assertFalse(statusDown1.getStatusCode() == statusDown3.getStatusCode()); assertTrue(statusDown1.isDown()); assertTrue(statusDown3.isUp()); assertTrue(statusAvailable1.isUp()); assertFalse(statusAvailable1.isDown()); }
private void anticipateDown(MockElement element, boolean force) { if (force || !element.getPollStatus().equals(PollStatus.down())) { Event event = element.createDownEvent(); m_eventMgr.getEventAnticipator().anticipateEvent(event); for (Event outageCreatedEvent: m_outageAnticipator.anticipateOutageOpened(element, event)) { m_eventMgr.getEventAnticipator().anticipateEvent(outageCreatedEvent); } } }
private void anticipateDown(MockElement element, boolean force) { if (force || !element.getPollStatus().equals(PollStatus.down())) { Event event = element.createDownEvent(); m_eventMgr.getEventAnticipator().anticipateEvent(event); for (Event outageCretedEvent : m_outageAnticipator.anticipateOutageOpened(element, event)){ m_eventMgr.getEventAnticipator().anticipateEvent(outageCretedEvent); } } }