Commit c8b10a7f authored by Johannes Kroß's avatar Johannes Kroß 🐳
Browse files

Merge branch 'feature-masterthesis-gunia' into 'master'

Improvements in Resource Environment Analysis and in Resource Container Utilization Calculation

See merge request !5
parents bf5b2572 b39bcb5d
......@@ -2,6 +2,7 @@ package org.fortiss.pmwt.pet.csv.client.simulation;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.fortiss.pmwt.pet.csv.client.csvParser.CSVParserSelector;
......@@ -73,6 +74,10 @@ public class SimulationStorage {
database.storeNetworkUtilization(this.simulation.getLinkingResourceUtil(linkingResource),
this.simulation.getId());
}
if(this.simulation.getLinkingResources().isEmpty()){
this.logger.info("No linking resources found. Will create empty Table 'Simulation_Network_Utilisation'");
database.storeNetworkUtilization(new HashMap<>(), this.simulation.getId());
}
this.logger.info("Finished storing Network Utilization");
......
......@@ -104,8 +104,15 @@ public class ResourceEnvironmentParser {
// CPU Configuration
resourceConfiguration = new CPUConfiguration(id, resourceTypePathmap);
CPUConfiguration cpuConfiguration = (CPUConfiguration) resourceConfiguration;
cpuConfiguration.setNumberOfCores(
Long.parseLong(activeResource.getAttribute(ParserConstants.NUMBER_OF_REPLICAS_ATTR)));
long numberCores = 0;
try{
numberCores = Long.parseLong(activeResource.getAttribute(ParserConstants.NUMBER_OF_REPLICAS_ATTR));
} catch (NumberFormatException e){
logger.info("No tag 'numberOfReplicas' found in XML structure. N=1 will be set.");
numberCores = 1;
}
cpuConfiguration.setNumberOfCores(numberCores);
Element processingRate = getImmediateElementsByTagName(activeResource,
ParserConstants.PROCESSING_RATE_TAG).get(0);
......
......@@ -192,17 +192,84 @@ public class Simulations implements Serializable {
resourceContainerConfiguration.getCpuConfiguration().getProcessingRate(),
resourceContainerConfiguration.getCpuConfiguration().getNumberOfCores(),
Constants.SIMULATION_INTERVAL));
if(percentile.get(Constants.MAX).isNaN()){
statistic.setMax(0d);
logger.info("CPU: Max Utilization is NaN, will be set to 0.");
} else {
statistic.setMax(percentile.get(Constants.MAX));
}
if(percentile.get(Constants.MIN).isNaN()){
statistic.setMin(0d);
logger.info("CPU: Min Utilization is NaN, will be set to 0.");
} else {
statistic.setMin(percentile.get(Constants.MIN));
}
if(percentile.get(Constants.MEDIAN).isNaN()){
statistic.setMean(0d);
logger.info("CPU: Mean Utilization is NaN, will be set to 0.");
} else {
statistic.setMean(percentile.get(Constants.MEDIAN));
}
if(percentile.get(Constants.QUARTILE1).isNaN()){
statistic.setQuartile1(0d);
logger.info("CPU: Quartile1 Utilization is NaN, will be set to 0.");
} else {
statistic.setQuartile1(percentile.get(Constants.QUARTILE1));
}
if(percentile.get(Constants.QUARTILE2).isNaN()){
logger.info("CPU: Quartile2 Utilization is NaN, will be set to 0.");
statistic.setQuartile2(0d);
} else {
statistic.setQuartile2(percentile.get(Constants.QUARTILE2));
}
resources.put(Constants.CPU_UTIL, statistic);
// MEM util
percentile = connection.getResourceSimulationUtilPercentile(resourceContainer,
SimulationUtilizationTable.MEM_UTIL.getColumnName(), simulationId, startEventTime, endEventTime);
statistic = new Statistic();
statistic.setMax(percentile.get(Constants.MAX) * 100d);
statistic.setMin(percentile.get(Constants.MIN) * 100d);
statistic.setMean(percentile.get(Constants.MEDIAN) * 100d);
statistic.setQuartile1(percentile.get(Constants.QUARTILE1) * 100d);
statistic.setQuartile2(percentile.get(Constants.QUARTILE2) * 100d);
if(percentile.get(Constants.MAX).isNaN()){
statistic.setMax(0d);
logger.info("MEM: Max Utilization is NaN, will be set to 0.");
} else {
statistic.setMax(percentile.get(Constants.MAX) * 100d);
}
if(percentile.get(Constants.MIN).isNaN()){
statistic.setMin(0d);
logger.info("MEM: Min Utilization is NaN, will be set to 0.");
} else {
statistic.setMin(percentile.get(Constants.MIN) * 100d);
}
if(percentile.get(Constants.MEDIAN).isNaN()){
statistic.setMean(0d);
logger.info("MEM: Mean Utilization is NaN, will be set to 0.");
} else {
statistic.setMean(percentile.get(Constants.MEDIAN) * 100d);
}
if(percentile.get(Constants.QUARTILE1).isNaN()){
statistic.setQuartile1(0d);
logger.info("MEM: Quartile1 Utilization is NaN, will be set to 0.");
} else {
statistic.setQuartile1(percentile.get(Constants.QUARTILE1) * 100d);
}
if(percentile.get(Constants.QUARTILE2).isNaN()){
logger.info("MEM: Quartile2 Utilization is NaN, will be set to 0.");
statistic.setQuartile2(0d);
} else {
statistic.setQuartile2(percentile.get(Constants.QUARTILE2) * 100d);
}
resources.put(Constants.MEM_UTIL, statistic);
// HDD util
......@@ -210,11 +277,42 @@ public class Simulations implements Serializable {
SimulationUtilizationTable.DEMANDED_TIME_HDD.getColumnName(), simulationId, startEventTime,
endEventTime);
statistic = new Statistic();
statistic.setMax(percentile.get(Constants.MAX));
statistic.setMin(percentile.get(Constants.MIN));
statistic.setMean(percentile.get(Constants.MEDIAN));
statistic.setQuartile1(percentile.get(Constants.QUARTILE1));
statistic.setQuartile2(percentile.get(Constants.QUARTILE2));
if(percentile.get(Constants.MAX).isNaN()){
statistic.setMax(0d);
logger.info("HDD: Max Utilization is NaN, will be set to 0.");
} else {
statistic.setMax(percentile.get(Constants.MAX));
}
if(percentile.get(Constants.MIN).isNaN()){
statistic.setMin(0d);
logger.info("HDD: Min Utilization is NaN, will be set to 0.");
} else {
statistic.setMin(percentile.get(Constants.MIN));
}
if(percentile.get(Constants.MEDIAN).isNaN()){
statistic.setMean(0d);
logger.info("HDD: Mean Utilization is NaN, will be set to 0.");
} else {
statistic.setMean(percentile.get(Constants.MEDIAN));
}
if(percentile.get(Constants.QUARTILE1).isNaN()){
statistic.setQuartile1(0d);
logger.info("HDD: Quartile1 Utilization is NaN, will be set to 0.");
} else {
statistic.setQuartile1(percentile.get(Constants.QUARTILE1));
}
if(percentile.get(Constants.QUARTILE2).isNaN()){
logger.info("HDD: Quartile2 Utilization is NaN, will be set to 0.");
statistic.setQuartile2(0d);
} else {
statistic.setQuartile2(percentile.get(Constants.QUARTILE2));
}
resources.put(Constants.HDD_UTIL, statistic);
return resources;
......
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