use of cbit.rmi.event.WorkerEvent in project vcell by virtualcell.
the class LocalSolverController method solverFinished.
/**
* Invoked when the solver finishes a calculation (normal termination).
* @param event indicates the solver and the event type
*/
public void solverFinished(SolverEvent event) {
try {
if (lg.isTraceEnabled())
lg.trace("LocalSolverController Caught solverFinished(" + event.getSource().toString() + ")");
SimulationJob simJob = getSimulationTask().getSimulationJob();
if (serialParameterScanJobIndex >= 0) {
SimulationTask newSimTask = new SimulationTask(new SimulationJob(simJob.getSimulation(), serialParameterScanJobIndex, simJob.getFieldDataIdentifierSpecs()), getSimulationTask().getTaskID());
fireWorkerEvent(new WorkerEvent(WorkerEvent.JOB_COMPLETED, this, newSimTask, hostname, new Double(event.getProgress()), new Double(event.getTimePoint()), event.getSimulationMessage()));
} else {
fireWorkerEvent(new WorkerEvent(WorkerEvent.JOB_COMPLETED, this, getSimulationTask(), hostname, new Double(event.getProgress()), new Double(event.getTimePoint()), event.getSimulationMessage()));
}
} catch (Throwable e) {
lg.error(e.getMessage(), e);
}
}
use of cbit.rmi.event.WorkerEvent in project vcell by virtualcell.
the class RestEventService method newEventMessage.
private void newEventMessage(MessageEvent event) {
System.out.println(getClass().getName() + ".newEventMessage(" + event.getClass().getSimpleName() + ": " + event);
if (event instanceof ExportEvent) {
ExportEvent exportEvent = (ExportEvent) event;
try {
ExportEventRepresentation exportEventRep = exportEvent.toJsonRep();
ExportEvent event2 = ExportEvent.fromJsonRep(this, exportEventRep);
if (!Compare.isEqual(event2.getFormat(), exportEvent.getFormat())) {
throw new RuntimeException("Export event round-trip failed");
}
if (!Compare.isEqual(event2.getJobID(), exportEvent.getJobID())) {
throw new RuntimeException("Export event round-trip failed");
}
Gson gson = new Gson();
String eventJSON = gson.toJson(exportEventRep);
insert(exportEventRep.username, EventType.ExportEvent, eventJSON);
} catch (Exception e) {
e.printStackTrace();
}
} else if (event instanceof SimulationJobStatusEvent) {
SimulationJobStatusEvent simJobEvent = (SimulationJobStatusEvent) event;
try {
SimulationJobStatusEventRepresentation simJobEventRep = simJobEvent.toJsonRep();
SimulationJobStatusEvent event2 = SimulationJobStatusEvent.fromJsonRep(this, simJobEventRep);
if (!Compare.isEqual(event2.getJobStatus(), simJobEvent.getJobStatus())) {
throw new RuntimeException("SimulationJobStatus event round-trip failed");
}
if (!Compare.isEqual(event2.getProgress(), simJobEvent.getProgress())) {
throw new RuntimeException("SimulationJobStatus <PROGRESS> event round-trip failed");
}
Gson gson = new Gson();
String eventJSON = gson.toJson(simJobEventRep);
insert(simJobEventRep.username, EventType.SimJob, eventJSON);
} catch (Exception e) {
e.printStackTrace();
}
} else if (event instanceof VCellMessageEvent) {
VCellMessageEvent vcellMessageEvent = (VCellMessageEvent) event;
lg.error("event of type VCellMessageEvent not supported");
} else if (event instanceof WorkerEvent) {
lg.error("event of type WorkerEvent not supported");
WorkerEvent workerEvent = (WorkerEvent) event;
} else if (event instanceof PerformanceMonitorEvent) {
lg.error("event of type PerformanceMonitorEvent not supported");
PerformanceMonitorEvent performanceMonitorEvent = (PerformanceMonitorEvent) event;
} else if (event instanceof DataJobEvent) {
lg.error("event of type DataJobEvent not supported");
DataJobEvent dataJobEvent = (DataJobEvent) event;
try {
DataJobEventRepresentation dataJobEventRep = dataJobEvent.toJsonRep();
DataJobEvent event2 = DataJobEvent.fromJsonRep(this, dataJobEventRep);
if (!Compare.isEqual(event2.getDataIdString(), dataJobEvent.getDataIdString())) {
throw new RuntimeException("DataJob event round-trip failed");
}
if (!Compare.isEqual(event2.getProgress(), dataJobEvent.getProgress())) {
throw new RuntimeException("DataJob <PROGRESS> event round-trip failed");
}
Gson gson = new Gson();
String eventJSON = gson.toJson(dataJobEventRep);
insert(dataJobEventRep.username, EventType.DataJob, eventJSON);
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of cbit.rmi.event.WorkerEvent in project vcell by virtualcell.
the class SimulationDispatcher method onWorkerEventMessage.
/**
* @param vcMessage
* @param session
*/
private void onWorkerEventMessage(VCMessage vcMessage, VCMessageSession session) {
try {
//
if (vcMessage.propertyExists(VCMessagingConstants.MESSAGE_TYPE_PROPERTY) && vcMessage.getStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY).equals(MessageConstants.MESSAGE_TYPE_FLUSH_VALUE)) {
if (simMonitor != null) {
try {
synchronized (simMonitor.notifyObject) {
simMonitor.notifyObject.notify();
}
} catch (IllegalMonitorStateException e) {
e.printStackTrace();
}
}
return;
}
WorkerEventMessage.UserResolver userResolver = new WorkerEventMessage.UserResolver() {
@Override
public User getUser(String username) {
try {
return simulationDatabase.getUser(username);
} catch (SQLException | DataAccessException e) {
throw new RuntimeException("cannot resolve user from userid " + username, e);
}
}
};
WorkerEventMessage workerEventMessage = new WorkerEventMessage(userResolver, vcMessage);
WorkerEvent workerEvent = workerEventMessage.getWorkerEvent();
simDispatcherEngine.onWorkerEvent(workerEvent, simulationDatabase, session);
} catch (Exception ex) {
lg.error(ex.getMessage(), ex);
}
}
use of cbit.rmi.event.WorkerEvent in project vcell by virtualcell.
the class LocalSolverController method solverAborted.
/**
* Invoked when the solver aborts a calculation (abnormal termination).
* @param event indicates the solver and the event type
*/
public void solverAborted(SolverEvent event) {
try {
if (lg.isTraceEnabled())
lg.trace("LocalSolverController Caught solverAborted(" + event.getSource().toString() + ",error='" + event.getSimulationMessage() + "')");
SimulationJob simJob = getSimulationTask().getSimulationJob();
if (serialParameterScanJobIndex >= 0) {
SimulationTask newSimTask = new SimulationTask(new SimulationJob(simJob.getSimulation(), serialParameterScanJobIndex, simJob.getFieldDataIdentifierSpecs()), getSimulationTask().getTaskID());
fireWorkerEvent(new WorkerEvent(WorkerEvent.JOB_FAILURE, this, newSimTask, hostname, event.getSimulationMessage()));
} else {
fireWorkerEvent(new WorkerEvent(WorkerEvent.JOB_FAILURE, this, getSimulationTask(), hostname, event.getSimulationMessage()));
}
} catch (Throwable e) {
lg.error(e.getMessage(), e);
}
}
use of cbit.rmi.event.WorkerEvent in project vcell by virtualcell.
the class VCMongoMessage method addObject.
private static void addObject(Document dbObject, WorkerEventMessage workerEventMessage) {
WorkerEvent workerEvent = workerEventMessage.getWorkerEvent();
dbObject.put(MongoMessage_computeHost, workerEvent.getHostName());
dbObject.put(MongoMessage_simId, workerEvent.getVCSimulationDataIdentifier().getSimulationKey().toString());
dbObject.put(MongoMessage_jobIndex, workerEvent.getJobIndex());
dbObject.put(MongoMessage_taskId, workerEvent.getTaskID());
// workerEvent.getEventTypeID();
// workerEvent.getMessageData();
// workerEvent.getMessageSource();
addObject(dbObject, workerEvent.getSimulationMessage());
dbObject.put(MongoMessage_simProgress, workerEvent.getProgress());
dbObject.put(MongoMessage_simTime, workerEvent.getTimePoint());
}
Aggregations