Fixed getSelfIfaces

parent 11ee0a5b
HOST=10.0.2.15
HOST=0.0.0.0
TCPPORT=11034
......@@ -36,7 +36,10 @@ public class CommsMonitoringTask extends TimerTask {
this.resourceManager.getConfig(Constants.CONFIG_FILE_PATH);
this.netMonitor
.setLinksRTT(this.resourceManager.getNodeByIP(this.resourceManager.getSelfIfaces().get("eth0")));
//this.netMonitor
// .setLinksRTT(this.resourceManager.getNodeByIP(this.resourceManager.getSelfIfaces().get("enp0s3")));
this.resourceManager.getCosts(this.resourceManager.getNodeByIP(this.resourceManager.getSelfIfaces().get("eth0")));
//this.resourceManager.getCosts(this.resourceManager.getNodeByIP(this.resourceManager.getSelfIfaces().get("enp0s3")));
System.out.println();
} catch (SocketException e) {
throw new RuntimeException(e);
......
......@@ -3,6 +3,7 @@ package nfrTool;
import java.io.FileNotFoundException;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.List;
import es.bsc.compss.nfr.model.COMPSsApplication;
import es.bsc.compss.nfr.model.CommunicationLink;
......@@ -24,7 +25,7 @@ public class NFRTool {
DataClay.init();
/*
/////////////////////////////////////////////////////////////////////////////////////////////////
// App A definition:
String name = "AppA";
......@@ -47,8 +48,8 @@ public class NFRTool {
// Node 1 definition:
String ipWifi = "182.168.137.17";
String ipLte = "172.10.0.2";
//String ipEth = "192.168.137.17"; // TODO: check value
String ipEth = "10.0.2.15"; // TODO: check value
String ipEth = "192.168.137.17"; // TODO: check value
//String ipEth = "192.168.137.197"; // TODO: check value
float cpuThreshold = 0;
float energyThreshold = 0;
float signalWifi = -30;
......@@ -59,7 +60,7 @@ public class NFRTool {
// Node 2 definition:
ipWifi = "182.168.137.179";
ipLte = "172.10.0.4";
ipEth = "192.168.137.179"; // TODO: check value
ipEth = "192.168.137.197"; // TODO: check value
cpuThreshold = 0;
energyThreshold = 0;
signalWifi = -30;
......@@ -70,7 +71,7 @@ public class NFRTool {
// Node 3 definition:
ipWifi = "182.168.137.1";
ipLte = "172.10.0.6";
ipEth = "192.168.137.17"; // TODO: check value
ipEth = "192.168.137.3"; // TODO: check value
cpuThreshold = 0;
energyThreshold = 0;
signalWifi = -30;
......@@ -83,10 +84,12 @@ public class NFRTool {
final int pid1A = 32145;
final boolean active1A = true;
final float cpuUsage1A = 0;
final float energyUsage1A = 0;
final int computingUnits1A = 4;
final float communicationCost1A = 0;
//final List<String> deactivationReasons1A;
Worker worker1A = new Worker(node1, pid1A, active1A, appA, cpuUsage1A, computingUnits1A, node1.getIpEth(),
Worker worker1A = new Worker(node1, pid1A, active1A, appA, cpuUsage1A, energyUsage1A, computingUnits1A, node1.getIpEth(),
communicationCost1A);
// Attach worker to Node and COMPSsApplication
//node1.addWorker(worker1A);
......@@ -96,10 +99,12 @@ public class NFRTool {
final int pid1B = 32146;
final boolean active1B = true;
final float cpuUsage1B = 0;
final float energyUsage1B = 0;
final int computingUnits1B = 4;
final float communicationCost1B = 0;
Worker worker1B = new Worker(node1, pid1B, active1B, appA, cpuUsage1B, computingUnits1B, node1.getIpEth(),
//final List<String> deactivationReasons1B;
Worker worker1B = new Worker(node1, pid1B, active1B, appB, cpuUsage1B, energyUsage1B, computingUnits1B, node1.getIpEth(),
communicationCost1B);
// Attach worker to Node and COMPSsApplication
//node1.addWorker(worker1B);
......@@ -109,10 +114,12 @@ public class NFRTool {
final int pid2A = 32147;
final boolean active2A = true;
final float cpuUsage2A = 0;
final float energyUsage2A = 0;
final int computingUnits2A = 4;
final float communicationCost2A = 0;
//final List<String> deactivationReasons2A;
Worker worker2A = new Worker(node2, pid2A, active2A, appA, cpuUsage2A, computingUnits2A, node1.getIpEth(),
Worker worker2A = new Worker(node2, pid2A, active2A, appA, cpuUsage2A, energyUsage2A, computingUnits2A, node1.getIpEth(),
communicationCost2A);
// Attach worker to Node and COMPSsApplication
//node2.addWorker(worker2A);
......@@ -122,10 +129,12 @@ public class NFRTool {
final int pid2B = 32148;
final boolean active2B = true;
final float cpuUsage2B = 0;
final float energyUsage2B = 0;
final int computingUnits2B = 4;
final float communicationCost2B = 0;
//final List<String> deactivationReasons2B;
Worker worker2B = new Worker(node2, pid2B, active2B, appB, cpuUsage2B, computingUnits2B, node1.getIpEth(),
Worker worker2B = new Worker(node2, pid2B, active2B, appB, cpuUsage2B, energyUsage2B, computingUnits2B, node1.getIpEth(),
communicationCost2B);
// Attach worker to Node and COMPSsApplication
//node2.addWorker(worker2B);
......@@ -135,10 +144,12 @@ public class NFRTool {
final int pid3A = 32149;
final boolean active3A = true;
final float cpuUsage3A = 0;
final float energyUsage3A = 0;
final int computingUnits3A = 4;
final float communicationCost3A = 0;
//final List<String> deactivationReasons3A;
Worker worker3A = new Worker(node3, pid3A, active3A, appA, cpuUsage3A, computingUnits3A, node3.getIpEth(),
Worker worker3A = new Worker(node3, pid3A, active3A, appA, cpuUsage3A, energyUsage3A, computingUnits3A, node3.getIpEth(),
communicationCost3A);
// Attach worker to Node and COMPSsApplication
//node3.addWorker(worker3A);
......@@ -148,10 +159,12 @@ public class NFRTool {
final int pid3B = 32150;
final boolean active3B = true;
final float cpuUsage3B = 0;
final float energyUsage3B = 0;
final int computingUnits3B = 4;
final float communicationCost3B = 0;
//final List<String> deactivationReasons3B;
Worker worker3B = new Worker(node3, pid3B, active3B, appB, cpuUsage3B, computingUnits3B, node3.getIpEth(),
Worker worker3B = new Worker(node3, pid3B, active3B, appB, cpuUsage3B, energyUsage3B, computingUnits3B, node3.getIpEth(),
communicationCost3B);
// Attach worker to Node and COMPSsApplication
//node3.addWorker(worker3B);
......@@ -196,9 +209,9 @@ public class NFRTool {
};
ElasticSystem system = new ElasticSystem(systemApps, systemNodes);
*/
ElasticSystem system = ElasticSystem.getByAlias("system");
//ElasticSystem system = ElasticSystem.getByAlias("system");
NFRMonitor nfrMonitor = new NFRMonitor(new ResourceManagerComms(system), new NetMonitor(system), Constants.PERIOD);
nfrMonitor.runMonitor();
......
package resourceManager;
import java.net.Inet4Address;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
......@@ -63,9 +64,8 @@ public abstract class ResourceManager {
for (NetworkInterface netint : Collections.list(nets)) {
Enumeration<InetAddress> addresses = netint.getInetAddresses();
for (InetAddress addr : Collections.list(addresses)) {
if (InetAddress.class == addr.getClass())
if (addr instanceof Inet4Address)
iFacesMap.put(netint.getName(), addr.getHostAddress());
break;
}
}
return iFacesMap;
......
......@@ -132,6 +132,7 @@ public class ResourceManagerComms extends ResourceManager {
if (workerLinks.get(ll).getDelayRtt() >= rttmax) {
worker.setActive(false);
System.out.println("[NFR Resource Manager] Max. RTT exceeded. Worker disabled");
System.out.println("Worker.setCommunicationCost(" + String.valueOf(Float.POSITIVE_INFINITY) + ")");
worker.setCommunicationCost(Float.POSITIVE_INFINITY);
return -1;
} else {
......@@ -139,8 +140,7 @@ public class ResourceManagerComms extends ResourceManager {
- (Math.log(Math.max(0, 1 - (workerLinks.get(ll).getDelayRtt() / rttmax))));
}
}
// System.out.println("Worker.setCommunicationCost(" + String.valueOf(commsCost)
// + ")");
System.out.println("Worker.setCommunicationCost(" + String.valueOf(commsCost) + ")");
worker.setCommunicationCost((float) commsCost);
return commsCost;
}
......@@ -149,12 +149,14 @@ public class ResourceManagerComms extends ResourceManager {
double commsCost = 0;
// Is Inactive True or False???
List<Worker> workerList = node.getWorkers();
List<Worker> activeWorkers = node.getWorkers().stream().filter(w -> w.isActive()).collect(Collectors.toList());
//List<Worker> activeWorkers = node.getWorkers().stream().filter(w -> w.isActive()).collect(Collectors.toList());
for (int ww = 0; ww < activeWorkers.size(); ww++) {
commsCost = getCost(activeWorkers.get(ww));
//for (int ww = 0; ww < activeWorkers.size(); ww++) {
//commsCost = getCost(activeWorkers.get(ww));
for (int ww = 0; ww < workerList.size(); ww++) {
commsCost = getCost(workerList.get(ww));
// System.out.println("Worker.setCommunicationCost(" + String.valueOf(commsCost) + ")");
}
//System.out.println("Worker.setCommunicationCost(" + String.valueOf(commsCost) + ")");
}
public Map<String, Double> getCost(JSONObject netTelemetry) {
......
......@@ -124,7 +124,7 @@ public class HardwareInfo {
else
System.out.println(output.toString());
} else {
// TODO: GESTION EXCEPCION ICMP TIMEOUT
// TODO: GESTION EXCEPCION ICMP TIMEOUT. CAMBIAR POR POSITIVE_INFINITY
System.out.println("ICMP error");
process.destroy();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment