Some cleanup

parent 1b7f296f
......@@ -16,7 +16,8 @@ public class NetMonitor extends ResourceManager {
public NetMonitor(ElasticSystem elasticSystem) {
super(elasticSystem);
this.hardwareInfo = new HardwareInfo("enp0s3");
//this.hardwareInfo = new HardwareInfo("enp0s3");
this.hardwareInfo = new HardwareInfo();
//this.node = getNodeByIP("10.0.2.15"); //TODO: get IP as I should
}
......@@ -34,7 +35,7 @@ public class NetMonitor extends ResourceManager {
collect(Collectors.toList());
commsList.stream().forEach(cl -> {
cl.setDelayRtt(hardwareInfo.getLinkRTT(cl.getIpNode2()));
cl.setDelayRtt(hardwareInfo.getLinkRTT(cl.getIpNode2(),"eth0"));
});
//hardwareInfo.getLinksRTT();
......
......@@ -24,6 +24,7 @@ public class NFRTool {
DataClay.init();
/*
/////////////////////////////////////////////////////////////////////////////////////////////////
// App A definition:
String name = "AppA";
......@@ -193,18 +194,15 @@ public class NFRTool {
add(appB);
}
};
ElasticSystem system = new ElasticSystem(systemApps, systemNodes);
*/
ElasticSystem system = ElasticSystem.getByAlias("system");
NFRMonitor nfrMonitor = new NFRMonitor(new ResourceManagerComms(system), new NetMonitor(system), Constants.PERIOD);
nfrMonitor.runMonitor();
// HardwareInfo h = new HardwareInfo("enp0s3");
/*
* ArrayList<String> gfg = new ArrayList<String>() { { add("8.8.8.8");
* add("4.4.4.4"); add("127.0.0.1"); } };
* System.out.println(h.getLinksRTT(gfg).toString());
*/
}
}
......@@ -130,7 +130,7 @@ public class ResourceManagerComms extends ResourceManager {
for (int ll = 0; ll < workerLinks.size(); ll++) {
// float monitoredRTT = workerLinks.get(ll).getDelayRtt();
if (workerLinks.get(ll).getDelayRtt() >= rttmax) {
worker.setActive(false); // Is inactive true or false?
worker.setActive(false);
System.out.println("[NFR Resource Manager] Max. RTT exceeded. Worker disabled");
worker.setCommunicationCost(Float.POSITIVE_INFINITY);
return -1;
......@@ -143,9 +143,6 @@ public class ResourceManagerComms extends ResourceManager {
// + ")");
worker.setCommunicationCost((float) commsCost);
return commsCost;
/*
* Double obj = new Double(commsCost); float f = obj.floatValue();
*/
}
public void getCosts(Node node) {
......@@ -207,7 +204,6 @@ public class ResourceManagerComms extends ResourceManager {
return costMap;
}
// TODO For now, all workers for a specific application
public void modifyWorkersStatus(Node node, boolean isSecure) {
node.getWorkers().stream().filter(Worker::isActive).forEach(worker -> worker.setActive(isSecure));
......
......@@ -82,11 +82,12 @@ public class HardwareInfo {
* return netInterfacesMap; }
*/
public float getLinkRTT(String ip) {
public float getLinkRTT(String ip, String netInterfaceName) {
try {
//TODO: the netInterfaceName should be obtained from dataClay's infoNature attributes instead of passing it as an argument to HardwareInfo
String cmdStr = "ping -c 1 -w 1 -W 1 -I " + this.netInterfaceName + " " + ip;
//TODO: the netInterfaceName should be obtained from dataClay's CommunicationLink attributes instead of passing it as an argument to HardwareInfo
//String cmdStr = "ping -c 1 -w 1 -W 1 -I " + this.netInterfaceName + " " + ip;
String cmdStr = "ping -c 1 -w 1 -W 1 -I " + netInterfaceName + " " + ip;
//String cmdStr = "ping -c 1 -w 1 -W 1 -I " + "enp0s3" + " " + ip; //TODO: get netInterfaceName
//System.out.println(cmdStr);
Process process = Runtime.getRuntime().exec(cmdStr, env);
......@@ -117,7 +118,7 @@ public class HardwareInfo {
Matcher m = r.matcher(pingText);
if (m.find()) {
String rtt = m.group(1);
System.out.println("[NFR Monitor] Monitored RTT to target IP \t" + ip + "\t: " + rtt + "ms");
System.out.println("[NFR Monitor] Monitored RTT to target Node:\t" + rtt + "ms");
return Float.parseFloat(rtt);
}
else
......@@ -154,11 +155,11 @@ public class HardwareInfo {
* networkStats); } }
*/
public Map<String,Float> getLinksRTT(ArrayList<String> IPs) {
/*public Map<String,Float> getLinksRTT(ArrayList<String> IPs) {
return IPs.stream().collect(Collectors.toMap(ip -> ip, ip -> getLinkRTT(ip)));
}
}*/
private void getMemoryInfo() {
......
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