cleaned up ping code
This commit is contained in:
parent
9abf7c0952
commit
160c437430
1 changed files with 6 additions and 6 deletions
|
|
@ -68,14 +68,14 @@ public class NetScanController implements HalEventController, HalAutoScannableCo
|
||||||
NetworkDevice device = entry.getKey();
|
NetworkDevice device = entry.getKey();
|
||||||
SwitchEventData prevData = entry.getValue();
|
SwitchEventData prevData = entry.getValue();
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
//logger.finest("Pinging IP "+ device.getHost());
|
// We ping two times to increase reliability
|
||||||
boolean ping1 = InetScanner.isReachable(device.getHost(), executor);
|
boolean ping = false;
|
||||||
boolean ping2 = InetScanner.isReachable(device.getHost(), executor);
|
ping |= InetScanner.isReachable(device.getHost(), executor);
|
||||||
|
ping |= InetScanner.isReachable(device.getHost(), executor);
|
||||||
|
|
||||||
// Should we report?
|
// Should we report?
|
||||||
if (prevData == null ||
|
if (prevData == null || prevData.isOn() != ping) {
|
||||||
(ping1 == ping2 && prevData.isOn() != ping1)) { // only store if we get consistent pings
|
SwitchEventData newData = new SwitchEventData(ping, System.currentTimeMillis());
|
||||||
SwitchEventData newData = new SwitchEventData(ping1, System.currentTimeMillis());
|
|
||||||
entry.setValue(newData);
|
entry.setValue(newData);
|
||||||
logger.fine("IP "+device.getHost() +" state has changed to "+ newData.isOn());
|
logger.fine("IP "+device.getHost() +" state has changed to "+ newData.isOn());
|
||||||
listener.reportReceived(device, newData);
|
listener.reportReceived(device, newData);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue