use of cbit.vcell.solvers.HTCSolver in project vcell by virtualcell.
the class SolverPreprocessor method main.
public static void main(java.lang.String[] args) {
if (args.length < 2) {
System.out.print(SolverPreprocessor.class.getName() + " ");
System.out.println(Arrays.toString(args));
System.out.println("Missing arguments: " + SolverPreprocessor.class.getName() + " [simulationTaskFile] [userdir] <parallel dir> ");
System.exit(1);
}
File parallelDirectory = null;
if (args.length >= 3) {
parallelDirectory = new File(args[2]);
if (!parallelDirectory.exists()) {
parallelDirectory.mkdirs();
}
if (!parallelDirectory.isDirectory() || !parallelDirectory.canWrite()) {
throw new IllegalArgumentException(parallelDirectory.getAbsolutePath() + " is not a writeable directory");
}
}
Logging.init();
try {
PropertyLoader.loadProperties();
//
File simulationFile = new File(args[0]);
final SimulationTask simTask = XmlHelper.XMLToSimTask(FileUtils.readFileToString(simulationFile));
if (parallelDirectory != null) {
// simulation task needs to be written to the "parallel directory" (a temporary directory) here (it is local to the cluster).
FileUtils.copyFile(simulationFile, new File(parallelDirectory, simulationFile.getName()));
}
File userDirectory = new File(args[1]);
final String hostName = null;
VCMongoMessage.serviceStartup(ServiceName.solverPreprocessor, Integer.valueOf(simTask.getSimKey().toString()), args);
//
// JMX registration
//
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean(new VCellServiceMXBeanImpl(), new ObjectName(VCellServiceMXBean.jmxObjectName));
final HTCSolver htcSolver = new HTCSolver(simTask, userDirectory, parallelDirectory) {
public void startSolver() {
try {
super.initialize();
} catch (Exception e) {
e.printStackTrace();
SimulationMessage simMessage = SimulationMessage.jobFailed(e.getMessage());
try {
sendFailureAndExit(this, simTask, hostName, simMessage);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
public void stopSolver() {
}
public double getCurrentTime() {
return 0;
}
public double getProgress() {
return 0;
}
};
SolverListener solverListener = new SolverListener() {
public void solverStopped(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
try {
sendFailureAndExit(htcSolver, simTask, hostName, event.getSimulationMessage());
} catch (Exception e) {
e.printStackTrace();
}
}
public void solverStarting(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
}
public void solverProgress(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
}
public void solverPrinted(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
}
public void solverFinished(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
}
public void solverAborted(SolverEvent event) {
VCMongoMessage.sendSolverEvent(event);
try {
sendFailureAndExit(htcSolver, simTask, hostName, event.getSimulationMessage());
} catch (VCMessagingException e) {
e.printStackTrace();
}
}
};
htcSolver.addSolverListener(solverListener);
htcSolver.startSolver();
VCMongoMessage.sendInfo("preprocessor done");
exitWithCode(0);
} catch (Throwable e) {
lg.error(e.getMessage(), e);
exitWithCode(-1);
}
}
Aggregations