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;
16 public CSVLogger(File file) throws IOException {
18 this.writer = new CSVWriter(new FileWriter(file), ';',
19 CSVWriter.NO_QUOTE_CHARACTER);
22 public void logScenarioData(ScenarioData data)
24 if (file.length() == 0) {
25 writeScenarioDataHeader();
27 writer.writeNext(data.toStringArray());
30 public void logSchedulerData(SchedulerData data)
32 if (file.length() == 0) {
33 writeSchedulerDataHeader();
35 writer.writeNext(data.toStringArray());
38 private void writeScenarioDataHeader() throws IOException {
39 String[] header = new String[] { "Scheduler", "Scenario", "TotalPMs",
40 "TotalVMs", "TotalDuration", "TotalPowerConsumption",
41 "TotalInSourced", "TotalOutSourced" };
42 writer.writeNext(header);
45 private void writeSchedulerDataHeader() throws IOException {
46 String[] header = new String[] { "Timestamp", "TotalRAM", "TotalCPU",
47 "TotalSize", "RunningPMs", "RunningVMs",
48 "TotalPowerConsumption", "InSourced", "OutSourced" };
49 writer.writeNext(header);
52 public void close() throws IOException {