Exemple #1
0
    def test_buckets_storefreq(self):
        bkts = buckets.Buckets(2, [(5, 1), (4, 4)],
                               bucket_destructor=self.delete_mybucket)

        bkts.buckets_add_element(10)
        bkts.buckets_add_element(20)
        bkts.buckets_add_element(30)
        bkts.buckets_add_element(40)
        bkts.buckets_add_element(50)
        bkts.buckets_add_element(60)
        bkts.buckets_add_element(70)
        bkts.buckets_add_element(80)
        bkts.buckets_add_element(90)
        bkts.buckets_add_element(100)
        bkts.buckets_add_element(110)
        bkts.buckets_add_element(120)
        bkts.buckets_add_element(130)
        bkts.buckets_add_element(140)
        bkts.buckets_add_element(150)
        bkts.buckets_add_element(160)
        bkts.buckets_add_element(170)
        bkts.buckets_add_element(180)
        bkts.buckets_add_element(190)
        bkts.buckets_add_element(200)
        bkts.buckets_add_element(210)
        bkts.buckets_add_element(220)
        bkts.buckets_add_element(230)
        bkts.buckets_add_element(240)

        pp = pprint.PrettyPrinter(indent=1)
        pp.pprint(bkts.buckets)
Exemple #2
0
    def get_bucketlist(self, server, port, user, password, opts):
        try:
            bucketlist = buckets.Buckets().runCmd('bucket-get', server, port, user, password, opts)
            for bucket in bucketlist:
                bucket_name = bucket['name']
                self.log.info("bucket: %s" % bucket_name)
                bucketinfo = {}
                bucketinfo['name'] = bucket_name
                bucketinfo['bucketType'] = bucket['bucketType']
                bucketinfo['authType'] = bucket['authType']
                bucketinfo['saslPassword'] = bucket['saslPassword']
                bucketinfo['numReplica'] = bucket['replicaNumber']
                bucketinfo['ramQuota'] = bucket['quota']['ram']
                bucketinfo['master'] = server

                bucketStats = bucket['basicStats']
                bucketinfo['bucketStats'] = {}
                bucketinfo['bucketStats']['diskUsed'] = bucketStats['diskUsed']
                bucketinfo['bucketStats']['memUsed'] = bucketStats['memUsed']
                bucketinfo['bucketStats']['diskFetches'] = bucketStats['diskFetches']
                bucketinfo['bucketStats']['quotaPercentUsed'] = bucketStats['quotaPercentUsed']
                bucketinfo['bucketStats']['opsPerSec'] = bucketStats['opsPerSec']
                bucketinfo['bucketStats']['itemCount'] = bucketStats['itemCount']

                stats_buffer.bucket_info[bucket_name] = bucketinfo

                # get bucket related stats
                c = buckets.BucketStats(bucket_name)
                json = c.runCmd('bucket-stats', server, port, user, password, opts)
                stats_buffer.buckets_summary[bucket_name] = json
            return bucketlist
        except Exception, err:
            traceback.print_exc()
            sys.exit(1)
Exemple #3
0
    def test_basic_bucket(self):
        print "Test basic bucket"
        bkts = buckets.Buckets(2, [(5, 1), (4, 1)])
        self.failUnless(bkts is not None)

        pp = pprint.PrettyPrinter(indent=1)
        pp.pprint(bkts.buckets)
Exemple #4
0
    def test_buckets_buckets_destructor(self):
        bkts = buckets.Buckets(2, [(5, 1), (4, 1)],
                               bucket_destructor=self.delete_mybucket)

        bkts.buckets_add_element(10)
        bkts.buckets_add_element(20)
        bkts.buckets_add_element(30)
        bkts.buckets_add_element(40)
        bkts.buckets_add_element(50)
        bkts.buckets_add_element(60)
        bkts.buckets_add_element(70)
        bkts.buckets_add_element(80)
        bkts.buckets_add_element(90)
        bkts.buckets_add_element(100)
        bkts.buckets_add_element(110)
        bkts.buckets_add_element(120)
        bkts.buckets_add_element(130)
        bkts.buckets_add_element(140)
        bkts.buckets_add_element(150)
        bkts.buckets_add_element(160)
        bkts.buckets_add_element(170)
Exemple #5
0
    def test_buckets_get_element(self):
        bkts = buckets.Buckets(2, [(5, 1), (4, 1)])

        bkts.buckets_add_element(10)
        bkts.buckets_add_element(20)

        elem = bkts.buckets_get_element()
        self.failUnless(elem == 20)

        bkts.buckets_add_element(30)
        bkts.buckets_add_element(40)
        bkts.buckets_add_element(50)

        elem = bkts.buckets_get_element()
        print "Elem: ", elem

        bkts.buckets_add_element(60)
        bkts.buckets_add_element(70)
        bkts.buckets_add_element(80)

        elem = bkts.buckets_get_element()
        print "Elem: ", elem
    def __init__(self,
                 request_q,
                 response_q,
                 err_q,
                 server_address,
                 handler_class=KademliaProtocolRequestHandler):
        self.logger = logging.getLogger('KademliaProtocolServer')
        self.logger.debug('__init__')
        self.thread_name = 'KademliaProtocolServer'
        self.request_q = request_q
        self.response_q = response_q
        self.err_q = err_q
        # TODO: change 20 to a global constant K
        self.buckets = buckets.Buckets(256, 1)
        self.data_server = DataServer()

        self.kbuckets_maintainer = Thread(target=kbuckets_maintainer,
                                          args=(self.buckets, self.err_q))
        self.kbuckets_maintainer.start()

        SocketServer.UDPServer.__init__(self, server_address, handler_class)
        SocketServer.UDPServer.allow_reuse_address = True
Exemple #7
0
    def test_buckets_add(self):
        bkts = buckets.Buckets(2, [(5, 1), (4, 1)])

        bkts.buckets_add_element(10)
        bkts.buckets_add_element(20)
        bkts.buckets_add_element(30)
        bkts.buckets_add_element(40)
        bkts.buckets_add_element(50)
        bkts.buckets_add_element(60)
        bkts.buckets_add_element(70)
        bkts.buckets_add_element(80)
        bkts.buckets_add_element(90)
        bkts.buckets_add_element(100)
        bkts.buckets_add_element(110)
        bkts.buckets_add_element(120)
        bkts.buckets_add_element(130)
        bkts.buckets_add_element(140)
        bkts.buckets_add_element(150)
        bkts.buckets_add_element(160)
        bkts.buckets_add_element(170)

        pp = pprint.PrettyPrinter(indent=1)
        pp.pprint(bkts.buckets)