1#this script will run until stopped. it will set keys with small/large values
2# python scripts/mixedload.py -p expiry=10,count=10000,prefix=something,size=1024
3
4
5
6import sys
7import uuid
8
9sys.path.append('.')
10sys.path.append('lib')
11import TestInput
12from memcached.helper.data_helper import MemcachedClientHelper, VBucketAwareMemcached
13from membase.api.rest_client import RestConnection
14
15
16if __name__ == "__main__":
17    try:
18        input = TestInput.TestInputParser.get_test_input(sys.argv)
19        server = input.servers[0]
20        params = input.test_params
21        count = 0
22        prefix = str(uuid.uuid4())[:6]
23        count = 10 * 1000 * 1000 * 1000
24        size = 512
25        expiry = 0
26        if "count" in params:
27            count = int(params["count"])
28            print count
29        if "size" in params:
30            size = int(params["size"])
31        if "prefix" in params:
32            prefix = params["prefix"]
33        #if "expiry" in params:
34        #    expiry = int(params["expiry"])
35        payload = MemcachedClientHelper.create_value('*', size)
36        rest = RestConnection(server)
37        buckets = rest.get_buckets()
38        for bucket in buckets:
39            smart = VBucketAwareMemcached(rest, bucket.name)
40            mc = MemcachedClientHelper.proxy_client(server, bucket.name)
41            i = 0
42            while i < count:
43                try:
44                    key = "{0}-{1}".format(prefix, i)
45                    #mc = smart.memcached(key)
46                    #do an expiry every 10 times
47                    mc.set(key, 0, 0, payload)
48                    #mc.get(key)
49                    i += 1
50                except Exception as ex:
51                    #print ex
52                    #we need to initialize smart client
53                    #smart.done()
54                    #smart = VBucketAwareMemcached(rest, bucket.name)
55                    mc = MemcachedClientHelper.proxy_client(server, bucket.name)
56
57    except Exception as ex:
58        print ex
59
60
61
62
63