Пример #1
0
class DBCheck(object):

    def __init__(self, port):
        self.port = port
        self.client = DBClient(host='0.0.0.0', port=self.port)


    def put(self):
        print "########## Put ###########"
        user = {
            'name': 'Foo Bar - 1',
            'email': '*****@*****.**'
        }
        key = '*****@*****.**'
        print "Put Request:\n", key, user
        resp = self.client.put(key, user)
        print "Put Response:\n%s" % resp
        return resp.id
        

    def get(self, id=None):
        print "########## Get ###########"
        resp = self.client.get(id)
        print "Get Response:\n%s" % resp


    def info(self):
        print "########## Info ###########"
        resp = self.client.info()
        print "Info Response:\n%s" %resp
Пример #2
0
 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:]))
Пример #3
0
    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))
Пример #4
0
 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
Пример #5
0
 def __init__(self, port):
     self.port = port
     self.client = DBClient(host='0.0.0.0', port=self.port)
Пример #6
0
 def setupDB(self, port):
     self.client = DBClient(host='0.0.0.0', port=int(port))