/** * <p>getStatusCode</p> * * @return a int. */ @Transient public int getStatusCode() { return m_pollResult.getStatusCode(); } }
/** * Set poll status to unknown indicate an exception occurred while attempting to sleep the thread. * @param status * @param interval * @return returns an unchanged PollStatus unless an exception happens in which case status is changed to unknown. */ private int delayTest(PollStatus status, final long interval) { LOG.debug("delayTest: delaying test for: {}ms. per configuration.", interval); try { Thread.sleep(interval); } catch (final InterruptedException e) { LOG.error("delayTest: An interrupt exception occurred while delaying the mail test", e); status = PollStatus.unknown(e.getLocalizedMessage()); } return status.getStatusCode(); }
@Override public Map<String, Object> getRuntimeAttributes(MonitoredService svc, Map<String, Object> parameters) { final Map<String, Object> attributes = new HashMap<>(); final PollStatus pollStatus = doPoll(svc.getNodeId(), svc.getIpAddr(), m_svcName); attributes.put("status", Integer.toString(pollStatus.getStatusCode())); attributes.put("reason", pollStatus.getReason()); return attributes; }
try { PollStatus pollStatus = future.get(1, TimeUnit.SECONDS).getPollStatus(); if (pollStatus.getStatusCode() == PollStatus.SERVICE_AVAILABLE) { System.out.printf("\nService is %s on %s using %s:\n", pollStatus.getStatusName(), host, className); final Map<String, Number> properties = pollStatus.getProperties();
private PollStatus doPoll(int nodeId, String ipAddr, String svcName) { synchronized (m_network) { MockService svc = m_network.getService(nodeId, ipAddr, svcName); if (svc == null) { LOG.info("Invalid Poll: {}/{}/{}", nodeId, ipAddr, svcName); m_network.receivedInvalidPoll(ipAddr, svcName); return PollStatus.unknown("Mock."); } else { LOG.info("Poll: [{}/{}/{}]", svc.getInterface().getNode().getLabel(), ipAddr, svcName); PollStatus pollStatus = svc.poll(); return PollStatus.get(pollStatus.getStatusCode(), pollStatus.getReason()); } } }
System.out.printf("Available ? %s (status %s[%s])%n", status.isAvailable(), status.getStatusName(), status.getStatusCode()); if (status.isAvailable()) { System.out.printf("Response time: %s%n", status.getResponseTime());
@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()); }
@Test public void testSnmpInterfacePoll() throws UnknownHostException { SnmpAgentConfig agentConfig = SnmpPeerFactory.getInstance() .getAgentConfig(InetAddressUtils.getInetAddress("192.168.2.2")); // Invoke poll directly interfacesResult = snmpInterfaceMonitor.poll(agentConfig, interfacesResult); // Check if Poll Status is UP assertEquals(1, interfacesResult.get(0).getStatus().getStatusCode()); // Check if Admin/Operational Status are retrieved properly assertEquals(1, interfacesResult.get(0).getAdminstatus()); assertEquals(2, interfacesResult.get(0).getOperstatus()); }
@Test public void testPSM() throws Exception { InputStream is = new FileInputStream(new File("src/test/resources/etc/psm-poller-configuration.xml")); PollerConfigFactory factory = new PollerConfigFactory(0, is); PollerConfigFactory.setInstance(factory); IOUtils.closeQuietly(is); ServiceMonitor monitor = PollerConfigFactory.getInstance().getServiceMonitor("MQ_API_DirectRte_v2"); Assert.assertNotNull(monitor); Package pkg = PollerConfigFactory.getInstance().getPackage("MapQuest"); Assert.assertNotNull(pkg); Service svc = PollerConfigFactory.getInstance().getServiceInPackage("MQ_API_DirectRte_v2", pkg); Assert.assertNotNull(svc); Map<String, Object> parameters = new HashMap<String, Object>(); for (Parameter p : svc.getParameters()) { parameters.put(p.getKey(), p.getValue() == null ? p.getAnyObject() : p.getValue()); } PollStatus status = monitor.poll(new MockMonitoredService(1, "www.mapquest.com", InetAddress.getByName("www.mapquest.com"), "MQ_API_DirectRte_v2"), parameters); Assert.assertEquals(PollStatus.SERVICE_AVAILABLE, status.getStatusCode()); } }
if (status.getStatusCode() == PollStatus.SERVICE_AVAILABLE) { break;