예제 #1
0
    def __init__(self, name, task, e):
        threading.Thread.__init__(self)
        self.name = name
        self.i = 0
        self.op_factor = CLIENTSPERPROCESS * PROCSPERTASK
        self.ops_sec = task['ops_sec']
        self.bucket = task['bucket']
        self.password = task['password']
        self.template = task['template']
        self.default_tsizes = [128, 256]
        self.create_count = task['create_count'] / self.op_factor
        self.update_count = task['update_count'] / self.op_factor
        self.get_count = task['get_count'] / self.op_factor
        self.del_count = task['del_count'] / self.op_factor
        self.exp_count = task['exp_count'] / self.op_factor
        self.ttl = task['ttl']
        self.miss_perc = task['miss_perc']
        self.active_hosts = task['active_hosts']
        self.batch_size = 5000
        self.memq = queue.Queue()
        self.consume_queue = task['consume_queue']
        self.standalone = task['standalone']
        self.ccq = None
        self.hotkey_batches = []

        if self.consume_queue is not None:
            RabbitHelper().declare(self.consume_queue)

        if task['template']['cc_queues']:
            self.ccq = str(
                task['template']['cc_queues'][0])  #only supporting 1 now
            RabbitHelper().declare(self.ccq)

        if self.batch_size > self.create_count:
            self.batch_size = self.create_count

        self.active_hosts = task['active_hosts']
        if not self.active_hosts:
            self.active_hosts = [cfg.COUCHBASE_IP]

        addr = task['active_hosts'][random.randint(0,
                                                   len(self.active_hosts) -
                                                   1)].split(':')
        host = addr[0]
        port = 8091
        if len(addr) > 1:
            port = addr[1]

        self.e = e
        self.cb = None
        self.isterminal = False
        self.done = False

        try:
            endpoint = "%s:%s/%s" % (host, port, self.bucket)
            self.cb = Bucket(endpoint, password=self.password)
        except Exception as ex:
            logging.error("[Thread %s] cannot reach %s" %
                          (self.name, endpoint))
            logging.error(ex)
            self.isterminal = True

        logging.info("[Thread %s] started for workload: %s" %
                     (self.name, task['id']))
예제 #2
0
                default=None,
                type=str,
                help="Use Pure-Python IOPS plugin")
ap.add_argument('-g',
                '--global-instance',
                help="Use global instance",
                default=False,
                action='store_true')
ap.add_argument('--batch', '-N', type=int, help="Batch size", default=1)

options = ap.parse_args()

GLOBAL_INSTANCE = None
CONN_OPTIONS = {'connstr': options.connstr, 'password': options.password}

GLOBAL_INSTANCE = Bucket(**CONN_OPTIONS)


def make_instance():
    if options.global_instance:
        return GLOBAL_INSTANCE
    else:
        return Bucket(**CONN_OPTIONS)


class Worker(object):
    def __init__(self):
        self.delay = options.delay
        self.key = 'K' * options.ksize
        self.value = b'V' * options.vsize
        self.kv = {}
예제 #3
0
def make_instance():
    if options.global_instance:
        return GLOBAL_INSTANCE
    else:
        return Bucket(**CONN_OPTIONS)
예제 #4
0
    def __init__(self, name, task, e):
        threading.Thread.__init__(self)
        self.name = name
        self.i = 0
        self.op_factor = CLIENTSPERPROCESS * PROCSPERTASK
        self.ops_sec = task['ops_sec']
        self.bucket = task['bucket']
        self.password = task['password']
        self.user_password = task['user_password']
        self.template = task['template']
        self.default_tsizes = task['sizes']
        self.create_count = task['create_count'] / self.op_factor
        self.update_count = task['update_count'] / self.op_factor
        self.get_count = task['get_count'] / self.op_factor
        self.del_count = task['del_count'] / self.op_factor
        self.exp_count = task['exp_count'] / self.op_factor
        self.ttl = task['ttl']
        self.persist_to = task['persist_to']
        self.replicate_to = task['replicate_to']
        self.miss_perc = task['miss_perc']
        self.active_hosts = task['active_hosts']
        self.batch_size = 5000
        self.memq = queue.Queue()
        self.consume_queue = task['consume_queue']
        self.standalone = task['standalone']
        self.ccq = None
        self.hotkey_batches = []

        if self.ttl:
            self.ttl = int(self.ttl)

        if self.batch_size > self.create_count:
            self.batch_size = self.create_count

        self.active_hosts = task['active_hosts']

        addr = task['active_hosts'][random.randint(0,
                                                   len(self.active_hosts) -
                                                   1)].split(':')
        host = addr[0]
        port = 8091
        if len(addr) > 1:
            port = addr[1]

        self.e = e
        self.cb = None
        self.isterminal = False
        self.done = False

        try:
            endpoint = "%s:%s/%s" % (host, port, self.bucket)
            self.cb = Bucket(endpoint, password=self.password)

        except AuthError:
            # direct port for cluster_run
            port_mod = int(port) % 9000
            if port_mod != 8091:
                port = str(12000 + port_mod)
            # try rbac style auth
            endpoint = 'couchbase://{0}:{1}?select_bucket=true'.format(
                host, port)
            cluster = Cluster(endpoint)
            auther = PasswordAuthenticator(self.bucket, self.user_password)
            cluster.authenticate(auther)
            self.cb = cluster.open_bucket(self.bucket)

        except Exception as ex:

            logging.error("[Thread %s] cannot reach %s" %
                          (self.name, endpoint))
            logging.error(ex)
            self.isterminal = True

        logging.info("[Thread %s] started for workload: %s" %
                     (self.name, task['id']))