Beispiel #1
0
 def __init__(self):
     self.localstore = {}
     self.started = False        
     self.storage = storage_factory.get("dht") # TODO: read storage type from config?
     self.coder = message_coder_factory.get("json")  # TODO: always json?
     self.flush_delayedcall = None
     self.flush_timout = 1
Beispiel #2
0
 def __init__(self):
     self.localstore = {}
     self.localstore_sets = {}
     self.started = False        
     self.storage = storage_factory.get("dht") # TODO: read storage type from config?
     self.coder = message_coder_factory.get("json")  # TODO: always json? append/remove requires json at the moment
     self.flush_delayedcall = None
     self.flush_timout = 1
Beispiel #3
0
 def __init__(self):
     self.localstore = {}
     self.started = False
     self.storage = storage_factory.get(
         "dht")  # TODO: read storage type from config?
     self.coder = message_coder_factory.get("json")  # TODO: always json?
     self.flush_delayedcall = None
     self.flush_timout = 1
Beispiel #4
0
 def __init__(self, node):
     self.localstore = {}
     self.localstore_sets = {}
     self.started = False
     self.node = node
     proxy = _conf.get(None, 'storage_proxy')
     _log.analyze(self.node.id, "+", {'proxy': proxy})
     self.tunnel = {}
     starting = _conf.get(None, 'storage_start')
     self.storage = storage_factory.get("proxy" if proxy else "dht", node) if starting else None
     self.coder = message_coder_factory.get("json")  # TODO: always json? append/remove requires json at the moment
     self.flush_delayedcall = None
     self.reset_flush_timeout()
Beispiel #5
0
 def __init__(self, node):
     self.localstore = {}
     self.localstore_sets = {}
     self.started = False
     self.node = node
     storage_type = _conf.get(None, 'storage_type')
     self.proxy = _conf.get(None, 'storage_proxy') if storage_type == 'proxy' else None
     _log.analyze(self.node.id, "+", {'proxy': self.proxy})
     self.tunnel = {}
     self.starting = storage_type != 'local'
     self.storage = storage_factory.get(storage_type, node)
     self.coder = message_coder_factory.get("json")  # TODO: always json? append/remove requires json at the moment
     self.flush_delayedcall = None
     self.reset_flush_timeout()
    def _create_servers(self, count, extra_uris=None):
        #import logging
        #calvinlogger.get_logger().setLevel(logging.DEBUG)
        #calvinlogger.get_logger().setLevel(1)

        if hasattr(self, '_networks') and self._networks:
            raise Exception("Trying to create multiple times without stop!")

        if not extra_uris:
            extra_uris = []

        self._networks = []
        self._ports = []
        _conf.set('global', 'storage_type', 'test_local')
        #_conf.set('global', 'storage_proxy', 'local')
        global_storage = storage_factory.get("test_local", None)

        for a in range(count):
            node1 = create_node(global_storage)
            network1 = CalvinNetwork(node1)

            cb, d = create_callback()
            node1.storage.start(cb=cb)
            res = yield d
            assert res[0][0]

            for fname in ['_join_finished', '_join_failed', '_server_started', '_server_stopped', '_recv_handler', '_peer_connection_failed', '_peer_disconnected']:
                _o = getattr(network1, fname)
                setattr(network1, fname, snoop_f(_o))
            assert network1._server_started.call_count == 0

            network1.register(['calvinip'], ['json'])
            network1.start_listeners()

            # Wait for everything to settle
            start = network1._server_started.side_effect_ds[-1]
            yield start

            #yield threads.deferToThread(time.sleep, .05)
            assert network1._server_started.call_count == 1

            # get listening ports
            net1_port = network1._server_started.call_args[0][1]
            node1._set_uris(node1, extra_uris + ["calvinip://127.0.0.1:%s" % net1_port], -1)
            cb, d = create_callback()
            node1.storage.add_node(node1, cb=CalvinCB(cb))
            res = yield d
            assert res[1]['value']
            self._networks.append(network1)
            self._ports.append(net1_port)