Ejemplo n.º 1
0
    def test_status_conflicts(self):
        zmq_ctx = zmq.Context()
        bind_socket = socket.Socket(zmq_ctx, zmq.REP)
        bind_socket.bind("inproc://status_test")
        with self.assertRaises(Exception):
            bind_socket.connect("inproc://status_test")

        connect_socket = socket.Socket(zmq_ctx, zmq.REP)
        connect_socket.connect("inproc://status_test")
        with self.assertRaises(Exception):
            connect_socket.bind("inproc://status_test")
Ejemplo n.º 2
0
    def test_pub_sub(self):
        zmq_ctx = zmq.Context()
        pub_socket = socket.Socket(zmq_ctx, zmq.PUB)
        pub_socket.bind("inproc://req_rep_test")
        sub_socket = socket.Socket(zmq_ctx, zmq.SUB)
        sub_socket.connect("inproc://req_rep_test")
        sub_socket.set_sock_opt(zmq.SUBSCRIBE, b"")

        thrift_obj = lsdb_types.PrefixDatabase()
        thrift_obj.thisNodeName = 'some node'

        pub_socket.send_thrift_obj(thrift_obj)
        recv_obj = sub_socket.recv_thrift_obj(lsdb_types.PrefixDatabase)
        self.assertEqual(thrift_obj, recv_obj)
Ejemplo n.º 3
0
    def test_req_rep(self):
        zmq_ctx = zmq.Context()
        rep_socket = socket.Socket(zmq_ctx, zmq.REP)
        rep_socket.bind("inproc://req_rep_test")
        req_socket = socket.Socket(zmq_ctx, zmq.REQ)
        req_socket.connect("inproc://req_rep_test")

        thrift_obj = lsdb_types.PrefixDatabase()
        thrift_obj.thisNodeName = 'some node'

        req_socket.send_thrift_obj(thrift_obj)
        recv_obj = rep_socket.recv_thrift_obj(lsdb_types.PrefixDatabase)
        self.assertEqual(thrift_obj, recv_obj)
        rep_socket.send_thrift_obj(recv_obj)
        recv_obj = req_socket.recv_thrift_obj(lsdb_types.PrefixDatabase)
        self.assertEqual(thrift_obj, recv_obj)
Ejemplo n.º 4
0
    def test_dealer_dealer(self):
        zmq_ctx = zmq.Context()
        d_socket_1 = socket.Socket(zmq_ctx, zmq.DEALER)
        d_socket_1.bind("inproc://dealer_test")
        d_socket_2 = socket.Socket(zmq_ctx, zmq.DEALER)
        d_socket_2.connect("inproc://dealer_test")

        thrift_obj = lsdb_types.PrefixDatabase()
        thrift_obj.thisNodeName = 'some node'

        d_socket_1.send_thrift_obj(thrift_obj)
        recv_obj = d_socket_2.recv_thrift_obj(lsdb_types.PrefixDatabase)
        self.assertEqual(thrift_obj, recv_obj)
        d_socket_2.send_thrift_obj(recv_obj)
        recv_obj = d_socket_1.recv_thrift_obj(lsdb_types.PrefixDatabase)
        self.assertEqual(thrift_obj, recv_obj)
Ejemplo n.º 5
0
 def __init__(self,
              zmq_ctx,
              decision_cmd_url,
              timeout=consts.Consts.TIMEOUT_MS,
              proto_factory=consts.Consts.PROTO_FACTORY):
     self._decision_cmd_socket = socket.Socket(zmq_ctx, zmq.REQ, timeout,
                                               proto_factory)
     self._decision_cmd_socket.connect(decision_cmd_url)
Ejemplo n.º 6
0
 def __init__(self,
              zmq_ctx,
              fib_rep_port,
              timeout=consts.Consts.TIMEOUT_MS,
              proto_factory=consts.Consts.PROTO_FACTORY):
     self._fib_cmd_socket = socket.Socket(zmq_ctx, zmq.REQ, timeout,
                                          proto_factory)
     self._fib_cmd_socket.connect(fib_rep_port)
Ejemplo n.º 7
0
 def _send_recv():
     req_socket = socket.Socket(zmq.Context(), zmq.REQ)
     req_socket.connect("tcp://localhost:5000")
     req_socket.send_thrift_obj(thrift_obj)
     print("request sent")
     recv_obj = req_socket.recv_thrift_obj(lsdb_types.PrefixDatabase)
     print("reply received")
     self.assertEqual(thrift_obj, recv_obj)
Ejemplo n.º 8
0
 def __init__(self, zmq_ctx, url):
     self._prefix_mgr_server_socket = socket.Socket(zmq_ctx, zmq.REP)
     self._prefix_mgr_server_socket.bind(url)
     self._prefix_map = {
         sprint_prefix(prefix_entry1.prefix): prefix_entry1,
         sprint_prefix(prefix_entry2.prefix): prefix_entry2,
         sprint_prefix(prefix_entry3.prefix): prefix_entry3
     }
Ejemplo n.º 9
0
 def _recv_send():
     rep_socket = socket.Socket(zmq.Context(), zmq.REP)
     rep_socket.bind("tcp://*:5000")
     recv_obj = rep_socket.recv_thrift_obj(lsdb_types.PrefixDatabase)
     print("request received")
     self.assertEqual(thrift_obj, recv_obj)
     rep_socket.send_thrift_obj(recv_obj)
     print("reply sent")
Ejemplo n.º 10
0
 def __init__(self,
              zmq_ctx,
              cs_cmd_url,
              timeout=consts.Consts.TIMEOUT_MS,
              proto_factory=TCompactProtocolFactory):
     self._cs_cmd_socket = socket.Socket(zmq_ctx, zmq.REQ, timeout,
                                         proto_factory)
     self._cs_cmd_socket.connect(cs_cmd_url)
Ejemplo n.º 11
0
 def __init__(self,
              zmq_ctx,
              health_checker_cmd_port,
              timeout=consts.Consts.TIMEOUT_MS,
              proto_factory=consts.Consts.PROTO_FACTORY):
     self._health_checker_cmd_socket = socket.Socket(
         zmq_ctx, zmq.REQ, timeout, proto_factory)
     self._health_checker_cmd_socket.connect(health_checker_cmd_port)
Ejemplo n.º 12
0
 def __init__(self,
              zmq_ctx,
              lm_cmd_url,
              timeout=consts.Consts.TIMEOUT_MS,
              proto_factory=consts.Consts.PROTO_FACTORY):
     self._lm_cmd_socket = socket.Socket(zmq_ctx, zmq.DEALER, timeout,
                                         proto_factory)
     self._lm_cmd_socket.connect(lm_cmd_url)
Ejemplo n.º 13
0
    def __init__(self,
                 zmq_ctx,
                 kv_store_pub_url,
                 proto_factory=TCompactProtocolFactory):

        # timeout set as -1 for indefinite blocking
        self._kv_store_sub_socket = socket.Socket(zmq_ctx, zmq.SUB, -1,
                                                  proto_factory)
        self._kv_store_sub_socket.connect(kv_store_pub_url)
        self._kv_store_sub_socket.set_sock_opt(zmq.SUBSCRIBE, b"")
Ejemplo n.º 14
0
 def __init__(
     self,
     zmq_ctx,
     prefix_mgr_cmd_url,
     timeout=consts.Consts.TIMEOUT_MS,
     proto_factory=consts.Consts.PROTO_FACTORY,
 ):
     self._prefix_mgr_cmd_socket = socket.Socket(zmq_ctx, zmq.REQ, timeout,
                                                 proto_factory)
     self._prefix_mgr_cmd_socket.connect(prefix_mgr_cmd_url)
Ejemplo n.º 15
0
    def __init__(self,
                 zmq_ctx,
                 kv_store_pub_url,
                 proto_factory=consts.Consts.PROTO_FACTORY):

        # timeout set as -1 for indefinite blocking
        self._kv_store_sub_socket = socket.Socket(zmq_ctx, zmq.SUB, -1,
                                                  proto_factory)
        self._kv_store_sub_socket.connect(kv_store_pub_url)
        self._kv_store_sub_socket.set_sock_opt(zmq.SUBSCRIBE, b"")
Ejemplo n.º 16
0
    def __init__(
        self,
        zmq_ctx,
        monitor_pub_url,
        timeout=-1,
        proto_factory=consts.Consts.PROTO_FACTORY,
    ):

        # timeout set as -1 for indefinite blocking
        self._monitor_sub_socket = socket.Socket(zmq_ctx, zmq.SUB, timeout,
                                                 proto_factory)
        self._monitor_sub_socket.connect(monitor_pub_url)
        self._monitor_sub_socket.set_sock_opt(zmq.SUBSCRIBE, b"")
Ejemplo n.º 17
0
    def run(self, yes):

        if not yes:
            yes = utils.yesno("Are you sure to trigger Open/R crash")

        if not yes:
            print("Not triggering force crash")
            return

        print("Triggering force crash")
        sock = socket.Socket(self.cli_opts.zmq_ctx, zmq.REQ, timeout=200)
        sock.set_sock_opt(zmq.LINGER, 1000)
        sock.connect(consts.Consts.FORCE_CRASH_SERVER_URL)
        sock.send("User {} issuing crash command".format(os.environ["USER"]))
        sock.close()
Ejemplo n.º 18
0
 def __init__(self, zmq_ctx, monitor_cmd_url, timeout=consts.Consts.TIMEOUT_MS,
              proto_factory=TCompactProtocolFactory):
     self._monitor_cmd_socket = socket.Socket(zmq_ctx, zmq.DEALER, timeout,
                                               proto_factory)
     self._monitor_cmd_socket.connect(monitor_cmd_url)
Ejemplo n.º 19
0
 def __init__(self, zmq_ctx, url):
     self._lm_server_socket = socket.Socket(zmq_ctx, zmq.DEALER)
     self._lm_server_socket.bind(url)
     self._dump_links_cache = dump_links_cache
Ejemplo n.º 20
0
 def __init__(self, zmq_ctx, url):
     self._monitor_server_socket = socket.Socket(zmq_ctx, zmq.DEALER)
     self._monitor_server_socket.bind(url)
     self._monitor_cache = monitor_cache
Ejemplo n.º 21
0
 def __init__(self, zmq_ctx, url):
     self._kv_store_server_socket = socket.Socket(zmq_ctx, zmq.REP)
     self._kv_store_server_socket.bind(url)
     self._kv_store = kv_store_cache
Ejemplo n.º 22
0
 def __init__(self, zmq_ctx, url):
     self._kv_store_publisher_socket = socket.Socket(zmq_ctx, zmq.PUB)
     self._kv_store_publisher_socket.bind(url)
Ejemplo n.º 23
0
 def __init__(self, zmq_ctx, url):
     self._decision_server_socket = socket.Socket(zmq_ctx, zmq.REP)
     self._decision_server_socket.bind(url)
     self._route_db_cache = route_db_cache
     self._adj_db_cachee = adj_dbs_cache
     self._prefix_db_cache = prefix_dbs_cache
Ejemplo n.º 24
0
 def __init__(self, zmq_ctx, url):
     self._fib_server_socket = socket.Socket(zmq_ctx, zmq.REP)
     self._fib_server_socket.bind(url)
     self._route_db_cache = route_db_cache
Ejemplo n.º 25
0
 def __init__(self, zmq_ctx, url):
     self._cs_server_socket = socket.Socket(zmq_ctx, zmq.REP)
     self._cs_server_socket.bind(url)
     self._store_db = store_db