Search in sources :

Example 21 with VCSimulationIdentifier

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();
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) VCDestination(cbit.vcell.message.VCDestination) LocalVCMessageListener(cbit.vcell.message.local.LocalVCMessageAdapter.LocalVCMessageListener) VCMessage(cbit.vcell.message.VCMessage) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) LocalVCMessageAdapter(cbit.vcell.message.local.LocalVCMessageAdapter)

Example 22 with VCSimulationIdentifier

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);
    }
}
Also used : LocalSolverController(cbit.vcell.solvers.LocalSolverController) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) SimulationTask(cbit.vcell.messaging.server.SimulationTask) KeyValue(org.vcell.util.document.KeyValue) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationJobStatusEvent(cbit.rmi.event.SimulationJobStatusEvent) SimulationTaskMessage(cbit.vcell.message.messages.SimulationTaskMessage) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) SQLException(java.sql.SQLException) VCMessagingException(cbit.vcell.message.VCMessagingException) SolverException(cbit.vcell.solver.SolverException) AuthenticationException(org.vcell.util.AuthenticationException) DataAccessException(org.vcell.util.DataAccessException) JMSException(javax.jms.JMSException) FileNotFoundException(java.io.FileNotFoundException) RemoteException(java.rmi.RemoteException) ConfigurationException(org.vcell.util.ConfigurationException)

Example 23 with VCSimulationIdentifier

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();
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) VCDestination(cbit.vcell.message.VCDestination) LocalVCMessageListener(cbit.vcell.message.local.LocalVCMessageAdapter.LocalVCMessageListener) VCMessage(cbit.vcell.message.VCMessage) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) LocalVCMessageAdapter(cbit.vcell.message.local.LocalVCMessageAdapter)

Example 24 with VCSimulationIdentifier

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;
}
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 25 with VCSimulationIdentifier

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);
    }
}
Also used : ServerMessagingDelegate(cbit.vcell.message.server.ServerMessagingDelegate) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) Log4jSessionLog(org.vcell.util.logging.Log4jSessionLog) VCMessageSession(cbit.vcell.message.VCMessageSession) VCMessagingService(cbit.vcell.message.VCMessagingService) Logger(org.apache.log4j.Logger) VCMessagingException(cbit.vcell.message.VCMessagingException) ObjectName(javax.management.ObjectName) VCellServiceMXBeanImpl(cbit.vcell.message.server.jmx.VCellServiceMXBeanImpl) VCMessagingException(cbit.vcell.message.VCMessagingException) WorkerEventMessage(cbit.vcell.message.messages.WorkerEventMessage) MBeanServer(javax.management.MBeanServer)

Aggregations

VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)59 KeyValue (org.vcell.util.document.KeyValue)37 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)27 User (org.vcell.util.document.User)20 File (java.io.File)17 Simulation (cbit.vcell.solver.Simulation)16 BigString (org.vcell.util.BigString)14 UserLoginInfo (org.vcell.util.document.UserLoginInfo)11 BioModel (cbit.vcell.biomodel.BioModel)10 Hashtable (java.util.Hashtable)10 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)9 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)9 SQLException (java.sql.SQLException)7 CartesianMesh (cbit.vcell.solvers.CartesianMesh)6 FileNotFoundException (java.io.FileNotFoundException)6 VCDataIdentifier (org.vcell.util.document.VCDataIdentifier)6 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)5 VCMessageSession (cbit.vcell.message.VCMessageSession)5 VCellConnection (cbit.vcell.server.VCellConnection)5 XMLSource (cbit.vcell.xml.XMLSource)5