def create_tenant_rpc_server(self, tid): """create_ blocking rpc server @param tid: openstack tenant id """ ret = {} if tid in self.rpc_servers: LOG.warning(_LW("already in message queue and server. queue=%s"), self.rpc_servers[tid]['topic']) return {'result': 'FAILED'} topic = "%s-%s" % (self.topic, tid) target = Target(topic=topic, server=cfg.CONF.host, fanout=False) assert n_rpc.TRANSPORT is not None serializer = n_rpc.RequestContextSerializer(None) server = get_rpc_server(n_rpc.TRANSPORT, target, self.agent_top.endpoints, 'blocking', serializer) self.rpc_servers[tid] = {'server': server, 'topic': topic} LOG.debug("RPCServer create: topic=%s", topic) self.rpc_servers[tid]['server'].start() ret['result'] = 'SUCCESS' ret['tenant_id'] = tid ret['topic'] = topic return ret
def create_tenant_rpc_server(self, tid): """create_ blocking rpc server @param tid: openstack tenant id """ ret = {} if tid in self.rpc_servers: LOG.warning(_LW("already in message queue and server. queue=%s"), self.rpc_servers[tid]['topic']) return {'result': 'FAILED'} topic = "%s-%s" % (self.topic, tid) target = Target(topic=topic, server=cfg.CONF.host, fanout=False) assert n_rpc.TRANSPORT is not None serializer = n_rpc.RequestContextSerializer(None) server = get_rpc_server(n_rpc.TRANSPORT, target, self.agent_top.endpoints, 'blocking', serializer) LOG.debug("RPCServer create: topic=%s", topic) if self.greenpool.free() < 1: self.greenpool_size += nwa_const.NWA_GREENPOOL_ADD_SIZE self.greenpool.resize(self.greenpool_size) LOG.info(_LI('RPCServer greenpool resize %s'), self.greenpool_size) def server_start(): while True: try: LOG.debug('RPCServer thread %d start %s', (self.greenpool.running(), server)) server.start() LOG.debug('RPCServer thread end %s', server) break except Exception as e: LOG.exception(_LE('RPCServer thread start failed: %s'), e) self.rpc_servers[tid] = { 'thread': self.greenpool.spawn(server_start), 'server': server, 'topic': topic } eventlet.sleep(0) LOG.info(_LI('RPCServer started: %(topic)s server=%(server)s'), { 'topic': topic, 'server': server }) ret['result'] = 'SUCCESS' ret['tenant_id'] = tid ret['topic'] = topic return ret
def listen_for_notifications(self, targets_and_priorities, pool, batch_size, batch_timeout): """Construct a Listener for notifications on the given target and priority. """ # TODO(kgiusti) should raise NotImplemented if not broker backend LOG.debug("Listen for notifications %s", targets_and_priorities) if pool: raise NotImplementedError('"pool" not implemented by ' 'this transport driver') listener = ProtonListener(self) # this is how the destination target is created by the notifier, # see MessagingDriver.notify in oslo_messaging/notify/messaging.py for target, priority in targets_and_priorities: topic = '%s.%s' % (target.topic, priority) # Sooo... the exchange is simply discarded? (see above comment) task = controller.SubscribeTask(Target(topic=topic), listener, notifications=True) self._ctrl.add_task(task) task.wait() return base.PollStyleListenerAdapter(listener, batch_size, batch_timeout)