Search in sources :

Example 6 with WorkerEvent

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);
    }
}
Also used : SimulationTask(cbit.vcell.messaging.server.SimulationTask) WorkerEvent(cbit.rmi.event.WorkerEvent) SimulationJob(cbit.vcell.solver.SimulationJob)

Example 7 with WorkerEvent

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();
        }
    }
}
Also used : ExportEventRepresentation(org.vcell.api.common.events.ExportEventRepresentation) ExportEvent(cbit.rmi.event.ExportEvent) SimulationJobStatusEventRepresentation(org.vcell.api.common.events.SimulationJobStatusEventRepresentation) Gson(com.google.gson.Gson) SimulationJobStatusEvent(cbit.rmi.event.SimulationJobStatusEvent) DataJobEvent(cbit.rmi.event.DataJobEvent) DataJobEventRepresentation(org.vcell.api.common.events.DataJobEventRepresentation) WorkerEvent(cbit.rmi.event.WorkerEvent) VCellMessageEvent(cbit.rmi.event.VCellMessageEvent) PerformanceMonitorEvent(cbit.rmi.event.PerformanceMonitorEvent)

Example 8 with WorkerEvent

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);
    }
}
Also used : SQLException(java.sql.SQLException) WorkerEvent(cbit.rmi.event.WorkerEvent) WorkerEventMessage(cbit.vcell.message.messages.WorkerEventMessage) DataAccessException(org.vcell.util.DataAccessException) VCMessagingException(cbit.vcell.message.VCMessagingException) HtcException(cbit.vcell.message.server.htc.HtcException) HtcJobNotFoundException(cbit.vcell.message.server.htc.HtcJobNotFoundException) PermissionException(org.vcell.util.PermissionException) ExecutableException(org.vcell.util.exe.ExecutableException) SQLException(java.sql.SQLException) RollbackException(cbit.vcell.message.RollbackException) DataAccessException(org.vcell.util.DataAccessException)

Example 9 with WorkerEvent

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);
    }
}
Also used : SimulationTask(cbit.vcell.messaging.server.SimulationTask) WorkerEvent(cbit.rmi.event.WorkerEvent) SimulationJob(cbit.vcell.solver.SimulationJob)

Example 10 with WorkerEvent

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());
}
Also used : WorkerEvent(cbit.rmi.event.WorkerEvent)

Aggregations

WorkerEvent (cbit.rmi.event.WorkerEvent)18 SimulationTask (cbit.vcell.messaging.server.SimulationTask)4 SimulationJob (cbit.vcell.solver.SimulationJob)4 DataJobEvent (cbit.rmi.event.DataJobEvent)1 ExportEvent (cbit.rmi.event.ExportEvent)1 PerformanceMonitorEvent (cbit.rmi.event.PerformanceMonitorEvent)1 SimulationJobStatusEvent (cbit.rmi.event.SimulationJobStatusEvent)1 VCellMessageEvent (cbit.rmi.event.VCellMessageEvent)1 RollbackException (cbit.vcell.message.RollbackException)1 VCMessagingException (cbit.vcell.message.VCMessagingException)1 WorkerEventMessage (cbit.vcell.message.messages.WorkerEventMessage)1 HtcException (cbit.vcell.message.server.htc.HtcException)1 HtcJobNotFoundException (cbit.vcell.message.server.htc.HtcJobNotFoundException)1 ServiceName (cbit.vcell.mongodb.VCMongoMessage.ServiceName)1 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)1 SimulationMessage (cbit.vcell.solver.server.SimulationMessage)1 Gson (com.google.gson.Gson)1 SQLException (java.sql.SQLException)1 DataJobEventRepresentation (org.vcell.api.common.events.DataJobEventRepresentation)1 ExportEventRepresentation (org.vcell.api.common.events.ExportEventRepresentation)1