From 0edad911dd96c71bdd2ae15dbb2e546bba04e786 Mon Sep 17 00:00:00 2001 From: Stefan Derkits Date: Tue, 14 May 2013 21:56:25 +0200 Subject: [PATCH] first draft of finished JobGenerator (pls test :) ) --- src/at/ac/tuwien/lsdc/JobGenerator.java | 30 +++++++++++++++++++------ 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/at/ac/tuwien/lsdc/JobGenerator.java b/src/at/ac/tuwien/lsdc/JobGenerator.java index 39d8812..9c35d96 100644 --- a/src/at/ac/tuwien/lsdc/JobGenerator.java +++ b/src/at/ac/tuwien/lsdc/JobGenerator.java @@ -44,8 +44,8 @@ public class JobGenerator { CSVWriter.NO_QUOTE_CHARACTER); writeCSVHeader(); int timestamp = 1; - for (int i = 0; i < count;i++) { - timestamp = timestamp + calculateNextTimestamp(); + for (int i = 0; i < count; i++) { + timestamp = timestamp + randomInt(1, 10); switch (scenario) { case A: generateWBA(timestamp); @@ -98,19 +98,27 @@ public class JobGenerator { writer.writeNext(header); } - private static int calculateNextTimestamp() { - // TODO: insert more random logic here ;) - return 1; + private static int randomInt(int low, int high) { + Random r = new Random(); + return (r.nextInt(high - low) + low); } private static void generateWBA(int timestamp) { - //TODO: generate Application & write to CSV + int size = randomInt(20, 100); + int ram = randomInt(30, 50); + int cpu = randomInt(50, 100); + int duration = randomInt(1, 50); numWBA++; + writeApplication(timestamp,size,ram,cpu,duration); } private static void generateHPA(int timestamp) { - //TODO: generate Application & write to CSV + int size = randomInt(150, 500); + int ram = randomInt(100, 400); + int cpu = randomInt(100, 700); + int duration = randomInt(1, 50); numHPA++; + writeApplication(timestamp,size,ram,cpu,duration); } private static void generateWBAorHPA(int timestamp) { @@ -122,4 +130,12 @@ public class JobGenerator { generateHPA(timestamp); } } + + private static void writeApplication(int timestamp, int size, int ram, + int cpu, int duration) { + String[] app = new String[] { String.valueOf(timestamp), + String.valueOf(size), String.valueOf(ram), String.valueOf(cpu), + String.valueOf(duration) }; + writer.writeNext(app); + } } -- 2.43.0