diff --git a/src/main/java/dlt/load/monitor/model/LoadMonitor.java b/src/main/java/dlt/load/monitor/model/LoadMonitor.java index 34c33eb..d6ef568 100644 --- a/src/main/java/dlt/load/monitor/model/LoadMonitor.java +++ b/src/main/java/dlt/load/monitor/model/LoadMonitor.java @@ -18,6 +18,7 @@ public class LoadMonitor implements Runnable { private Processor processor; private int samplingInterval; private IDevicePropertiesManager deviceManager; + private static final Logger logger = Logger.getLogger(LoadMonitor.class.getName()); public LoadMonitor(int samplingInterval) { this.samplingInterval = samplingInterval; @@ -54,7 +55,7 @@ public void run() { qtdDevices = this.deviceManager.getAllDevices().size(); this.processor.updateBrokerStatus(qtdDevices); } catch (IOException | InterruptedException ex) { - Logger.getLogger(LoadMonitor.class.getName()).log(Level.SEVERE, null, ex); + logger.log(Level.SEVERE, null, ex); this.stop(); } } diff --git a/src/main/java/dlt/load/monitor/model/Processor.java b/src/main/java/dlt/load/monitor/model/Processor.java index 5ea68ed..20f4714 100644 --- a/src/main/java/dlt/load/monitor/model/Processor.java +++ b/src/main/java/dlt/load/monitor/model/Processor.java @@ -1,5 +1,7 @@ package dlt.load.monitor.model; +import java.util.logging.Logger; + /** * * @author Allan Capistrano, Antonio Crispim, Uellington Damasceno @@ -12,6 +14,9 @@ public class Processor { private long lastSentLbEntry; private boolean flag; private long lbEntryTimeout; + private static final Logger logger = Logger.getLogger( + Processor.class.getName() + ); public Processor(int loadLimit) { this.loadLimit = loadLimit; @@ -22,16 +27,14 @@ protected void updateBrokerStatus(Integer qtdDevices) boolean lbEntry = (qtdDevices >= loadLimit); boolean available = ((qtdDevices + 1) < loadLimit); - System.out.println( + logger.info( "Amount of devices: " + qtdDevices + " | Need balancing? " + lbEntry ); if (lbEntry) { //Se o gateway está sobrecarregado. if ( flag || - System.currentTimeMillis() > - this.lastSentLbEntry + - lbEntryTimeout + System.currentTimeMillis() > this.lastSentLbEntry + lbEntryTimeout ) { // Salva o tempo da última vez que enviou uma transação do tipo LB_ENTRY. this.lastSentLbEntry = System.currentTimeMillis();