From 800aa14329fe1b202ce474d0cc2adcabdb667889 Mon Sep 17 00:00:00 2001 From: Andreas Egger Date: Sat, 22 Jun 2013 14:33:00 +0200 Subject: [PATCH] Fixed bug in scheduler A --- src/at/ac/tuwien/lsdc/SchedSimulator.java | 2 +- src/at/ac/tuwien/lsdc/types/ScenarioData.java | 24 +++++++++++-------- .../ac/tuwien/lsdc/types/SchedulerData.java | 6 ++++- src/at/ac/tuwien/lsdc/util/NumberUtils.java | 2 -- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/at/ac/tuwien/lsdc/SchedSimulator.java b/src/at/ac/tuwien/lsdc/SchedSimulator.java index cb5ea5b..ee65551 100644 --- a/src/at/ac/tuwien/lsdc/SchedSimulator.java +++ b/src/at/ac/tuwien/lsdc/SchedSimulator.java @@ -102,7 +102,7 @@ public class SchedSimulator { throw new IOException("Can not read input file"); generalLog = new File(generalLogStr); boolean generalLogOK = false; - log.info(String.valueOf(generalLog.length())); + if ( generalLog.canWrite() ) { generalLogOK = true; } diff --git a/src/at/ac/tuwien/lsdc/types/ScenarioData.java b/src/at/ac/tuwien/lsdc/types/ScenarioData.java index 8d3ae02..2078116 100644 --- a/src/at/ac/tuwien/lsdc/types/ScenarioData.java +++ b/src/at/ac/tuwien/lsdc/types/ScenarioData.java @@ -1,6 +1,14 @@ package at.ac.tuwien.lsdc.types; +import java.math.BigDecimal; +import java.text.DecimalFormat; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + public class ScenarioData { + + private static final Logger LOG = LoggerFactory.getLogger(ScenarioData.class); private String scheduler; private String scenario; @@ -32,21 +40,17 @@ public class ScenarioData { long totalVMs, long totalDuration, double totalConsumption, int totalInSourced, int totalOutSourced, int totalResizeCalls, int totalDelayedApps) { - this.scheduler = scheduler; - this.scenario = scenario; - this.totalPMs = totalPMs; - this.totalVMs = totalVMs; - this.totalDuration = totalDuration; - this.totalConsumption = totalConsumption; - this.totalInSourced = totalInSourced; - this.totalOutSourced = totalOutSourced; - this.totalResizeCalls = totalResizeCalls; + + this(scheduler, scenario, totalPMs, totalVMs, totalDuration, totalConsumption, totalInSourced, totalOutSourced, totalResizeCalls); this.totalDelayedApps = totalDelayedApps; } public String[] toStringArray() { +// LOG.info("total Consumption = "+totalConsumption+ ", string: "+String.valueOf(totalConsumption)); + DecimalFormat df = new DecimalFormat("#.##"); + return new String[] { scheduler, scenario, String.valueOf(totalPMs), String.valueOf(totalVMs), - String.valueOf(totalDuration), String.valueOf(totalConsumption), String.valueOf(totalInSourced), + String.valueOf(totalDuration), df.format(totalConsumption), String.valueOf(totalInSourced), String.valueOf(totalOutSourced), String.valueOf(totalResizeCalls), String.valueOf(totalDelayedApps) }; } diff --git a/src/at/ac/tuwien/lsdc/types/SchedulerData.java b/src/at/ac/tuwien/lsdc/types/SchedulerData.java index c62cd58..adf4702 100644 --- a/src/at/ac/tuwien/lsdc/types/SchedulerData.java +++ b/src/at/ac/tuwien/lsdc/types/SchedulerData.java @@ -1,5 +1,7 @@ package at.ac.tuwien.lsdc.types; +import java.text.DecimalFormat; + public class SchedulerData { private long timestamp; @@ -57,10 +59,12 @@ public class SchedulerData { } public String[] toStringArray() { + DecimalFormat df = new DecimalFormat("#.##"); + return new String[] { String.valueOf(timestamp), String.valueOf(totalRAM), String.valueOf(totalCPU), String.valueOf(totalSize), String.valueOf(runningPMs), - String.valueOf(runningVMs), String.valueOf(totalConsumption), + String.valueOf(runningVMs), df.format(totalConsumption), String.valueOf(inSourced), String.valueOf(outSourced), String.valueOf(totalResized), String.valueOf(delayedApps), String.valueOf(started), String.valueOf(stopped)}; diff --git a/src/at/ac/tuwien/lsdc/util/NumberUtils.java b/src/at/ac/tuwien/lsdc/util/NumberUtils.java index c86b2ae..6e47820 100644 --- a/src/at/ac/tuwien/lsdc/util/NumberUtils.java +++ b/src/at/ac/tuwien/lsdc/util/NumberUtils.java @@ -8,8 +8,6 @@ public class NumberUtils { private static final Logger LOG = LoggerFactory.getLogger(NumberUtils.class); public static double roundDouble(double val) { - LOG.info("value = "+val); - return Math.floor(val * 100) / 100; } -- 2.43.0