Search in sources :

Example 6 with VCMessage

use of cbit.vcell.message.VCMessage in project vcell by virtualcell.

the class VCellServices method dataJobMessage.

public void dataJobMessage(cbit.rmi.event.DataJobEvent event) {
    synchronized (dataSession) {
        try {
            // VCMessageSession dataSession = vcMessagingService.createProducerSession();
            VCMessage dataEventMessage = dataSession.createObjectMessage(event);
            dataEventMessage.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_DATA_EVENT_VALUE);
            dataEventMessage.setStringProperty(VCMessagingConstants.USERNAME_PROPERTY, event.getUser().getName());
            dataSession.sendTopicMessage(VCellTopic.ClientStatusTopic, dataEventMessage);
        // dataSession.close();
        } catch (VCMessagingException ex) {
            lg.error(ex.getMessage(), ex);
        }
    }
}
Also used : VCMessage(cbit.vcell.message.VCMessage) VCMessagingException(cbit.vcell.message.VCMessagingException)

Example 7 with VCMessage

use of cbit.vcell.message.VCMessage in project vcell by virtualcell.

the class VCellServices method exportMessage.

public void exportMessage(cbit.rmi.event.ExportEvent event) {
    synchronized (exportSession) {
        try {
            // VCMessageSession dataSession = vcMessagingService.createProducerSession();
            VCMessage exportEventMessage = exportSession.createObjectMessage(event);
            exportEventMessage.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_EXPORT_EVENT_VALUE);
            exportEventMessage.setStringProperty(VCMessagingConstants.USERNAME_PROPERTY, event.getUser().getName());
            exportSession.sendTopicMessage(VCellTopic.ClientStatusTopic, exportEventMessage);
        // dataSession.close();
        } catch (VCMessagingException ex) {
            lg.error(ex.getMessage(), ex);
        }
    }
}
Also used : VCMessage(cbit.vcell.message.VCMessage) VCMessagingException(cbit.vcell.message.VCMessagingException)

Example 8 with VCMessage

use of cbit.vcell.message.VCMessage in project vcell by virtualcell.

the class HtcSimulationWorker method initQueueConsumer.

// ------------------------------Job Monitor Section END
private void initQueueConsumer() {
    startJobMonitor();
    this.messageProducer_sim = vcMessagingService_sim.createProducerSession();
    this.messageProducer_int = vcMessagingService_int.createProducerSession();
    QueueListener queueListener = new QueueListener() {

        @Override
        public void onQueueMessage(VCMessage vcMessage, VCMessageSession session) throws RollbackException {
            SimulationTask simTask = null;
            try {
                SimulationTaskMessage simTaskMessage = new SimulationTaskMessage(vcMessage);
                simTask = simTaskMessage.getSimulationTask();
                if (lg.isInfoEnabled()) {
                    lg.info("onQueueMessage() run simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName());
                }
                PostProcessingChores rd = choresFor(simTask);
                HtcProxy clonedHtcProxy = htcProxy.cloneThreadsafe();
                if (lg.isInfoEnabled()) {
                    lg.info("onQueueMessage() submit job: simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName());
                }
                HtcJobID pbsId = submit2PBS(simTask, clonedHtcProxy, rd);
                addMonitorJob(pbsId.getJobNumber(), simTask, false);
                if (lg.isInfoEnabled()) {
                    lg.info("onQueueMessage() sending 'accepted' message for job: simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName());
                }
                synchronized (messageProducer_sim) {
                    WorkerEventMessage.sendAccepted(messageProducer_sim, HtcSimulationWorker.class.getName(), simTask, ManageUtils.getHostName(), pbsId);
                    WorkerEventMessage.sendStarting(messageProducer_sim, HtcSimulationWorker.class.getName(), simTask, ManageUtils.getHostName(), SimulationMessage.MESSAGE_WORKEREVENT_STARTING);
                    WorkerEventMessage.sendProgress(messageProducer_sim, HtcSimulationWorker.class.getName(), simTask, ManageUtils.getHostName(), 0, 0, SimulationMessage.MESSAGE_JOB_RUNNING_UNKNOWN);
                }
                if (lg.isInfoEnabled()) {
                    lg.info("onQueueMessage() sent 'accepted' message for job: simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName());
                }
            } catch (Exception e) {
                lg.error(e.getMessage(), e);
                if (simTask != null) {
                    try {
                        lg.error("failed to process simTask request: " + e.getMessage() + " for simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName(), e);
                        synchronized (messageProducer_sim) {
                            WorkerEventMessage.sendFailed(messageProducer_sim, HtcSimulationWorker.class.getName(), simTask, ManageUtils.getHostName(), SimulationMessage.jobFailed(e.getMessage()));
                        }
                        lg.error("sent 'failed' message for simulation key=" + simTask.getSimKey() + ", job=" + simTask.getSimulationJobID() + ", task=" + simTask.getTaskID() + " for user " + simTask.getUserName(), e);
                    } catch (VCMessagingException e1) {
                        lg.error(e1.getMessage(), e);
                    }
                } else {
                    lg.error("failed to process simTask request: " + e.getMessage(), e);
                }
            }
        }
    };
    int numHtcworkerThreads = Integer.parseInt(PropertyLoader.getProperty(PropertyLoader.htcworkerThreadsProperty, "5"));
    this.pooledQueueConsumer_int = new VCPooledQueueConsumer(queueListener, numHtcworkerThreads, messageProducer_int);
    this.pooledQueueConsumer_int.initThreadPool();
    VCellQueue queue = VCellQueue.SimJobQueue;
    VCMessageSelector selector = vcMessagingService_int.createSelector(getJobSelector());
    String threadName = "SimJob Queue Consumer";
    queueConsumer = new VCQueueConsumer(queue, pooledQueueConsumer_int, selector, threadName, MessageConstants.PREFETCH_LIMIT_SIM_JOB_HTC);
    vcMessagingService_int.addMessageConsumer(queueConsumer);
}
Also used : QueueListener(cbit.vcell.message.VCQueueConsumer.QueueListener) SimulationTask(cbit.vcell.messaging.server.SimulationTask) HtcProxy(cbit.vcell.message.server.htc.HtcProxy) VCMessageSelector(cbit.vcell.message.VCMessageSelector) VCMessageSession(cbit.vcell.message.VCMessageSession) VCPooledQueueConsumer(cbit.vcell.message.VCPooledQueueConsumer) ExecutableException(org.vcell.util.exe.ExecutableException) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) UnknownHostException(java.net.UnknownHostException) VCMessagingException(cbit.vcell.message.VCMessagingException) FileNotFoundException(java.io.FileNotFoundException) RollbackException(cbit.vcell.message.RollbackException) SolverException(cbit.vcell.solver.SolverException) VCQueueConsumer(cbit.vcell.message.VCQueueConsumer) VCMessage(cbit.vcell.message.VCMessage) VCMessagingException(cbit.vcell.message.VCMessagingException) HtcJobID(cbit.vcell.server.HtcJobID) VCellQueue(cbit.vcell.message.VCellQueue) SimulationTaskMessage(cbit.vcell.message.messages.SimulationTaskMessage)

Example 9 with VCMessage

use of cbit.vcell.message.VCMessage 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 10 with VCMessage

use of cbit.vcell.message.VCMessage 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)) {
                lg.error("SimulationControllerImpl.stopSimulation() exercising serviceControl topic ... should be removed");
                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)

Aggregations

VCMessage (cbit.vcell.message.VCMessage)22 VCMessageSession (cbit.vcell.message.VCMessageSession)10 VCMessagingException (cbit.vcell.message.VCMessagingException)9 VCMessageSelector (cbit.vcell.message.VCMessageSelector)6 VCQueueConsumer (cbit.vcell.message.VCQueueConsumer)5 QueueListener (cbit.vcell.message.VCQueueConsumer.QueueListener)5 VCDestination (cbit.vcell.message.VCDestination)4 SimulationJobStatus (cbit.vcell.server.SimulationJobStatus)4 FileNotFoundException (java.io.FileNotFoundException)4 RollbackException (cbit.vcell.message.RollbackException)3 VCTopicConsumer (cbit.vcell.message.VCTopicConsumer)3 TopicListener (cbit.vcell.message.VCTopicConsumer.TopicListener)3 LocalVCMessageAdapter (cbit.vcell.message.local.LocalVCMessageAdapter)3 LocalVCMessageListener (cbit.vcell.message.local.LocalVCMessageAdapter.LocalVCMessageListener)3 SolverException (cbit.vcell.solver.SolverException)3 XmlParseException (cbit.vcell.xml.XmlParseException)3 DataAccessException (org.vcell.util.DataAccessException)3 MessagePropertyNotFoundException (cbit.vcell.message.MessagePropertyNotFoundException)2 VCMessagingService (cbit.vcell.message.VCMessagingService)2 VCPooledQueueConsumer (cbit.vcell.message.VCPooledQueueConsumer)2