Search in sources :

Example 1 with VCMessageSelector

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

the class ClientTopicMessageCollector method init.

/**
 * onException method comment.
 */
public void init() {
    VCMessageSelector selector = null;
    topicConsumer = new VCTopicConsumer(VCellTopic.ClientStatusTopic, this, selector, "Client Status Topic Consumer", MessageConstants.PREFETCH_LIMIT_CLIENT_TOPIC);
    vcMessagingService.addMessageConsumer(topicConsumer);
}
Also used : VCMessageSelector(cbit.vcell.message.VCMessageSelector) VCTopicConsumer(cbit.vcell.message.VCTopicConsumer)

Example 2 with VCMessageSelector

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

the class SimulationDispatcher method init.

public void init() {
    // 
    // set up consumer for WorkerEvent messages
    // 
    QueueListener workerEventListener = new QueueListener() {

        public void onQueueMessage(VCMessage vcMessage, VCMessageSession session) throws RollbackException {
            onWorkerEventMessage(vcMessage, session);
        }
    };
    VCMessageSelector workerEventSelector = null;
    String threadName = "Worker Event Consumer";
    workerEventConsumer = new VCQueueConsumer(VCellQueue.WorkerEventQueue, workerEventListener, workerEventSelector, threadName, MessageConstants.PREFETCH_LIMIT_WORKER_EVENT);
    vcMessagingService.addMessageConsumer(workerEventConsumer);
    // 
    // set up consumer for Simulation Request (non-blocking RPC) messages
    // 
    SimulationService simServiceImpl = new SimulationServiceImpl();
    VCMessageSelector simRequestSelector = null;
    threadName = "Sim Request Consumer";
    this.rpcMessageHandler = new VCRpcMessageHandler(simServiceImpl, VCellQueue.SimReqQueue);
    simRequestConsumer = new VCQueueConsumer(VCellQueue.SimReqQueue, rpcMessageHandler, simRequestSelector, threadName, MessageConstants.PREFETCH_LIMIT_SIM_REQUEST);
    vcMessagingService.addMessageConsumer(simRequestConsumer);
    this.dispatcherQueueSession = vcMessagingService.createProducerSession();
    this.dispatchThread = new DispatchThread();
    this.dispatchThread.start();
    initControlTopicListener();
    this.simMonitorThreadSession = vcMessagingService.createProducerSession();
    this.simMonitor = new SimulationMonitor();
}
Also used : QueueListener(cbit.vcell.message.VCQueueConsumer.QueueListener) VCMessageSelector(cbit.vcell.message.VCMessageSelector) VCMessage(cbit.vcell.message.VCMessage) VCMessageSession(cbit.vcell.message.VCMessageSession) VCRpcMessageHandler(cbit.vcell.message.VCRpcMessageHandler) SimulationService(cbit.vcell.server.SimulationService) VCQueueConsumer(cbit.vcell.message.VCQueueConsumer)

Example 3 with VCMessageSelector

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

the class HtcSimulationWorker method initQueueConsumer.

private void initQueueConsumer() {
    this.sharedMessageProducer = vcMessagingService.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);
                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 (sharedMessageProducer) {
                    WorkerEventMessage.sendAccepted(sharedMessageProducer, HtcSimulationWorker.class.getName(), simTask, ManageUtils.getHostName(), pbsId);
                }
                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 (sharedMessageProducer) {
                            WorkerEventMessage.sendFailed(sharedMessageProducer, 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 = new VCPooledQueueConsumer(queueListener, numHtcworkerThreads, sharedMessageProducer);
    this.pooledQueueConsumer.initThreadPool();
    VCellQueue queue = VCellQueue.SimJobQueue;
    VCMessageSelector selector = vcMessagingService.createSelector(getJobSelector());
    String threadName = "SimJob Queue Consumer";
    queueConsumer = new VCQueueConsumer(queue, pooledQueueConsumer, selector, threadName, MessageConstants.PREFETCH_LIMIT_SIM_JOB_HTC);
    vcMessagingService.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) VCMessagingException(cbit.vcell.message.VCMessagingException) FileNotFoundException(java.io.FileNotFoundException) ConfigurationException(org.vcell.util.ConfigurationException) ExecutableException(org.vcell.util.exe.ExecutableException) RollbackException(cbit.vcell.message.RollbackException) XmlParseException(cbit.vcell.xml.XmlParseException) SolverException(cbit.vcell.solver.SolverException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) UnknownHostException(java.net.UnknownHostException) 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 4 with VCMessageSelector

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

the class JavaSimulationExecutable method init.

protected void init() throws JMSException {
    // 
    // session used for sending worker events.
    // 
    this.workerEventSession = vcMessagingService.createProducerSession();
    // 
    // message consumer for Service Control topic message (to stop simulation).
    // 
    VCellTopic topic = VCellTopic.ServiceControlTopic;
    TopicListener listener = new TopicListener() {

        public void onTopicMessage(VCMessage vcMessage, VCMessageSession session) {
            if (lg.isTraceEnabled())
                lg.trace("JavaSimulationExecutable::onControlTopicMessage(): " + vcMessage.show());
            try {
                String msgType = vcMessage.getStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY);
                if (msgType != null && msgType.equals(MessageConstants.MESSAGE_TYPE_STOPSIMULATION_VALUE)) {
                    Long longkey = vcMessage.getLongProperty(MessageConstants.SIMKEY_PROPERTY);
                    KeyValue simKey = new KeyValue(longkey + "");
                    int jobIndex = vcMessage.getIntProperty(MessageConstants.JOBINDEX_PROPERTY);
                    if (simKey.equals(simulationTask.getSimKey()) && jobIndex == simulationTask.getSimulationJob().getJobIndex()) {
                        solver.stopSolver();
                    }
                }
            } catch (MessagePropertyNotFoundException ex) {
                lg.error(ex.getMessage(), ex);
                return;
            }
        }
    };
    VCMessageSelector selector = null;
    String threadName = "Service Control Topic Consumer";
    VCTopicConsumer serviceControlConsumer = new VCTopicConsumer(topic, listener, selector, threadName, MessageConstants.PREFETCH_LIMIT_SERVICE_CONTROL);
    vcMessagingService.addMessageConsumer(serviceControlConsumer);
}
Also used : TopicListener(cbit.vcell.message.VCTopicConsumer.TopicListener) KeyValue(org.vcell.util.document.KeyValue) MessagePropertyNotFoundException(cbit.vcell.message.MessagePropertyNotFoundException) VCMessageSelector(cbit.vcell.message.VCMessageSelector) VCMessage(cbit.vcell.message.VCMessage) VCTopicConsumer(cbit.vcell.message.VCTopicConsumer) VCMessageSession(cbit.vcell.message.VCMessageSession) VCellTopic(cbit.vcell.message.VCellTopic)

Example 5 with VCMessageSelector

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

the class ServiceProvider method initControlTopicListener.

/**
 * Insert the method's description here.
 * Creation date: (11/19/2001 5:29:47 PM)
 */
public void initControlTopicListener() {
    if (bSlaveMode) {
        return;
    }
    TopicListener listener = new TopicListener() {

        public void onTopicMessage(VCMessage message, VCMessageSession session) {
            try {
                String msgType = message.getStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY);
                String serviceID = null;
                if (msgType == null) {
                    return;
                }
                if (msgType.equals(MessageConstants.MESSAGE_TYPE_ISSERVICEALIVE_VALUE)) {
                    VCMessage reply = session.createObjectMessage(ServiceProvider.this.serviceInstanceStatus);
                    reply.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_IAMALIVE_VALUE);
                    reply.setStringProperty(MessageConstants.SERVICE_ID_PROPERTY, serviceInstanceStatus.getID());
                    if (lg.isTraceEnabled())
                        lg.trace("sending reply [" + reply.toString() + "]");
                    if (message.getReplyTo() != null) {
                        reply.setCorrelationID(message.getMessageID());
                        session.sendTopicMessage((VCellTopic) message.getReplyTo(), reply);
                    } else {
                        session.sendTopicMessage(VCellTopic.DaemonControlTopic, reply);
                    }
                } else if (msgType.equals(MessageConstants.MESSAGE_TYPE_ASKPERFORMANCESTATUS_VALUE)) {
                    VCMessage reply = session.createObjectMessage(serviceInstanceStatus);
                    reply.setStringProperty(VCMessagingConstants.MESSAGE_TYPE_PROPERTY, MessageConstants.MESSAGE_TYPE_REPLYPERFORMANCESTATUS_VALUE);
                    reply.setStringProperty(MessageConstants.SERVICE_ID_PROPERTY, serviceInstanceStatus.getID());
                    session.sendTopicMessage(VCellTopic.DaemonControlTopic, reply);
                    if (lg.isTraceEnabled())
                        lg.trace("sending reply [" + reply.toString() + "]");
                } else if (msgType.equals(MessageConstants.MESSAGE_TYPE_STOPSERVICE_VALUE)) {
                    serviceID = message.getStringProperty(MessageConstants.SERVICE_ID_PROPERTY);
                    if (serviceID != null && serviceID.equalsIgnoreCase(serviceInstanceStatus.getID())) {
                        stopService();
                    }
                }
            } catch (Exception ex) {
                lg.error(ex.getMessage(), ex);
            }
        }
    };
    VCMessageSelector selector = vcMessagingService.createSelector(getDaemonControlFilter());
    String threadName = "Daemon Control Topic Consumer";
    vcTopicConsumer = new VCTopicConsumer(VCellTopic.DaemonControlTopic, listener, selector, threadName, MessageConstants.PREFETCH_LIMIT_DAEMON_CONTROL);
    vcMessagingService.addMessageConsumer(vcTopicConsumer);
}
Also used : TopicListener(cbit.vcell.message.VCTopicConsumer.TopicListener) VCMessageSelector(cbit.vcell.message.VCMessageSelector) VCMessage(cbit.vcell.message.VCMessage) VCTopicConsumer(cbit.vcell.message.VCTopicConsumer) VCMessageSession(cbit.vcell.message.VCMessageSession) FileNotFoundException(java.io.FileNotFoundException) VCMessagingException(cbit.vcell.message.VCMessagingException)

Aggregations

VCMessageSelector (cbit.vcell.message.VCMessageSelector)6 VCMessage (cbit.vcell.message.VCMessage)4 VCMessageSession (cbit.vcell.message.VCMessageSession)4 VCQueueConsumer (cbit.vcell.message.VCQueueConsumer)3 VCTopicConsumer (cbit.vcell.message.VCTopicConsumer)3 VCMessagingException (cbit.vcell.message.VCMessagingException)2 VCPooledQueueConsumer (cbit.vcell.message.VCPooledQueueConsumer)2 QueueListener (cbit.vcell.message.VCQueueConsumer.QueueListener)2 VCRpcMessageHandler (cbit.vcell.message.VCRpcMessageHandler)2 TopicListener (cbit.vcell.message.VCTopicConsumer.TopicListener)2 FileNotFoundException (java.io.FileNotFoundException)2 MessagePropertyNotFoundException (cbit.vcell.message.MessagePropertyNotFoundException)1 RollbackException (cbit.vcell.message.RollbackException)1 VCellQueue (cbit.vcell.message.VCellQueue)1 VCellTopic (cbit.vcell.message.VCellTopic)1 SimulationTaskMessage (cbit.vcell.message.messages.SimulationTaskMessage)1 ServiceType (cbit.vcell.message.server.bootstrap.ServiceType)1 HtcProxy (cbit.vcell.message.server.htc.HtcProxy)1 SimulationTask (cbit.vcell.messaging.server.SimulationTask)1 HtcJobID (cbit.vcell.server.HtcJobID)1