use of cbit.vcell.server.SimulationJobStatus in project vcell by virtualcell.
the class SimulationDatabaseDirect method buildSimulationStatus.
private SimulationStatus buildSimulationStatus(SimulationStatusPersistent simStatusDB) throws ObjectNotFoundException, DataAccessException {
SimulationStatus simulationStatus = translateToSimulationStatusTransient(simStatusDB);
// replace SimulationJobStatus from cache when possible
ArrayList<SimulationJobStatus> simJobStatusList = new ArrayList<SimulationJobStatus>();
int index = 0;
while (simulationStatus.getJobStatus(index) != null) {
SimulationJobStatus simJobStatusDb = simulationStatus.getJobStatus(index);
SimJobStatusKey key = new SimJobStatusKey(simJobStatusDb.getVCSimulationIdentifier().getSimulationKey(), simJobStatusDb.getJobIndex(), simJobStatusDb.getTaskID());
SimStatusCacheEntry entry = cache.get(key);
if (entry != null) {
// assume cache is more recent
simJobStatusList.add(entry.jobStatus);
} else {
simJobStatusList.add(simJobStatusDb);
cache.put(key, new SimStatusCacheEntry(simJobStatusDb, null));
}
index++;
}
SimulationStatus newSimStatus = new SimulationStatus(simJobStatusList.toArray(new SimulationJobStatus[simJobStatusList.size()]));
return newSimStatus;
}
use of cbit.vcell.server.SimulationJobStatus in project vcell by virtualcell.
the class SimulationDatabaseDirect method translateToSimulationStatusTransient.
private SimulationStatus translateToSimulationStatusTransient(SimulationStatusPersistent simStatusPersistent) {
ArrayList<SimulationJobStatus> simJobStatusList = new ArrayList<SimulationJobStatus>();
if (simStatusPersistent == null) {
}
SimulationJobStatusPersistent[] simStatusPersistentArray = simStatusPersistent.getJobStatuses();
if (simStatusPersistentArray == null) {
}
for (SimulationJobStatusPersistent stat : simStatusPersistentArray) {
simJobStatusList.add(translateToSimulationJobStatusTransient(stat));
}
SimulationStatus simStatus = new SimulationStatus(simJobStatusList.toArray(new SimulationJobStatus[0]));
return simStatus;
}
use of cbit.vcell.server.SimulationJobStatus in project vcell by virtualcell.
the class SimulationDatabaseDirect method getSimulationJobStatus.
SimulationJobStatus getSimulationJobStatus(KeyValue simKey, int jobIndex, int taskID) throws DataAccessException, SQLException {
SimJobStatusKey key = new SimJobStatusKey(simKey, jobIndex, taskID);
SimStatusCacheEntry simStatusCacheEntry = cache.get(key);
if (simStatusCacheEntry != null) {
return simStatusCacheEntry.jobStatus;
} else {
SimulationJobStatusPersistent simJobStatusPersistent = adminDbTopLevel.getSimulationJobStatus(simKey, jobIndex, taskID, true);
SimulationJobStatus simulationJobStatus = translateToSimulationJobStatusTransient(simJobStatusPersistent);
cache.put(key, new SimStatusCacheEntry(simulationJobStatus, null));
return simulationJobStatus;
}
}
use of cbit.vcell.server.SimulationJobStatus 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.server.SimulationJobStatus in project vcell by virtualcell.
the class SimulationControllerImpl method onClientStatusTopic_SimulationJobStatus.
private void onClientStatusTopic_SimulationJobStatus(VCMessage simJobStatusMessage) {
Double progress = null;
if (simJobStatusMessage.propertyExists(MessageConstants.SIMULATION_STATUS_PROGRESS_PROPERTY)) {
progress = simJobStatusMessage.getDoubleProperty(MessageConstants.SIMULATION_STATUS_PROGRESS_PROPERTY);
}
Double timepoint = null;
if (simJobStatusMessage.propertyExists(MessageConstants.SIMULATION_STATUS_TIMEPOINT_PROPERTY)) {
timepoint = simJobStatusMessage.getDoubleProperty(MessageConstants.SIMULATION_STATUS_TIMEPOINT_PROPERTY);
}
SimulationJobStatus simJobStatus = (SimulationJobStatus) simJobStatusMessage.getObjectContent();
SimulationJobStatusEvent simulationJobStatusEvent = new SimulationJobStatusEvent(SimulationControllerImpl.this, simJobStatus.getVCSimulationIdentifier().getID(), simJobStatus, progress, timepoint, simJobStatus.getVCSimulationIdentifier().getOwner().getName());
fireSimulationJobStatusEvent(simulationJobStatusEvent);
}
Aggregations