def setup(self, config, cache_dir): """Setup all the Khashmir sub-modules. @type config: C{dictionary} @param config: the configuration parameters for the DHT @type cache_dir: C{string} @param cache_dir: the directory to store all files in """ self.config = config self.port = config['PORT'] self.store = DB(os.path.join(cache_dir, 'khashmir.' + str(self.port) + '.db')) self.node = self._loadSelfNode('', self.port) self.table = KTable(self.node, config) self.token_secrets = [newID()] self.stats = StatsLogger(self.table, self.store) # Start listening self.udp = krpc.hostbroker(self, self.stats, config) self.udp.protocol = krpc.KRPC self.listenport = reactor.listenUDP(self.port, self.udp) # Load the routing table and begin checkpointing self._loadRoutingTable() self.refreshTable(force = True) self.next_checkpoint = reactor.callLater(60, self.checkpoint)
def setup(self, host, port, db='khashmir.db'): self._findDB(db) self.port = port self.node = self._loadSelfNode(host, port) self.table = KTable(self.node) #self.app = service.Application("krpc") self.udp = krpc.hostbroker(self) self.udp.protocol = krpc.KRPC self.listenport = reactor.listenUDP(port, self.udp) self.last = time.time() self._loadRoutingTable() KeyExpirer(store=self.store) self.refreshTable(force=1) reactor.callLater(60, self.checkpoint, (1,))
def setup(self, host, port, db='khashmir.db'): self._findDB(db) self.port = port self.node = self._loadSelfNode(host, port) self.table = KTable(self.node) #self.app = service.Application("krpc") self.udp = krpc.hostbroker(self) self.udp.protocol = krpc.KRPC self.listenport = reactor.listenUDP(port, self.udp) self.last = time.time() self._loadRoutingTable() KeyExpirer(store=self.store) self.refreshTable(force=1) reactor.callLater(60, self.checkpoint, (1, ))
def setup(self, host, port, data_dir, rlcount, checkpoint=True): self.host = host self.port = port self.ddir = data_dir self.store = KStore() self.pingcache = {} self.socket = self.rawserver.create_udpsocket(self.port, self.host, False) self.udp = krpc.hostbroker(self, (self.host, self.port), self.socket, self.rawserver.add_task, self.max_ul_rate, self.config, rlcount) self._load() self.rawserver.start_listening_udp(self.socket, self.udp) self.last = time() KeyExpirer(self.store, self.rawserver.add_task) self.refreshTable(force=1) if checkpoint: self.rawserver.add_task(self.findCloseNodes, 30, (lambda a: a, True)) self.rawserver.add_task(self.checkpoint, 60, (1,))
def setup(self, host, port, data_dir, rlcount, checkpoint=True): self.host = host self.port = port self.ddir = data_dir self.store = KStore() self.pingcache = {} self.socket = self.rawserver.create_udpsocket(self.port, self.host) self.udp = krpc.hostbroker(self, (self.host, self.port), self.socket, self.rawserver.add_task, self.max_ul_rate, self.config, rlcount) self._load() self.rawserver.start_listening_udp(self.socket, self.udp) self.last = time() KeyExpirer(self.store, self.rawserver.add_task) self.refreshTable(force=1) if checkpoint: self.rawserver.add_task(30, self.findCloseNodes, lambda a: a, True) self.rawserver.add_task(60, self.checkpoint, 1)