Added some more traces and an additional thread to the netscan pool as the network scan will block the ping for 5 min
This commit is contained in:
parent
45eabe2845
commit
26e38ed704
1 changed files with 7 additions and 5 deletions
|
|
@ -18,6 +18,7 @@ import java.util.Map;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -43,7 +44,7 @@ public class NetScanController implements HalEventController, HalAutoScannableCo
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initialize() throws Exception {
|
public void initialize() throws Exception {
|
||||||
executor = Executors.newScheduledThreadPool(1);
|
executor = Executors.newScheduledThreadPool(2);
|
||||||
executor.scheduleAtFixedRate(NetScanController.this, 10_000, PING_INTERVAL, TimeUnit.MILLISECONDS);
|
executor.scheduleAtFixedRate(NetScanController.this, 10_000, PING_INTERVAL, TimeUnit.MILLISECONDS);
|
||||||
if (!HalContext.containsProperty(PARAM_IPSCAN) || HalContext.getBooleanProperty(PARAM_IPSCAN)) {
|
if (!HalContext.containsProperty(PARAM_IPSCAN) || HalContext.getBooleanProperty(PARAM_IPSCAN)) {
|
||||||
executor.scheduleAtFixedRate(new Runnable() {
|
executor.scheduleAtFixedRate(new Runnable() {
|
||||||
|
|
@ -56,7 +57,7 @@ public class NetScanController implements HalEventController, HalAutoScannableCo
|
||||||
scanner.scan(InetUtil.getLocalInet4Address().get(0));
|
scanner.scan(InetUtil.getLocalInet4Address().get(0));
|
||||||
logger.fine("Network scan done");
|
logger.fine("Network scan done");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
logger.log(Level.SEVERE, null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 30_000, NETWORK_SYNC_INTERVAL, TimeUnit.MILLISECONDS);
|
}, 30_000, NETWORK_SYNC_INTERVAL, TimeUnit.MILLISECONDS);
|
||||||
|
|
@ -68,6 +69,7 @@ public class NetScanController implements HalEventController, HalAutoScannableCo
|
||||||
try(MultiCommandExecutor executor = new MultiCommandExecutor();){
|
try(MultiCommandExecutor executor = new MultiCommandExecutor();){
|
||||||
for (Map.Entry<LocalNetworkDevice,SwitchEventData> entry : devices.entrySet()) {
|
for (Map.Entry<LocalNetworkDevice,SwitchEventData> entry : devices.entrySet()) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
|
logger.finest("Pinging IP "+entry.getKey().getHost());
|
||||||
boolean online = InetScanner.isReachable(entry.getKey().getHost(), executor);
|
boolean online = InetScanner.isReachable(entry.getKey().getHost(), executor);
|
||||||
if (entry.getValue() == null || entry.getValue().isOn() != online) {
|
if (entry.getValue() == null || entry.getValue().isOn() != online) {
|
||||||
entry.setValue(
|
entry.setValue(
|
||||||
|
|
@ -77,13 +79,13 @@ public class NetScanController implements HalEventController, HalAutoScannableCo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
logger.log(Level.SEVERE, null, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void foundInetAddress(InetAddress ip) {
|
public void foundInetAddress(InetAddress ip) {
|
||||||
logger.fine("Detected ip: "+ip.getHostAddress());
|
logger.fine("Auto Detected ip: "+ip.getHostAddress());
|
||||||
if (listener != null)
|
if (listener != null)
|
||||||
listener.reportReceived(
|
listener.reportReceived(
|
||||||
new LocalNetworkDevice(ip.getHostAddress()),
|
new LocalNetworkDevice(ip.getHostAddress()),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue