1 package at.ac.tuwien.lsdc.util;
4 import java.io.FileWriter;
5 import java.io.IOException;
7 import at.ac.tuwien.lsdc.types.ScenarioData;
8 import at.ac.tuwien.lsdc.types.SchedulerData;
9 import au.com.bytecode.opencsv.CSVWriter;
11 public class CSVLogger {
13 private CSVWriter writer;
15 boolean scenarioHeaderExists;
16 boolean schedulerHeaderExists;
18 public CSVLogger(File file) throws IOException {
20 this.writer = new CSVWriter(new FileWriter(file), ';',
21 CSVWriter.NO_QUOTE_CHARACTER);
22 this.scenarioHeaderExists = false;
23 this.schedulerHeaderExists = false;
26 public void logScenarioData(ScenarioData data)
28 if (!scenarioHeaderExists) {
29 writeScenarioDataHeader();
30 scenarioHeaderExists = true;
32 writer.writeNext(data.toStringArray());
35 public void logSchedulerData(SchedulerData data)
37 if (!schedulerHeaderExists) {
38 writeSchedulerDataHeader();
39 schedulerHeaderExists = true;
41 writer.writeNext(data.toStringArray());
44 private void writeScenarioDataHeader() throws IOException {
45 String[] header = new String[] { "Scheduler", "Scenario", "TotalPMs",
46 "TotalVMs", "TotalDuration", "TotalPowerConsumption",
47 "TotalInSourced", "TotalOutSourced" };
48 writer.writeNext(header);
51 private void writeSchedulerDataHeader() throws IOException {
52 String[] header = new String[] { "Timestamp", "TotalRAM", "TotalCPU",
53 "TotalSize", "RunningPMs", "RunningVMs",
54 "TotalPowerConsumption", "InSourced", "OutSourced" };
55 writer.writeNext(header);
58 public void close() throws IOException {