// Go back and check if still suspended or got killed.
continue;
}
}
Run run = null;
String runId = null;
// Poll other hosts in poller mode. Otherwise skip this block.
if (Config.daemonMode == Config.DaemonModes.POLLER) {
NameValuePair<Long> nextLocal = nextRunAge(Long.MIN_VALUE);
long runAge = -1;
if (nextLocal != null) {
runId = nextLocal.name;
runAge = nextLocal.value;
}
File tmpRunDir = null;
while ((tmpRunDir = RunRetriever.pollRun(runAge)) != null)
try {
run = fetchRemoteRun(tmpRunDir);
if (run == null)
logger.warning("Fetched null remote run");
break;
} catch (RunEntryException e) {
continue; // If we got a bad run, try polling again
}
if (run == null && nextLocal == null) {
// No local run or remote run...
runqLock.waitForSignal(10000);
continue;
}
}
boolean remoteRun = true;
if (run == null)
try {
try {
// runId null if not poller.
run = fetchNextRun(runId);
} catch (IOException ex) {
Logger.getLogger(RunDaemon.class.getName()).log(
Level.SEVERE,
"IOException fetching remote run.", ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(RunDaemon.class.getName()).log(
Level.SEVERE, "ClassNotFoundException " +
"fetching remote run.", ex);
}
remoteRun = false;
} catch (RunEntryException e) {
// If there is a run entry issue, just skip to the next
// run immediately.
continue;
}
if (run == null) {
runqLock.waitForSignal(10000);
continue;
}
String benchName = run.getBenchmarkName();
String runDir = run.getOutDir();
// Redirect the log to runOutDir/log.xml
String logFile = runDir + File.separator + Config.LOG_FILE;
redirectLog(logFile, null);
logger.info("Starting " + benchName + " run using " + runDir);
// instantiate, start running the benchmark
currRun = run;
gb = new GenericBenchmark(currRun);
gb.start();
// We could have done the uploads in GenericBenchmark.
// But we fetched the remote run here, so we should return it
// here, too!
if (remoteRun)
try {
RunUploader.uploadIfOrigin(run.getRunId());
} catch (IOException e) {
logger.log(Level.WARNING, "Run upload failed!", e);
}
logger.info(benchName + " Completed/Terminated");