Search in sources :

Example 46 with VCSimulationIdentifier

use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.

the class VtkMeshGenerator method generateVtkMeshes.

private void generateVtkMeshes(User owner, KeyValue simKey, int jobIndex) throws DataAccessException, IOException {
    VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, owner);
    VCSimulationDataIdentifier vcdataID = new VCSimulationDataIdentifier(vcSimID, jobIndex);
    Cachetable cacheTable = new Cachetable(MessageConstants.MINUTE_IN_MS * 20);
    DataSetControllerImpl dataSetControllerImpl = new DataSetControllerImpl(cacheTable, new File(PropertyLoader.getRequiredProperty(PropertyLoader.primarySimDataDirInternalProperty)), new File(PropertyLoader.getRequiredProperty(PropertyLoader.secondarySimDataDirInternalProperty)));
    ExportServiceImpl exportServiceImpl = new ExportServiceImpl();
    DataServerImpl dataServerImpl = new DataServerImpl(dataSetControllerImpl, exportServiceImpl);
    // @SuppressWarnings("unused")
    if (!dataSetControllerImpl.getIsMovingBoundary(vcdataID)) {
        // 
        // precompute single static vtk mesh
        // 
        VtuFileContainer vtuFileContainer = dataServerImpl.getEmptyVtuMeshFiles(owner, vcdataID, 0);
    } else {
        // 
        // precompute static vtk mesh for each saved time point
        // 
        double[] times = dataServerImpl.getDataSetTimes(owner, vcdataID);
        for (int i = 0; i < times.length; i++) {
            VtuFileContainer vtuFileContainer = dataServerImpl.getEmptyVtuMeshFiles(owner, vcdataID, i);
        }
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) ExportServiceImpl(cbit.vcell.export.server.ExportServiceImpl) VtuFileContainer(org.vcell.vis.io.VtuFileContainer) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) File(java.io.File)

Example 47 with VCSimulationIdentifier

use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.

the class WorkerEventMessage method parseMessage.

/**
 * Insert the method's description here.
 * Creation date: (2/5/2004 2:19:48 PM)
 * @param message javax.jms.Message
 * @throws DataAccessException
 * @throws SQLException
 */
private void parseMessage(UserResolver userResolver, VCMessage message) throws DataAccessException, SQLException {
    if (message == null) {
        throw new RuntimeException("Null message");
    }
    if (!message.propertyExists(VCMessagingConstants.MESSAGE_TYPE_PROPERTY)) {
        throw new RuntimeException("Wrong message: expecting property " + VCMessagingConstants.MESSAGE_TYPE_PROPERTY);
    }
    String msgType = message.getStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY);
    if (msgType != null && !msgType.equals(MessageConstants.MESSAGE_TYPE_WORKEREVENT_VALUE)) {
        throw new RuntimeException("Wrong message type: " + msgType + ", expecting: " + MessageConstants.MESSAGE_TYPE_WORKEREVENT_VALUE);
    }
    Object obj = message.getObjectContent();
    if (obj != null) {
        if (obj instanceof WorkerEvent) {
            // from Java executable or htcWorker
            workerEvent = (WorkerEvent) obj;
        } else if (obj instanceof String) {
            // from c++ executable (REST API where message stored as a single JSON object)
            String jsonContent = (String) obj;
            System.out.println("received JSON from message: " + jsonContent);
        } else {
            throw new IllegalArgumentException("Expecting object message with object " + WorkerEvent.class.getName() + ", found object :" + obj.getClass().getName());
        }
    } else {
        // from c++ executable (activemq-cpp native protocol communication library)
        int status = message.getIntProperty(MessageConstants.WORKEREVENT_STATUS);
        String hostname = message.getStringProperty(MessageConstants.HOSTNAME_PROPERTY);
        String username = message.getStringProperty(VCMessagingConstants.USERNAME_PROPERTY);
        int taskID = message.getIntProperty(MessageConstants.TASKID_PROPERTY);
        int jobIndex = message.getIntProperty(MessageConstants.JOBINDEX_PROPERTY);
        Long longkey = message.getLongProperty(MessageConstants.SIMKEY_PROPERTY);
        KeyValue simKey = new KeyValue(longkey + "");
        // Simulation sim = null;
        User user = userResolver.getUser(username);
        VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, user);
        String statusMessage = null;
        Double progress = null;
        Double timepoint = null;
        if (message.propertyExists(MessageConstants.WORKEREVENT_STATUSMSG)) {
            statusMessage = message.getStringProperty(MessageConstants.WORKEREVENT_STATUSMSG);
        }
        if (message.propertyExists(MessageConstants.WORKEREVENT_PROGRESS)) {
            progress = message.getDoubleProperty(MessageConstants.WORKEREVENT_PROGRESS);
        }
        if (message.propertyExists(MessageConstants.WORKEREVENT_TIMEPOINT)) {
            timepoint = message.getDoubleProperty(MessageConstants.WORKEREVENT_TIMEPOINT);
        }
        SimulationMessage simulationMessage = SimulationMessage.fromSerializedMessage(statusMessage);
        if (simulationMessage == null) {
            switch(status) {
                case WorkerEvent.JOB_ACCEPTED:
                    throw new RuntimeException("unexpected job_accepted status");
                case WorkerEvent.JOB_STARTING:
                    if (statusMessage == null) {
                        simulationMessage = SimulationMessage.MESSAGE_WORKEREVENT_STARTING;
                    } else {
                        simulationMessage = SimulationMessage.workerStarting(statusMessage);
                    }
                    break;
                case WorkerEvent.JOB_DATA:
                    simulationMessage = SimulationMessage.workerData(timepoint);
                    break;
                case WorkerEvent.JOB_PROGRESS:
                    simulationMessage = SimulationMessage.workerProgress(progress);
                    break;
                case WorkerEvent.JOB_FAILURE:
                    if (statusMessage == null) {
                        simulationMessage = SimulationMessage.MESSAGE_WORKEREVENT_FAILURE;
                    } else {
                        simulationMessage = SimulationMessage.workerFailure(statusMessage);
                    }
                    break;
                case WorkerEvent.JOB_COMPLETED:
                    if (statusMessage == null) {
                        simulationMessage = SimulationMessage.MESSAGE_WORKEREVENT_COMPLETED;
                    } else {
                        simulationMessage = SimulationMessage.workerCompleted(statusMessage);
                    }
                    break;
                case WorkerEvent.JOB_WORKER_ALIVE:
                    simulationMessage = SimulationMessage.MESSAGE_WORKEREVENT_WORKERALIVE;
                    break;
                default:
                    throw new RuntimeException("unexpected worker event status : " + status);
            }
        }
        ServiceName serviceName = VCMongoMessage.getServiceName();
        workerEvent = new WorkerEvent(status, serviceName, vcSimID, jobIndex, hostname, taskID, progress, timepoint, simulationMessage);
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) WorkerEvent(cbit.rmi.event.WorkerEvent) ServiceName(cbit.vcell.mongodb.VCMongoMessage.ServiceName) SimulationMessage(cbit.vcell.solver.server.SimulationMessage)

Example 48 with VCSimulationIdentifier

use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.

the class VCellSimReader method getVCSimulationIdentifierFromVCellSimulationData.

public static VCSimulationIdentifier getVCSimulationIdentifierFromVCellSimulationData(File vcellSimLogFile) {
    final String SIMID_PREFIX = "SimID_";
    String simulationKeyS = vcellSimLogFile.getName().substring(SIMID_PREFIX.length(), vcellSimLogFile.getName().indexOf('_', SIMID_PREFIX.length()));
    KeyValue simulationKey = new KeyValue(simulationKeyS);
    return new VCSimulationIdentifier(simulationKey, getDotUser());
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) KeyValue(org.vcell.util.document.KeyValue)

Example 49 with VCSimulationIdentifier

use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.

the class SimulationControllerImpl method getOrCreateSolverController.

/**
 * This method was created by a SmartGuide.
 * @throws SolverException
 * @throws DataAccessException
 * @throws ConfigurationException
 * @exception java.rmi.RemoteException The exception description.
 * @throws JMSException
 * @throws AuthenticationException
 * @throws SQLException
 * @throws FileNotFoundException
 */
LocalSolverController getOrCreateSolverController(SimulationTask simTask) throws FileNotFoundException, ConfigurationException, DataAccessException, AuthenticationException, SQLException, SolverException {
    Simulation simulation = simTask.getSimulation();
    VCSimulationIdentifier vcSimID = simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
    if (vcSimID == null) {
        throw new IllegalArgumentException("cannot run an unsaved simulation");
    }
    if (!simulation.getVersion().getOwner().equals(localVCellConnection.getUserLoginInfo().getUser())) {
        throw new PermissionException("insufficient privilege: startSimulation()");
    }
    SimulationTaskID simTaskInfo = new SimulationTaskID(simTask);
    LocalSolverController solverController = solverControllerHash.get(simTaskInfo);
    if (solverController == null) {
        solverController = createNewSolverController(simTask);
        solverControllerHash.put(simTaskInfo, solverController);
    }
    return solverController;
}
Also used : PermissionException(org.vcell.util.PermissionException) LocalSolverController(cbit.vcell.solvers.LocalSolverController) VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) Simulation(cbit.vcell.solver.Simulation) SimulationTaskID(cbit.vcell.server.SimulationTaskID)

Example 50 with VCSimulationIdentifier

use of cbit.vcell.solver.VCSimulationIdentifier in project vcell by virtualcell.

the class SimulationControllerImpl method onServiceControlTopic_StopSimulation.

private void onServiceControlTopic_StopSimulation(VCMessage message) {
    KeyValue simKey = new KeyValue(String.valueOf(message.getLongProperty(MessageConstants.SIMKEY_PROPERTY)));
    int jobIndex = message.getIntProperty(MessageConstants.JOBINDEX_PROPERTY);
    int taskID = message.getIntProperty(MessageConstants.TASKID_PROPERTY);
    try {
        SimulationTaskID simTaskInfo = new SimulationTaskID(simKey, jobIndex, taskID);
        LocalSolverController solverController = solverControllerHash.get(simTaskInfo);
        if (solverController != null) {
            // can only start after updating the database is done
            solverController.stopSimulationJob();
        }
    } catch (Exception e) {
        lg.error(e.getMessage(), e);
        VCSimulationIdentifier vcSimID = new VCSimulationIdentifier(simKey, localVCellConnection.getUserLoginInfo().getUser());
        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) KeyValue(org.vcell.util.document.KeyValue) SimulationTaskID(cbit.vcell.server.SimulationTaskID) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) SimulationJobStatusEvent(cbit.rmi.event.SimulationJobStatusEvent) 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)

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