@Test public void testNotFoundWithCustomRcode() throws UnknownHostException { final Map<String, Object> m = new ConcurrentSkipListMap<String, Object>(); final ServiceMonitor monitor = new DnsMonitor(); final MonitoredService svc = MonitorTestUtils.getMonitoredService(99, addr("127.0.0.1"), "DNS"); m.put("port", "9153"); m.put("retry", "2"); m.put("timeout", "5000"); m.put("lookup", "bogus.example.com"); m.put("fatal-response-codes", "3"); final PollStatus status = monitor.poll(svc, m); MockUtil.println("Reason: "+status.getReason()); assertEquals(PollStatus.SERVICE_UNAVAILABLE, status.getStatusCode()); }
public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) { NetworkInterface<InetAddress> iface = svc.getNetInterface(); if (iface.getType() != NetworkInterface.TYPE_INET) throw new NetworkInterfaceNotSupportedException("Unsupported interface type, only TYPE_INET currently supported"); TimeoutTracker timeoutTracker = new TimeoutTracker(parameters, DEFAULT_RETRY, DEFAULT_TIMEOUT); int port = ParameterMap.getKeyedInteger(parameters, "port", DEFAULT_PORT); String lookup = ParameterMap.getKeyedString(parameters, "lookup", null); if (lookup == null || lookup.length() == 0) { lookup = InetAddressUtils.getLocalHostAddressAsString(); if (lookup == null) { throw new UnsupportedOperationException("Unable to look up local host address."); } } final List<Integer> fatalCodes = new ArrayList<Integer>(); for (final int code : ParameterMap.getKeyedIntegerArray(parameters, "fatal-response-codes", DEFAULT_FATAL_RESP_CODES)) { fatalCodes.add(code); } int minAnswers = ParameterMap.getKeyedInteger(parameters, "min-answers", DEFAULT_MIN_ANSWERS); int maxAnswers = ParameterMap.getKeyedInteger(parameters, "max-answers", DEFAULT_MAX_ANSWERS); final InetAddress addr = iface.getAddress(); PollStatus serviceStatus = null; serviceStatus = pollDNS(timeoutTracker, port, addr, lookup, fatalCodes, minAnswers, maxAnswers); if (serviceStatus == null) { serviceStatus = logDown(Level.DEBUG, "Never received valid DNS response for address: " + addr); } return serviceStatus; }
DnsMonitor extends AbstractServiceMonitor { public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) { NetworkInterface<InetAddress> iface = svc.getNetInterface(); if (iface.getType() != NetworkInterface.TYPE_INET) throw new NetworkInterfaceNotSupportedException("Unsupported interface type, only TYPE_INET currently supported"); TimeoutTracker timeoutTracker = new TimeoutTracker(parameters, DEFAULT_RETRY, DEFAULT_TIMEOUT); int port = ParameterMap.getKeyedInteger(parameters, "port", DEFAULT_PORT); String lookup = ParameterMap.getKeyedString(parameters, "lookup", null); if (lookup == null || lookup.length() == 0) { lookup = InetAddressUtils.getLocalHostAddressAsString(); if (lookup == null) { throw new UnsupportedOperationException("Unable to look up local host address."); } } final List<Integer> fatalCodes = new ArrayList<Integer>(); for (final int code : ParameterMap.getKeyedIntegerArray(parameters, "fatal-response-codes", DEFAULT_FATAL_RESP_CODES)) { fatalCodes.add(code); } int minAnswers = ParameterMap.getKeyedInteger(parameters, "min-answers", DEFAULT_MIN_ANSWERS); int maxAnswers = ParameterMap.getKeyedInteger(parameters, "max-answers", DEFAULT_MAX_ANSWERS); final InetAddress addr = iface.getAddress(); PollStatus serviceStatus = null; serviceStatus = pollDNS(timeoutTracker, port, addr, lookup, fatalCodes, minAnswers, maxAnswers); if (serviceStatus == null) { serviceStatus = logDown(Level.DEBUG, "Never received valid DNS response for address: " + addr); } return serviceStatus; } }
DnsMonitor extends AbstractServiceMonitor { public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) { NetworkInterface<InetAddress> iface = svc.getNetInterface(); if (iface.getType() != NetworkInterface.TYPE_INET) throw new NetworkInterfaceNotSupportedException("Unsupported interface type, only TYPE_INET currently supported"); TimeoutTracker timeoutTracker = new TimeoutTracker(parameters, DEFAULT_RETRY, DEFAULT_TIMEOUT); int port = ParameterMap.getKeyedInteger(parameters, "port", DEFAULT_PORT); String lookup = ParameterMap.getKeyedString(parameters, "lookup", null); if (lookup == null || lookup.length() == 0) { lookup = InetAddressUtils.getLocalHostAddressAsString(); if (lookup == null) { throw new UnsupportedOperationException("Unable to look up local host address."); } } final List<Integer> fatalCodes = new ArrayList<Integer>(); for (final int code : ParameterMap.getKeyedIntegerArray(parameters, "fatal-response-codes", DEFAULT_FATAL_RESP_CODES)) { fatalCodes.add(code); } int minAnswers = ParameterMap.getKeyedInteger(parameters, "min-answers", DEFAULT_MIN_ANSWERS); int maxAnswers = ParameterMap.getKeyedInteger(parameters, "max-answers", DEFAULT_MAX_ANSWERS); final InetAddress addr = iface.getAddress(); PollStatus serviceStatus = null; serviceStatus = pollDNS(timeoutTracker, port, addr, lookup, fatalCodes, minAnswers, maxAnswers); if (serviceStatus == null) { serviceStatus = logDown(Level.DEBUG, "Never received valid DNS response for address: " + addr); } return serviceStatus; }  }
DnsMonitor extends AbstractServiceMonitor { public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) { NetworkInterface<InetAddress> iface = svc.getNetInterface(); if (iface.getType() != NetworkInterface.TYPE_INET) throw new NetworkInterfaceNotSupportedException("Unsupported interface type, only TYPE_INET currently supported"); TimeoutTracker timeoutTracker = new TimeoutTracker(parameters, DEFAULT_RETRY, DEFAULT_TIMEOUT); int port = ParameterMap.getKeyedInteger(parameters, "port", DEFAULT_PORT); String lookup = ParameterMap.getKeyedString(parameters, "lookup", null); if (lookup == null || lookup.length() == 0) { lookup = InetAddressUtils.getLocalHostAddressAsString(); if (lookup == null) { throw new UnsupportedOperationException("Unable to look up local host address."); } } final List<Integer> fatalCodes = new ArrayList<Integer>(); for (final int code : ParameterMap.getKeyedIntegerArray(parameters, "fatal-response-codes", DEFAULT_FATAL_RESP_CODES)) { fatalCodes.add(code); } int minAnswers = ParameterMap.getKeyedInteger(parameters, "min-answers", DEFAULT_MIN_ANSWERS); int maxAnswers = ParameterMap.getKeyedInteger(parameters, "max-answers", DEFAULT_MAX_ANSWERS); final InetAddress addr = iface.getAddress(); PollStatus serviceStatus = null; serviceStatus = pollDNS(timeoutTracker, port, addr, lookup, fatalCodes, minAnswers, maxAnswers); if (serviceStatus == null) { serviceStatus = logDown(Level.DEBUG, "Never received valid DNS response for address: " + addr); } return serviceStatus; }  PollStatus poll(MonitoredService svc, Map<String, Object> parameters); }
DnsMonitor extends AbstractServiceMonitor { public PollStatus poll(MonitoredService svc, Map<String, Object> parameters) { NetworkInterface<InetAddress> iface = svc.getNetInterface(); if (iface.getType() != NetworkInterface.TYPE_INET) throw new NetworkInterfaceNotSupportedException("Unsupported interface type, only TYPE_INET currently supported"); TimeoutTracker timeoutTracker = new TimeoutTracker(parameters, DEFAULT_RETRY, DEFAULT_TIMEOUT); int port = ParameterMap.getKeyedInteger(parameters, "port", DEFAULT_PORT); String lookup = ParameterMap.getKeyedString(parameters, "lookup", null); if (lookup == null || lookup.length() == 0) { lookup = InetAddressUtils.getLocalHostAddressAsString(); if (lookup == null) { throw new UnsupportedOperationException("Unable to look up local host address."); } } final List<Integer> fatalCodes = new ArrayList<Integer>(); for (final int code : ParameterMap.getKeyedIntegerArray(parameters, "fatal-response-codes", DEFAULT_FATAL_RESP_CODES)) { fatalCodes.add(code); } int minAnswers = ParameterMap.getKeyedInteger(parameters, "min-answers", DEFAULT_MIN_ANSWERS); int maxAnswers = ParameterMap.getKeyedInteger(parameters, "max-answers", DEFAULT_MAX_ANSWERS); final InetAddress addr = iface.getAddress(); PollStatus serviceStatus = null; serviceStatus = pollDNS(timeoutTracker, port, addr, lookup, fatalCodes, minAnswers, maxAnswers); if (serviceStatus == null) { serviceStatus = logDown(Level.DEBUG, "Never received valid DNS response for address: " + addr); } return serviceStatus; }  PollStatus poll(MonitoredService svc, Map<String, Object> parameters);  }