예제 #1
0
        def _cs_client():
            cs_client_inst = config_store_client.ConfigStoreClient(
                zmq.Context(), "ipc:///tmp/config_store_cmd")

            self.assertEqual(cs_client_inst.load('key1'), store_db['key1'])
            with self.assertRaises(Exception):
                cs_client_inst.load('key3')

            self.assertTrue(cs_client_inst.erase('key1'))
            with self.assertRaises(Exception):
                cs_client_inst.load('key1')

            value = serialize_thrift_object(
                lm_types.DumpLinksReply(thisNodeName='node5'))
            self.assertTrue(cs_client_inst.store('key5', value))
            self.assertEqual(cs_client_inst.load('key5'), value)
예제 #2
0
        def _cs_client():
            cs_client_inst = config_store_client.ConfigStoreClient(
                ctx, "inproc://openr_config_store_cmd")

            self.assertEqual(cs_client_inst.load("key1"), store_db["key1"])
            with self.assertRaises(Exception):
                cs_client_inst.load("key3")

            self.assertTrue(cs_client_inst.erase("key1"))
            with self.assertRaises(Exception):
                cs_client_inst.load("key1")

            value = serialize_thrift_object(
                lm_types.DumpLinksReply(thisNodeName="node5"))
            self.assertTrue(cs_client_inst.store("key5", value))
            self.assertEqual(cs_client_inst.load("key5"), value)
예제 #3
0
from __future__ import unicode_literals
from __future__ import division

from openr.utils import socket
from openr.utils.serializer import serialize_thrift_object
from openr.clients import config_store_client
from openr.PersistentStore import ttypes as ps_types
from openr.LinkMonitor import ttypes as lm_types

import zmq
import unittest
from multiprocessing import Process

store_db = {
    'key1':
    serialize_thrift_object(lm_types.DumpLinksReply(thisNodeName='node1')),
    'key2':
    serialize_thrift_object(lm_types.DumpLinksReply(thisNodeName='node2'))
}


class ConfigStore():
    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

    def process_request(self):
        req = self._cs_server_socket.recv_thrift_obj(ps_types.StoreRequest)

        if req.requestType == ps_types.StoreRequestType.LOAD:
예제 #4
0
# LICENSE file in the root directory of this source tree.
#

from __future__ import absolute_import, division, print_function, unicode_literals

import unittest
from builtins import object, range
from multiprocessing import Process

import bunch
import zmq
from openr.clients import lm_client
from openr.LinkMonitor import ttypes as lm_types
from openr.utils import zmq_socket

dump_links_cache = lm_types.DumpLinksReply()
dump_links_cache.thisNodeName = "san jose 1"


class LM(object):
    def __init__(self, zmq_ctx, url):
        self._lm_server_socket = zmq_socket.ZmqSocket(zmq_ctx, zmq.DEALER)
        self._lm_server_socket.bind(url)
        self._dump_links_cache = dump_links_cache

    def _dump_links(self, request):

        return self._dump_links_cache

    def process_request(self):
        request = self._lm_server_zmq_socket.recv_thrift_obj(