int scale = -1;
if (reloadDB || reloadMedia) {
scale = Integer.parseInt(params.getParameter("dbServer/scale"));
}
CommandHandle dbHandle = null;
CommandHandle mediaHandle = null;
if (reloadDB) {
// We need to restart the appservers
boolean restartApp = Boolean.parseBoolean(
params.getParameter("webServer/fh:service/fh:restart"));
if (!restartApp)
params.setParameter("webServer/fh:service/fh:restart", "true");
logger.info("Reloading the database for " + scale + " users!");
String dbhost = dbhosts[0];
String driver = params.getParameter("dbServer/dbDriver");
String connectURL = params.getParameter("dbServer/connectURL");
// Un-escape the URL.
connectURL = connectURL.replace("&", "&");
ArrayList<String> cmdList = new ArrayList<String>();
cmdList.add("-Dcommit.tx=false");
cmdList.add("org.apache.olio.workload.loader.LoadController");
cmdList.add(driver);
cmdList.add(connectURL);
cmdList.add(String.valueOf(scale));
Command c = new Command(cmdList);
c.setSynchronous(false);
dbHandle = java(dbhost, c);
}
if (reloadMedia) {
logger.info("Reloading images/media for " + scale + " users!");
String mediaHost = params.getParameter(
"dataStorage/fa:hostConfig/fa:host");
String mediaDir = params.getParameter("dataStorage/mediaDir");
Command c = new Command("org.apache.olio.workload.fsloader.FileLoader",
getBenchmarkDir() + "resources", mediaDir,
String.valueOf(scale));
c.setSynchronous(false);
mediaHandle = java(mediaHost, c);
}
if (dbHandle != null) {
dbHandle.waitFor();
int exitValue = dbHandle.exitValue();
if (exitValue != 0) {
throw (new Exception("DB load error, exited with value " + exitValue));
}
}
if (mediaHandle != null) {
mediaHandle.waitFor();
int exitValue = mediaHandle.exitValue();
if (exitValue != 0) {
throw (new Exception("File load error, exited with value " + exitValue));
}
}