Search in sources :

Example 1 with SimulationMessage

use of cbit.vcell.solver.server.SimulationMessage in project vcell by virtualcell.

the class AbstractJavaSolver method runSolver.

/**
 * Insert the method's description here.
 * Creation date: (6/26/2001 3:08:31 PM)
 */
public void runSolver() {
    try {
        fieldRunning = true;
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_STARTING, SimulationMessage.MESSAGE_SOLVER_STARTING_INIT));
        fireSolverStarting(SimulationMessage.MESSAGE_SOLVEREVENT_STARTING_INIT);
        initialize();
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_RUNNING, SimulationMessage.MESSAGE_SOLVER_RUNNING_START));
        fireSolverProgress(getProgress());
        integrate();
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_FINISHED, SimulationMessage.MESSAGE_SOLVER_FINISHED));
        fireSolverFinished();
    } catch (SolverException integratorException) {
        lg.error(integratorException.getMessage(), integratorException);
        SimulationMessage simulationMessage = SimulationMessage.solverAborted(integratorException.getMessage());
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, simulationMessage));
        fireSolverAborted(simulationMessage);
    } catch (IOException ioException) {
        lg.error(ioException.getMessage(), ioException);
        SimulationMessage simulationMessage = SimulationMessage.solverAborted(ioException.getMessage());
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, simulationMessage));
        fireSolverAborted(simulationMessage);
    } catch (UserStopException userStopException) {
        lg.error(userStopException.getMessage(), userStopException);
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_STOPPED, SimulationMessage.solverStopped(userStopException.getMessage())));
        fireSolverStopped();
    } catch (Exception e) {
        lg.error("AbstractJavaSolver.runSolver() : Caught Throwable instead of SolverException -- THIS EXCEPTION SHOULD NOT HAPPEN!", e);
        SimulationMessage simulationMessage = SimulationMessage.solverAborted(e.getMessage());
        setSolverStatus(new SolverStatus(SolverStatus.SOLVER_ABORTED, simulationMessage));
        fireSolverAborted(simulationMessage);
    } finally {
        fieldRunning = false;
    }
}
Also used : SimulationMessage(cbit.vcell.solver.server.SimulationMessage) SolverException(cbit.vcell.solver.SolverException) IOException(java.io.IOException) UserStopException(cbit.vcell.solver.UserStopException) SolverStatus(cbit.vcell.solver.server.SolverStatus) UserStopException(cbit.vcell.solver.UserStopException) IOException(java.io.IOException) SolverException(cbit.vcell.solver.SolverException)

Example 2 with SimulationMessage

use of cbit.vcell.solver.server.SimulationMessage 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;
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) SimulationExecutionStatus(cbit.vcell.server.SimulationExecutionStatus) VCellServerID(org.vcell.util.document.VCellServerID) SchedulerStatus(cbit.vcell.server.SimulationJobStatus.SchedulerStatus) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationMessage(cbit.vcell.solver.server.SimulationMessage) SimulationQueueEntryStatus(cbit.vcell.server.SimulationQueueEntryStatus) Date(java.util.Date) SimulationQueueID(cbit.vcell.server.SimulationJobStatus.SimulationQueueID)

Example 3 with SimulationMessage

use of cbit.vcell.solver.server.SimulationMessage in project vcell by virtualcell.

the class SimulationStateMachine method onWorkerEvent.

public synchronized void onWorkerEvent(WorkerEvent workerEvent, SimulationDatabase simulationDatabase, VCMessageSession session) throws DataAccessException, VCMessagingException, SQLException {
    updateSolverProcessTimestamp();
    WorkerEventMessage workerEventMessage = new WorkerEventMessage(workerEvent);
    VCMongoMessage.sendWorkerEvent(workerEventMessage);
    // as the filter of the client
    String userName = workerEvent.getUserName();
    int workerEventTaskID = workerEvent.getTaskID();
    if (lg.isTraceEnabled())
        lg.trace("onWorkerEventMessage[" + workerEvent.getEventTypeID() + "," + workerEvent.getSimulationMessage() + "][simid=" + workerEvent.getVCSimulationDataIdentifier() + ",job=" + jobIndex + ",task=" + workerEventTaskID + "]");
    VCSimulationDataIdentifier vcSimDataID = workerEvent.getVCSimulationDataIdentifier();
    if (vcSimDataID == null) {
        VCMongoMessage.sendInfo("onWorkerEvent() ignoring WorkerEvent - no SimID in message): " + workerEvent.show());
        return;
    }
    KeyValue simKey = vcSimDataID.getSimulationKey();
    SimulationJobStatus oldSimulationJobStatus = simulationDatabase.getLatestSimulationJobStatus(simKey, jobIndex);
    if (oldSimulationJobStatus == null) {
        VCMongoMessage.sendInfo("onWorkerEvent() ignoring WorkerEvent, no current SimulationJobStatus: " + workerEvent.show());
        return;
    }
    if (oldSimulationJobStatus == null || oldSimulationJobStatus.getSchedulerStatus().isDone() || oldSimulationJobStatus.getTaskID() > workerEventTaskID) {
        VCMongoMessage.sendInfo("onWorkerEvent() ignoring outdated WorkerEvent, (currState=" + oldSimulationJobStatus.getSchedulerStatus().getDescription() + "): " + workerEvent.show());
        return;
    }
    int taskID = oldSimulationJobStatus.getTaskID();
    SchedulerStatus oldSchedulerStatus = oldSimulationJobStatus.getSchedulerStatus();
    // 
    // status information (initialized as if new record)
    // 
    Date startDate = null;
    Date lastUpdateDate = null;
    Date endDate = null;
    boolean hasData = false;
    HtcJobID htcJobID = null;
    String computeHost = null;
    VCellServerID vcServerID = VCellServerID.getSystemServerID();
    Date submitDate = null;
    Date queueDate = null;
    int queuePriority = PRIORITY_DEFAULT;
    SimulationJobStatus.SimulationQueueID simQueueID = SimulationJobStatus.SimulationQueueID.QUEUE_ID_WAITING;
    // 
    // update using previously stored status (if available).
    // 
    SimulationExecutionStatus oldSimExeStatus = oldSimulationJobStatus.getSimulationExecutionStatus();
    if (oldSimExeStatus != null && oldSimExeStatus.getStartDate() != null) {
        startDate = oldSimExeStatus.getStartDate();
    }
    if (oldSimExeStatus != null && oldSimExeStatus.getLatestUpdateDate() != null) {
        lastUpdateDate = oldSimExeStatus.getLatestUpdateDate();
    }
    if (oldSimExeStatus != null && oldSimExeStatus.getEndDate() != null) {
        endDate = oldSimExeStatus.getEndDate();
    }
    if (oldSimExeStatus != null && oldSimExeStatus.hasData()) {
        hasData = true;
    }
    if (oldSimExeStatus != null && oldSimExeStatus.getComputeHost() != null) {
        computeHost = oldSimExeStatus.getComputeHost();
    }
    if (oldSimExeStatus != null && oldSimExeStatus.getHtcJobID() != null) {
        htcJobID = oldSimExeStatus.getHtcJobID();
    }
    vcServerID = oldSimulationJobStatus.getServerID();
    submitDate = oldSimulationJobStatus.getSubmitDate();
    SimulationQueueEntryStatus oldQueueStatus = oldSimulationJobStatus.getSimulationQueueEntryStatus();
    if (oldQueueStatus != null && oldQueueStatus.getQueueDate() != null) {
        queueDate = oldQueueStatus.getQueueDate();
    }
    if (oldQueueStatus != null) {
        queuePriority = oldQueueStatus.getQueuePriority();
    }
    if (oldQueueStatus != null && oldQueueStatus.getQueueID() != null) {
        simQueueID = oldQueueStatus.getQueueID();
    }
    // 
    if (workerEvent.getHtcJobID() != null) {
        htcJobID = workerEvent.getHtcJobID();
    }
    if (workerEvent.getHostName() != null) {
        computeHost = workerEvent.getHostName();
    }
    SimulationMessage workerEventSimulationMessage = workerEvent.getSimulationMessage();
    if (workerEventSimulationMessage.getHtcJobId() != null) {
        htcJobID = workerEventSimulationMessage.getHtcJobId();
    }
    SimulationJobStatus newJobStatus = null;
    if (workerEvent.isAcceptedEvent()) {
        // 
        if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued()) {
            // new queue status
            SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
            // new exe status
            lastUpdateDate = new Date();
            startDate = lastUpdateDate;
            endDate = null;
            SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
            newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.DISPATCHED, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
        }
    } else if (workerEvent.isStartingEvent()) {
        // only update database when the job event changes from started to running. The later progress event will not be recorded.
        if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
            // new queue status
            SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
            // new exe status
            lastUpdateDate = new Date();
            if (startDate == null) {
                startDate = lastUpdateDate;
            }
            SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
            newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
        }
    } else if (workerEvent.isNewDataEvent()) {
        if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
            if (!oldSchedulerStatus.isRunning() || simQueueID != SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL || hasData == false) {
                // new queue status
                SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
                // new exe status
                if (startDate == null) {
                    startDate = lastUpdateDate;
                }
                hasData = true;
                SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
                newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
            }
        }
    } else if (workerEvent.isProgressEvent() || workerEvent.isWorkerAliveEvent()) {
        if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
            if (!oldSchedulerStatus.isRunning() || simQueueID != SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL) {
                // new queue status
                SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
                // new exe status
                if (startDate == null) {
                    startDate = lastUpdateDate;
                }
                SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
                newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
            } else if (oldSchedulerStatus.isRunning()) {
                if (oldSimExeStatus != null) {
                    // Date latestUpdate = oldSimExeStatus.getLatestUpdateDate();
                    // if (System.currentTimeMillis() - latestUpdate.getTime() >= MessageConstants.INTERVAL_PING_SERVER_MS * 3 / 5) {
                    // new queue status
                    SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
                    SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
                    newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.RUNNING, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
                }
            // }
            }
        }
    } else if (workerEvent.isCompletedEvent()) {
        if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
            // new queue status
            SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
            // new exe status
            endDate = new Date();
            hasData = true;
            SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
            newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.COMPLETED, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
        }
    } else if (workerEvent.isFailedEvent()) {
        if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
            // new queue status
            SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
            // new exe status
            endDate = new Date();
            SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
            newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.FAILED, taskID, workerEventSimulationMessage, newQueueStatus, newExeStatus);
        }
    } else if (workerEvent.isWorkerExitErrorEvent()) {
        if (oldSchedulerStatus.isWaiting() || oldSchedulerStatus.isQueued() || oldSchedulerStatus.isDispatched() || oldSchedulerStatus.isRunning()) {
            // new queue status
            SimulationQueueEntryStatus newQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationJobStatus.SimulationQueueID.QUEUE_ID_NULL);
            // new exe status
            endDate = new Date();
            SimulationExecutionStatus newExeStatus = new SimulationExecutionStatus(startDate, computeHost, lastUpdateDate, endDate, hasData, htcJobID);
            SimulationMessage simulationMessage = SimulationMessage.workerFailure("solver stopped unexpectedly, " + workerEventSimulationMessage.getDisplayMessage());
            newJobStatus = new SimulationJobStatus(vcServerID, vcSimDataID.getVcSimID(), jobIndex, submitDate, SchedulerStatus.FAILED, taskID, simulationMessage, newQueueStatus, newExeStatus);
        }
    }
    if (newJobStatus != null) {
        if (!newJobStatus.compareEqual(oldSimulationJobStatus) || workerEvent.isProgressEvent() || workerEvent.isNewDataEvent()) {
            Double progress = workerEvent.getProgress();
            Double timepoint = workerEvent.getTimePoint();
            RunningStateInfo runningStateInfo = null;
            if (progress != null && timepoint != null) {
                runningStateInfo = new RunningStateInfo(progress, timepoint);
            }
            simulationDatabase.updateSimulationJobStatus(newJobStatus, runningStateInfo);
            StatusMessage msgForClient = new StatusMessage(newJobStatus, userName, progress, timepoint);
            msgForClient.sendToClient(session);
            if (lg.isTraceEnabled())
                lg.trace("Send status to client: " + msgForClient);
        } else {
            simulationDatabase.updateSimulationJobStatus(newJobStatus);
            StatusMessage msgForClient = new StatusMessage(newJobStatus, userName, null, null);
            msgForClient.sendToClient(session);
            if (lg.isTraceEnabled())
                lg.trace("Send status to client: " + msgForClient);
        }
    } else if (workerEvent.isProgressEvent() || workerEvent.isNewDataEvent()) {
        Double progress = workerEvent.getProgress();
        Double timepoint = workerEvent.getTimePoint();
        RunningStateInfo runningStateInfo = null;
        if (progress != null && timepoint != null) {
            runningStateInfo = new RunningStateInfo(progress, timepoint);
        }
        simulationDatabase.updateSimulationJobStatus(oldSimulationJobStatus, runningStateInfo);
        StatusMessage msgForClient = new StatusMessage(oldSimulationJobStatus, userName, progress, timepoint);
        msgForClient.sendToClient(session);
        if (lg.isTraceEnabled())
            lg.trace("Send status to client: " + msgForClient);
    } else {
        VCMongoMessage.sendInfo("onWorkerEvent() ignoring WorkerEvent (currState=" + oldSchedulerStatus.getDescription() + "): " + workerEvent.show());
    }
// addStateMachineTransition(new StateMachineTransition(new WorkerStateMachineEvent(taskID, workerEvent), oldSimulationJobStatus, newJobStatus));
}
Also used : RunningStateInfo(cbit.vcell.server.RunningStateInfo) SimulationExecutionStatus(cbit.vcell.server.SimulationExecutionStatus) KeyValue(org.vcell.util.document.KeyValue) SchedulerStatus(cbit.vcell.server.SimulationJobStatus.SchedulerStatus) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) SimulationQueueEntryStatus(cbit.vcell.server.SimulationQueueEntryStatus) Date(java.util.Date) StatusMessage(cbit.vcell.message.messages.StatusMessage) VCellServerID(org.vcell.util.document.VCellServerID) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationMessage(cbit.vcell.solver.server.SimulationMessage) WorkerEventMessage(cbit.vcell.message.messages.WorkerEventMessage) HtcJobID(cbit.vcell.server.HtcJobID)

Example 4 with SimulationMessage

use of cbit.vcell.solver.server.SimulationMessage 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);
    }
}
Also used : SimulationTask(cbit.vcell.messaging.server.SimulationTask) VCMessagingException(cbit.vcell.message.VCMessagingException) FileNotFoundException(java.io.FileNotFoundException) ObjectName(javax.management.ObjectName) SolverEvent(cbit.vcell.solver.server.SolverEvent) VCellServiceMXBeanImpl(cbit.vcell.message.server.jmx.VCellServiceMXBeanImpl) SimulationMessage(cbit.vcell.solver.server.SimulationMessage) SolverListener(cbit.vcell.solver.server.SolverListener) VCMessagingException(cbit.vcell.message.VCMessagingException) File(java.io.File) HTCSolver(cbit.vcell.solvers.HTCSolver) MBeanServer(javax.management.MBeanServer)

Example 5 with SimulationMessage

use of cbit.vcell.solver.server.SimulationMessage in project vcell by virtualcell.

the class SimulationJobStatusEvent method fromJsonRep.

public static SimulationJobStatusEvent fromJsonRep(Object eventSource, SimulationJobStatusEventRepresentation eventRep) {
    String simid = Simulation.createSimulationID(new KeyValue(eventRep.jobStatus.simulationKey));
    int jobIndex = eventRep.jobStatus.jobIndex;
    int taskID = eventRep.jobStatus.taskID;
    VCellServerID serverID = VCellServerID.getServerID(eventRep.jobStatus.vcellServerID);
    KeyValue simkey = new KeyValue(eventRep.jobStatus.simulationKey);
    User owner = new User(eventRep.jobStatus.owner_userid, new KeyValue(eventRep.jobStatus.onwer_userkey));
    VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simkey, owner);
    Date submitDate = eventRep.jobStatus.submitDate;
    SchedulerStatus schedulerStatus = null;
    if (eventRep.jobStatus.schedulerStatus != null) {
        schedulerStatus = SchedulerStatus.valueOf(eventRep.jobStatus.schedulerStatus.name());
    }
    HtcJobID htcJobID = null;
    Long htcJobNumber = eventRep.jobStatus.htcJobNumber;
    SimulationJobStatusRepresentation.BatchSystemType htcBatchSystemType = eventRep.jobStatus.htcBatchSystemType;
    if (htcJobNumber != null) {
        htcJobID = new HtcJobID(htcJobNumber.toString(), BatchSystemType.valueOf(htcBatchSystemType.name()));
    }
    SimulationMessage simMessage = null;
    DetailedState detailedState = DetailedState.valueOf(eventRep.jobStatus.detailedState.name());
    String message = eventRep.jobStatus.detailedStateMessage;
    if (detailedState != null) {
        simMessage = SimulationMessage.create(detailedState, message, htcJobID);
    }
    SimulationQueueEntryStatus simQueueStatus = null;
    Date queueDate = eventRep.jobStatus.queueDate;
    Integer queuePriority = eventRep.jobStatus.queuePriority;
    SimulationJobStatusRepresentation.SimulationQueueID queueId2 = eventRep.jobStatus.queueId;
    if (queueDate != null && queuePriority != null) {
        simQueueStatus = new SimulationQueueEntryStatus(queueDate, queuePriority, SimulationQueueID.valueOf(queueId2.name()));
    }
    SimulationExecutionStatus simExeStatus = null;
    Date startDate = eventRep.jobStatus.simexe_startDate;
    String computeHost = eventRep.jobStatus.computeHost;
    Date latestUpdateDate = eventRep.jobStatus.simexe_latestUpdateDate;
    Date endDate = eventRep.jobStatus.simexe_endDate;
    Boolean hasData = eventRep.jobStatus.hasData;
    if (latestUpdateDate != null) {
        simExeStatus = new SimulationExecutionStatus(startDate, computeHost, latestUpdateDate, endDate, hasData, htcJobID);
    }
    SimulationJobStatus jobStatus = new SimulationJobStatus(serverID, vcSimID, jobIndex, submitDate, schedulerStatus, taskID, simMessage, simQueueStatus, simExeStatus);
    Double progress = eventRep.progress;
    Double timepoint = eventRep.timePoint;
    String username = eventRep.username;
    SimulationJobStatusEvent event = new SimulationJobStatusEvent(eventSource, simid, jobStatus, progress, timepoint, username);
    return event;
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) SimulationExecutionStatus(cbit.vcell.server.SimulationExecutionStatus) KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) SchedulerStatus(cbit.vcell.server.SimulationJobStatus.SchedulerStatus) SimulationJobStatusRepresentation(org.vcell.api.common.events.SimulationJobStatusRepresentation) DetailedState(cbit.vcell.solver.server.SimulationMessage.DetailedState) SimulationQueueEntryStatus(cbit.vcell.server.SimulationQueueEntryStatus) Date(java.util.Date) VCellServerID(org.vcell.util.document.VCellServerID) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationMessage(cbit.vcell.solver.server.SimulationMessage) HtcJobID(cbit.vcell.server.HtcJobID)

Aggregations

SimulationMessage (cbit.vcell.solver.server.SimulationMessage)6 SimulationExecutionStatus (cbit.vcell.server.SimulationExecutionStatus)3 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)3 SchedulerStatus (cbit.vcell.server.SimulationJobStatus.SchedulerStatus)3 SimulationQueueEntryStatus (cbit.vcell.server.SimulationQueueEntryStatus)3 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)3 Date (java.util.Date)3 KeyValue (org.vcell.util.document.KeyValue)3 VCellServerID (org.vcell.util.document.VCellServerID)3 HtcJobID (cbit.vcell.server.HtcJobID)2 User (org.vcell.util.document.User)2 WorkerEvent (cbit.rmi.event.WorkerEvent)1 VCMessagingException (cbit.vcell.message.VCMessagingException)1 StatusMessage (cbit.vcell.message.messages.StatusMessage)1 WorkerEventMessage (cbit.vcell.message.messages.WorkerEventMessage)1 VCellServiceMXBeanImpl (cbit.vcell.message.server.jmx.VCellServiceMXBeanImpl)1 SimulationTask (cbit.vcell.messaging.server.SimulationTask)1 ServiceName (cbit.vcell.mongodb.VCMongoMessage.ServiceName)1 RunningStateInfo (cbit.vcell.server.RunningStateInfo)1 SimulationQueueID (cbit.vcell.server.SimulationJobStatus.SimulationQueueID)1