Search in sources :

Example 1 with LocalVCMessageAdapter

use of cbit.vcell.message.local.LocalVCMessageAdapter 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 2 with LocalVCMessageAdapter

use of cbit.vcell.message.local.LocalVCMessageAdapter 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 3 with LocalVCMessageAdapter

use of cbit.vcell.message.local.LocalVCMessageAdapter in project vcell by virtualcell.

the class SimulationControllerImpl method onWorkerEvent.

/**
 * Insert the method's description here.
 * Creation date: (3/11/2004 10:44:18 AM)
 * @param newJobStatus cbit.vcell.messaging.db.SimulationJobStatus
 * @param progress java.lang.Double
 * @param timePoint java.lang.Double
 */
public void onWorkerEvent(WorkerEvent workerEvent) {
    try {
        LocalVCMessageListener localVCMessageListener = new LocalVCMessageListener() {

            public void onLocalVCMessage(VCDestination destination, VCMessage objectMessage) {
                if (destination == VCellTopic.ClientStatusTopic && objectMessage.getObjectContent() instanceof SimulationJobStatus) {
                    onClientStatusTopic_SimulationJobStatus(objectMessage);
                } else {
                    throw new RuntimeException("SimulationControllerImpl.onWorkerEvent().localMessageListener::  expecting object message with SimulationJobStatus to topic " + VCellTopic.ClientStatusTopic.getName() + ": received \"" + objectMessage.show() + "\"");
                }
            }
        };
        LocalVCMessageAdapter vcMessageSession = new LocalVCMessageAdapter(localVCMessageListener);
        simulationDispatcherEngine.onWorkerEvent(workerEvent, simulationDatabase, vcMessageSession);
        vcMessageSession.deliverAll();
    } catch (Exception e) {
        lg.error(e.getMessage(), e);
    }
}
Also used : VCDestination(cbit.vcell.message.VCDestination) LocalVCMessageListener(cbit.vcell.message.local.LocalVCMessageAdapter.LocalVCMessageListener) VCMessage(cbit.vcell.message.VCMessage) SimulationJobStatus(cbit.vcell.server.SimulationJobStatus) 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) LocalVCMessageAdapter(cbit.vcell.message.local.LocalVCMessageAdapter)

Aggregations

VCDestination (cbit.vcell.message.VCDestination)3 VCMessage (cbit.vcell.message.VCMessage)3 LocalVCMessageAdapter (cbit.vcell.message.local.LocalVCMessageAdapter)3 LocalVCMessageListener (cbit.vcell.message.local.LocalVCMessageAdapter.LocalVCMessageListener)3 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)3 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)2 VCMessagingException (cbit.vcell.message.VCMessagingException)1 SolverException (cbit.vcell.solver.SolverException)1 FileNotFoundException (java.io.FileNotFoundException)1 RemoteException (java.rmi.RemoteException)1 SQLException (java.sql.SQLException)1 JMSException (javax.jms.JMSException)1 AuthenticationException (org.vcell.util.AuthenticationException)1 ConfigurationException (org.vcell.util.ConfigurationException)1 DataAccessException (org.vcell.util.DataAccessException)1 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)1 PermissionException (org.vcell.util.PermissionException)1