use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class SimulationControllerImpl method stopSimulation.
/**
* This method was created by a SmartGuide.
* @throws JMSException
* @throws AuthenticationException
* @throws DataAccessException
* @throws SQLException
* @throws FileNotFoundException
* @exception java.rmi.RemoteException The exception description.
* @throws VCMessagingException
*/
public void stopSimulation(Simulation simulation) throws FileNotFoundException, SQLException, DataAccessException, AuthenticationException, JMSException, VCMessagingException {
LocalVCMessageListener localVCMessageListener = new LocalVCMessageListener() {
public void onLocalVCMessage(VCDestination destination, VCMessage objectMessage) {
String messageTypeProperty = VCMessagingConstants.MESSAGE_TYPE_PROPERTY;
String stopSimulationValue = MessageConstants.MESSAGE_TYPE_STOPSIMULATION_VALUE;
if (destination == VCellTopic.ClientStatusTopic && objectMessage.getObjectContent() instanceof SimulationJobStatus) {
onClientStatusTopic_SimulationJobStatus(objectMessage);
} else if (destination == VCellTopic.ServiceControlTopic && objectMessage.getStringProperty(messageTypeProperty).equals(stopSimulationValue)) {
onServiceControlTopic_StopSimulation(objectMessage);
} else {
throw new RuntimeException("SimulationControllerImpl.startSimulation().objectMessageListener:: expecting message with SimulationJobStatus to topic " + VCellTopic.ClientStatusTopic.getName() + ": received \"" + objectMessage.show() + "\" on destination \"" + destination + "\"");
}
}
};
LocalVCMessageAdapter vcMessageSession = new LocalVCMessageAdapter(localVCMessageListener);
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simulation.getKey(), simulation.getVersion().getOwner());
simulationDispatcherEngine.onStopRequest(vcSimID, localVCellConnection.getUserLoginInfo().getUser(), simulationDatabase, vcMessageSession);
vcMessageSession.deliverAll();
}
use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class SimulationControllerImpl method onSimJobQueue_SimulationTask.
private void onSimJobQueue_SimulationTask(VCMessage vcMessage) {
SimulationTask simTask = null;
try {
SimulationTaskMessage simTaskMessage = new SimulationTaskMessage(vcMessage);
simTask = simTaskMessage.getSimulationTask();
LocalSolverController solverController = getOrCreateSolverController(simTask);
// can only start after updating the database is done
solverController.startSimulationJob();
} catch (Exception e) {
lg.error(e.getMessage(), e);
KeyValue simKey = simTask.getSimKey();
VCSimulationIdentifier vcSimID = simTask.getSimulationJob().getVCDataIdentifier().getVcSimID();
int jobIndex = simTask.getSimulationJob().getJobIndex();
int taskID = simTask.getTaskID();
SimulationJobStatus newJobStatus = new SimulationJobStatus(VCellServerID.getSystemServerID(), vcSimID, jobIndex, null, SchedulerStatus.FAILED, taskID, SimulationMessage.jobFailed(e.getMessage()), null, null);
SimulationJobStatusEvent event = new SimulationJobStatusEvent(this, Simulation.createSimulationID(simKey), newJobStatus, null, null, vcSimID.getOwner().getName());
fireSimulationJobStatusEvent(event);
}
}
use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class SimulationControllerImpl method startSimulation.
/**
* This method was created by a SmartGuide.
* @exception java.rmi.RemoteException The exception description.
*/
public void startSimulation(Simulation simulation) throws Exception {
LocalVCMessageListener localVCMessageListener = new LocalVCMessageListener() {
public void onLocalVCMessage(VCDestination destination, VCMessage vcMessage) {
if (destination == VCellTopic.ClientStatusTopic && vcMessage.getObjectContent() instanceof SimulationJobStatus) {
onClientStatusTopic_SimulationJobStatus(vcMessage);
} else if (destination == VCellQueue.SimJobQueue && vcMessage.getStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY).equals(MessageConstants.MESSAGE_TYPE_SIMULATION_JOB_VALUE)) {
onSimJobQueue_SimulationTask(vcMessage);
} else {
throw new RuntimeException("SimulationControllerImpl.startSimulation().objectMessageListener:: expecting object message with SimulationJobStatus to topic " + VCellTopic.ClientStatusTopic.getName() + ": received \"" + vcMessage.show() + "\"");
}
}
};
LocalVCMessageAdapter vcMessageSession = new LocalVCMessageAdapter(localVCMessageListener);
removeSimulationJobStatusListener(localVCellConnection.getMessageCollector());
addSimulationJobStatusListener(localVCellConnection.getMessageCollector());
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simulation.getKey(), simulation.getVersion().getOwner());
simulationDispatcherEngine.onStartRequest(vcSimID, localVCellConnection.getUserLoginInfo().getUser(), simulation.getScanCount(), simulationDatabase, vcMessageSession, vcMessageSession);
vcMessageSession.deliverAll();
for (int jobIndex = 0; jobIndex < simulation.getScanCount(); jobIndex++) {
SimulationJobStatus latestSimJobStatus = simulationDatabase.getLatestSimulationJobStatus(simulation.getKey(), jobIndex);
simulationDispatcherEngine.onDispatch(simulation, latestSimJobStatus, simulationDatabase, vcMessageSession);
vcMessageSession.deliverAll();
}
}
use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class SimulationDatabaseDirect method translateToSimulationJobStatusTransient.
private SimulationJobStatus translateToSimulationJobStatusTransient(SimulationJobStatusPersistent simJobStatus) {
VCellServerID serverID = simJobStatus.getServerID();
VCSimulationIdentifier vcSimID = simJobStatus.getVCSimulationIdentifier();
int jobIndex = simJobStatus.getJobIndex();
Date submitDate = simJobStatus.getSubmitDate();
SchedulerStatus schedulerStatus = SimulationJobStatus.SchedulerStatus.valueOf(simJobStatus.getSchedulerStatus().name());
int taskID = simJobStatus.getTaskID();
SimulationMessage simMessage = SimulationMessage.fromSerializedMessage(simJobStatus.getSimulationMessage().toSerialization());
Date queueDate = simJobStatus.getSimulationQueueEntryStatus().getQueueDate();
int queuePriority = simJobStatus.getSimulationQueueEntryStatus().getQueuePriority();
SimulationQueueID queueId = SimulationJobStatus.SimulationQueueID.valueOf(simJobStatus.getSimulationQueueEntryStatus().getQueueID().name());
SimulationQueueEntryStatus simQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, queueId);
SimulationExecutionStatus simExecStatus = new SimulationExecutionStatus(simJobStatus.getSimulationExecutionStatus().getStartDate(), simJobStatus.getSimulationExecutionStatus().getComputeHost(), simJobStatus.getSimulationExecutionStatus().getLatestUpdateDate(), simJobStatus.getSimulationExecutionStatus().getEndDate(), simJobStatus.getSimulationExecutionStatus().hasData(), simJobStatus.getSimulationExecutionStatus().getHtcJobID());
SimulationJobStatus simJobStatusTransient = new SimulationJobStatus(serverID, vcSimID, jobIndex, submitDate, schedulerStatus, taskID, simMessage, simQueueStatus, simExecStatus);
return simJobStatusTransient;
}
use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.
the class SolverPostprocessor method main.
public static void main(java.lang.String[] args) {
if (args.length < NUM_STD_ARGS) {
System.out.println("Usage: " + SolverPostprocessor.class.getName() + " simKey username userKey jobindex taskid solverExitCode [postProcessorCommandFile]");
System.exit(1);
}
Logging.init();
Log4jSessionLog log = new Log4jSessionLog(LOG_NAME);
Logger lg = log.getLogger();
VCMessagingService vcMessagingService = null;
try {
PropertyLoader.loadProperties(POST_PROCESSOR_PROPERTIES);
ResourceUtil.setNativeLibraryDirectory();
NativeLoader.setOsType(OsType.LINUX);
KeyValue simKey = new KeyValue(args[0]);
String userName = args[1];
KeyValue userKey = new KeyValue(args[2]);
int jobIndex = Integer.parseInt(args[3]);
int taskID = Integer.parseInt(args[4]);
int solverExitCode = Integer.parseInt(args[5]);
User owner = new User(userName, userKey);
VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, owner);
String hostName = ManageUtils.getHostName();
VCMongoMessage.serviceStartup(ServiceName.solverPostprocessor, Integer.valueOf(simKey.toString()), args);
//
// JMX registration
//
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean(new VCellServiceMXBeanImpl(), new ObjectName(VCellServiceMXBean.jmxObjectName));
vcMessagingService = VCellServiceHelper.getInstance().loadService(VCMessagingService.class);
vcMessagingService.setDelegate(new ServerMessagingDelegate());
VCMessageSession session = vcMessagingService.createProducerSession();
WorkerEventMessage workerEventMessage;
if (solverExitCode == 0) {
Exception postProcessingException = null;
if (args.length > NUM_STD_ARGS) {
String fname = args[NUM_STD_ARGS];
if (lg.isDebugEnabled()) {
lg.debug("processing " + fname);
}
postProcessingException = runPostprocessingCommands(fname, lg);
}
if (lg.isDebugEnabled()) {
lg.debug("postProcessingException is " + postProcessingException);
}
if (postProcessingException == null) {
lg.debug("sendWorkerExitNormal");
workerEventMessage = WorkerEventMessage.sendWorkerExitNormal(session, SolverPostprocessor.class.getName(), hostName, vcSimID, jobIndex, taskID, solverExitCode);
} else {
lg.debug("sendWorkerExitError postprocessing");
workerEventMessage = WorkerEventMessage.sendWorkerExitError(session, postProcessingException, hostName, vcSimID, jobIndex, taskID, SimulationMessage.WorkerExited(postProcessingException));
}
} else {
// solverExitCode != 0
lg.debug("sendWorkerExitError solverExitCode");
workerEventMessage = WorkerEventMessage.sendWorkerExitError(session, SolverPostprocessor.class.getName(), hostName, vcSimID, jobIndex, taskID, solverExitCode);
}
lg.debug(workerEventMessage);
VCMongoMessage.sendWorkerEvent(workerEventMessage);
} catch (Throwable e) {
log.exception(e);
} finally {
if (vcMessagingService != null) {
try {
vcMessagingService.close();
} catch (VCMessagingException e) {
e.printStackTrace();
}
}
ApplicationTerminator.beginCountdown(TimeUnit.SECONDS, 10, 0);
VCMongoMessage.shutdown();
System.exit(0);
}
}
Aggregations