Beispiel #1
0
    def __init__(self,
                 conf,
                 context,
                 socket_type,
                 host,
                 port,
                 high_watermark=0,
                 identity=None):
        super(ZmqFixedPortSocket, self).__init__(conf,
                                                 context,
                                                 socket_type,
                                                 immediate=False,
                                                 high_watermark=high_watermark,
                                                 identity=identity)
        self.connect_address = zmq_address.combine_address(host, port)
        self.bind_address = zmq_address.get_tcp_direct_address(
            zmq_address.combine_address(
                conf.oslo_messaging_zmq.rpc_zmq_bind_address, port))
        self.host = host
        self.port = port

        try:
            self.handle.bind(self.bind_address)
        except zmq.ZMQError as e:
            LOG.exception(e)
            LOG.error(_LE("Chosen port %d is being busy.") % self.port)
            raise ZmqPortBusy(port_number=port)
Beispiel #2
0
    def on_publishers(self, publishers):
        with self._socket_lock:
            for host, sync in publishers:
                self.socket.connect(zmq_address.get_tcp_direct_address(host))

            self.poller.register(self.socket, self.receive_message)
        LOG.debug("[%s] SUB consumer connected to publishers %s", self.id,
                  publishers)
    def on_publishers(self, publishers):
        with self._socket_lock:
            for host, sync in publishers:
                self.socket.connect(zmq_address.get_tcp_direct_address(host))

            self.poller.register(self.socket, self.receive_message)
        LOG.debug("[%s] SUB consumer connected to publishers %s",
                  (self.id, publishers))
Beispiel #4
0
 def _connect_to_host(self, socket, host, target):
     address = zmq_address.get_tcp_direct_address(host)
     LOG.info(address)
     stype = zmq_names.socket_type_str(self.socket_type)
     try:
         LOG.info(_LI("Connecting %(stype)s to %(address)s for %(target)s")
                  % {"stype": stype,
                     "address": address,
                     "target": target})
         socket.connect(address)
     except zmq.ZMQError as e:
         errmsg = _LE("Failed connecting %(stype) to %(address)s: %(e)s")\
             % (stype, address, e)
         LOG.error(_LE("Failed connecting %(stype) to %(address)s: %(e)s")
                   % (stype, address, e))
         raise rpc_common.RPCException(errmsg)
    def __init__(self, conf, context, socket_type, host, port,
                 high_watermark=0):
        super(ZmqFixedPortSocket, self).__init__(
            conf, context, socket_type, immediate=False,
            high_watermark=high_watermark)
        self.connect_address = zmq_address.combine_address(host, port)
        self.bind_address = zmq_address.get_tcp_direct_address(
            zmq_address.combine_address(conf.rpc_zmq_bind_address, port))
        self.host = host
        self.port = port

        try:
            self.handle.bind(self.bind_address)
        except zmq.ZMQError as e:
            LOG.exception(e)
            LOG.error(_LE("Chosen port %d is being busy.") % self.port)
            raise ZmqPortBusy(port_number=port)
    def _connect_to_host(self, target, timeout=0):

        try:
            self.zmq_context = zmq.Context()
            socket = self.zmq_context.socket(zmq.REQ)

            host = self.matchmaker.get_single_host(target, timeout)
            connect_address = zmq_address.get_tcp_direct_address(host)

            LOG.info(_LI("Connecting REQ to %s") % connect_address)

            socket.connect(connect_address)
            self.outbound_sockets[str(target)] = socket
            return socket

        except zmq.ZMQError as e:
            errmsg = _LE("Error connecting to socket: %s") % str(e)
            LOG.error(_LE("Error connecting to socket: %s") % str(e))
            raise rpc_common.RPCException(errmsg)
    def _connect_to_host(self, target, timeout=0):

        try:
            self.zmq_context = zmq.Context()
            socket = self.zmq_context.socket(zmq.REQ)

            host = self.matchmaker.get_single_host(target, timeout)
            connect_address = zmq_address.get_tcp_direct_address(host)

            LOG.info(_LI("Connecting REQ to %s") % connect_address)

            socket.connect(connect_address)
            self.outbound_sockets[str(target)] = socket
            return socket

        except zmq.ZMQError as e:
            errmsg = _LE("Error connecting to socket: %s") % str(e)
            LOG.error(_LE("Error connecting to socket: %s") % str(e))
            raise rpc_common.RPCException(errmsg)
Beispiel #8
0
 def connect_to_host(self, host):
     address = zmq_address.get_tcp_direct_address(
         host.decode('utf-8')
         if six.PY3 and isinstance(host, six.binary_type) else host)
     self.connect_to_address(address)
 def connect_to_host(self, host):
     address = zmq_address.get_tcp_direct_address(
         host.decode('utf-8') if six.PY3 and
         isinstance(host, six.binary_type) else host
     )
     self.connect_to_address(address)
Beispiel #10
0
 def connect_to_host(self, host):
     address = zmq_address.get_tcp_direct_address(host)
     self.connect_to_address(address)
 def _resolve_host_address(self, target, timeout=0):
     host = self.matchmaker.get_single_host(
         target, zmq_names.socket_type_str(zmq.ROUTER), timeout)
     return zmq_address.get_tcp_direct_address(host)
 def on_publishers(self, publishers):
     for host, sync in publishers:
         self.socket.connect(zmq_address.get_tcp_direct_address(host))
     LOG.debug("[%s] SUB consumer connected to publishers %s",
               self.socket.handle.identity, publishers)
 def _update_connection(self):
     publishers = self.matchmaker.get_publishers()
     for host, sync in publishers:
         self.socket.connect(zmq_address.get_tcp_direct_address(host))
     LOG.debug("[%s] SUB consumer connected to publishers %s",
               self.socket.handle.identity, publishers)
 def on_publishers(self, publishers):
     for host, sync in publishers:
         self.socket.connect(zmq_address.get_tcp_direct_address(host))
     LOG.debug("[%s] SUB consumer connected to publishers %s",
               self.socket.handle.identity, publishers)
Beispiel #15
0
 def _resolve_host_address(self, target, timeout=0):
     host = self.matchmaker.get_single_host(target, timeout)
     return zmq_address.get_tcp_direct_address(host)
Beispiel #16
0
 def connect_to_host(self, host):
     address = zmq_address.get_tcp_direct_address(host)
     self.connect_to_address(address)
Beispiel #17
0
 def _connect_to_host(self, socket, host, target):
     address = zmq_address.get_tcp_direct_address(host)
     self._connect_to_address(socket, address, target)
 def _connect_to_host(self, socket, host, target):
     address = zmq_address.get_tcp_direct_address(host)
     self._connect_to_address(socket, address, target)
 def _resolve_host_address(self, target, timeout=0):
     host = self.matchmaker.get_single_host(target, timeout)
     return zmq_address.get_tcp_direct_address(host)