Refactoring
authorAndreas Egger <egger.andreas.1@gmail.com>
Tue, 21 May 2013 07:59:35 +0000 (09:59 +0200)
committerAndreas Egger <egger.andreas.1@gmail.com>
Tue, 21 May 2013 07:59:35 +0000 (09:59 +0200)
build.xml
src/at/ac/tuwien/lsdc/SchedSimulator.java

index 0d2484a2d022e687f96eca8351498f99de0dedd0..f32caf6cc56397d241cd334d2ba29af7e03abafb 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -27,7 +27,7 @@
                <javac srcdir="${src.dir}" destdir="${build.dir}" classpathref="project.classpath" debug="true" deprecation="true" includeantruntime="false" />\r
        </target>\r
 \r
-       <target name="run-generator-A" depends="compile" description="Run Group GUI (JMS).">\r
+       <target name="run-generator-A" depends="compile" description="Compile project">\r
                <java classname="at.ac.tuwien.lsdc.JobGenerator" fork="true" classpathref="project.classpath">\r
                        <assertions refid="project.assertions" />\r
                        <arg value="A" />\r
                </java>\r
        </target>\r
 \r
-       <target name="run-generator" depends="compile, input-runargs" description="Run Group GUI (JMS).">\r
+       <target name="run-generator" depends="compile, input-runargs" description="Run generator with user defined arguments">\r
                <java classname="at.ac.tuwien.lsdc.JobGenerator" fork="true" classpathref="project.classpath">\r
                        <assertions refid="project.assertions" />\r
                        <arg value="${args}" />\r
                </java>\r
        </target>\r
 \r
-       <target name="run-scheduler" depends="compile, input-runargs" description="Run Group GUI (JMS).">\r
+       <target name="run-scheduler" depends="compile, input-runargs" description="Run scheduler with user defined arguments">\r
                <java classname="at.ac.tuwien.lsdc.SchedSimulator" fork="true" classpathref="project.classpath">\r
                        <assertions refid="project.assertions" />\r
                        <arg value="${args}" />\r
                </java>\r
        </target>\r
 \r
-       <target name="run-scheduler-A-A" depends="compile" description="Run Group GUI (JMS).">\r
+       <target name="run-scheduler-A-A" depends="compile" description="Run scheduler A on scenario A">\r
                <java classname="at.ac.tuwien.lsdc.SchedSimulator" fork="true" classpathref="project.classpath">\r
                        <assertions refid="project.assertions" />\r
                        <arg value="A" />\r
@@ -63,7 +63,7 @@
                </java>\r
        </target>\r
 \r
-       <target name="run-scheduler-A-B" depends="compile" description="Run Group GUI (JMS).">\r
+       <target name="run-scheduler-A-B" depends="compile" description="Run scheduler B on scenario A">\r
                <java classname="at.ac.tuwien.lsdc.SchedSimulator" fork="true" classpathref="project.classpath">\r
                        <assertions refid="project.assertions" />\r
                        <arg value="A" />\r
@@ -76,7 +76,7 @@
                </java>\r
        </target>\r
 \r
-       <target name="run-scheduler-A-C" depends="compile" description="Run Group GUI (JMS).">\r
+       <target name="run-scheduler-A-C" depends="compile" description="Run scheduler C on scenario A">\r
                <java classname="at.ac.tuwien.lsdc.SchedSimulator" fork="true" classpathref="project.classpath">\r
                        <assertions refid="project.assertions" />\r
                        <arg value="A" />\r
index 003e6c28858d90bb69dde7544c4e75e70615493f..83256c025a03198a4c5d86b0cb294211f891101e 100644 (file)
@@ -24,7 +24,7 @@ import at.ac.tuwien.lsdc.util.CSVParser;
  */
 public class SchedSimulator {
 
-       private static final String USAGE = "SchedSimulator needs exactly 5 parameters: scenario, scheduler, inputFile, logFilePath, schedulerLogPath";
+       private static final String USAGE = "SchedSimulator needs exactly 7 parameters: scenario, scheduler, numPMS, numCloudPartners, inputFile, generalLogPath, schedulerLogPath";
 
        private static final Logger log = LoggerFactory
                        .getLogger(SchedSimulator.class);
@@ -73,6 +73,8 @@ public class SchedSimulator {
         * Commandline arguments parsed (mandatory):
         * - type of scenario
         * - type of scheduler
+        * - number of available PMs
+        * - number of cloud partners
         * - scenario input file with applications
         * - general output file for all schedulers
         * - specific output file for this scheduler/scenario combination
@@ -84,40 +86,43 @@ public class SchedSimulator {
                String numPMsStr = args[2];
                String numCloudPartnersStr = args[3];
                String inputFileStr = args[4];
-               String schedulerLogStr = args[5];
-               String scenarioLogFileStr = args[6];
+               String generalLogStr = args[5];
+               String schedulerLogStr = args[6];
+
                try {
                        scenario = ScenarioType.valueOf(scenarioStr);
                        schedulerType = SchedulerType.valueOf(schedulerTypeStr);
                        numPMs = Integer.parseInt(numPMsStr);
                        numCloudPartners = Integer.parseInt(numCloudPartnersStr);
                        inputFile = new File(inputFileStr);
+                       
                        if (!inputFile.canRead())
                                throw new IOException("Can not read input file");
-                       generalLog = new File(schedulerLogStr);
-                       boolean  logFileOK = false;
+                       generalLog = new File(generalLogStr);
+                       boolean  generalLogOK = false;
                        if ( generalLog.canWrite() ) {
-                               logFileOK = true;
+                               generalLogOK = true;
                        }
                        else if (!generalLog.exists()) {
                                generalLog.createNewFile();
-                               logFileOK = true;
+                               generalLogOK = true;
                        }
-                       if (!logFileOK)
-                               throw new IOException("Can not write to scheduler log file");
-                       boolean fileWriteOK = false;
-                       schedulerLog = new File(scenarioLogFileStr);
+                       if (!generalLogOK)
+                               throw new IOException("Can not write to general log file");
+                       
+                       boolean schedulerLogOK = false;
+                       schedulerLog = new File(schedulerLogStr);
                        if (schedulerLog.exists()) {
-                               fileWriteOK = schedulerLog.canWrite();
+                               schedulerLogOK = schedulerLog.canWrite();
                                schedulerLog.delete();
                                schedulerLog.createNewFile();
                        } else {
                                schedulerLog.createNewFile();
-                               fileWriteOK = true;
+                               schedulerLogOK = true;
                        }
-                       if (!fileWriteOK)
-                               throw new IOException("Can not write to Scenario Log File "
-                                               + scenarioLogFileStr);
+                       if (!schedulerLogOK)
+                               throw new IOException("Can not write to scheduler log file "
+                                               + schedulerLogStr);
                } catch (Exception e) {
                        e.printStackTrace();
                        log.info(USAGE);