def __init__(self, db_servers=None): """ 1. Initialize the super/parent RendezvousHash class. Class inheritance@http://www.python-course.eu/python3_inheritance.php 2. Create DBClient instance for all servers and save them in a dictionary. :param db_servers: a list of DB servers: ['0.0.0.0:3000', '0.0.0.0:3001', '0.0.0.0:3002'] """ RendezvousHash.__init__(self, db_servers) self.db_servers = {} for db in db_servers: self.db_servers[db] = DBClient('0.0.0.0', int(db[-4:]))
def __init__(self, db_servers=None): """ 1. Initialize the super/parent RendezvousHash class. Class inheritance@http://www.python-course.eu/python3_inheritance.php 2. Create DBClient instance for all servers and save them in a dictionary. :param db_servers: a list of DB servers: ['0.0.0.0:3000', '0.0.0.0:3001', '0.0.0.0:3002'] """ self.db_servers = db_servers self.db_clients = {} self.ring = RendezvousHash(nodes=self.db_servers) for server in self.db_servers: [host, port] = server.split(":") self.db_clients[server] = DBClient(host=host, port=int(port))
def __init__(self, db_servers=None): """ 1. Initialize the super/parent RendezvousHash class. Class inheritance@http://www.python-course.eu/python3_inheritance.php 2. Create DBClient instance for all servers and save them in a dictionary. :param db_servers: a list of DB servers: ['0.0.0.0:3000', '0.0.0.0:3001', '0.0.0.0:3002'] """ # TODO super(RendezvousHashDBClient, self).__init__(db_servers) #RendezvousHash.__init__(db_servers) self.dbclient_dict = {} for server in db_servers: host = server.split(':')[0] print server.split(':')[0] print server.split(':')[1] port = (int)(server.split(':')[1]) client = DBClient(host=host, port=port) self.dbclient_dict[server] = client
def __init__(self, port): self.port = port self.client = DBClient(host='0.0.0.0', port=self.port)
def setupDB(self, port): self.client = DBClient(host='0.0.0.0', port=int(port))