def run(workload, prevWorkload=None): rabbitHelper = run.rabbitHelper cache = WorkloadCacher() workload.active = True cache.store(workload) bucket = str(workload.bucket) task_queue = workload.task_queue inflight = 0 while workload.active: if inflight < 20: # read doc template template = TemplateCacher().template(str(workload.template)) if template != None: if workload.cc_queues is not None: # override template attribute with workload template.cc_queues = workload.cc_queues # read workload settings bucket = workload.bucket ops_sec = workload.ops_per_sec create_count = int(ops_sec * workload.create_perc / 100) update_count = int(ops_sec * workload.update_perc / 100) get_count = int(ops_sec * workload.get_perc / 100) del_count = int(ops_sec * workload.del_perc / 100) consume_queue = workload.consume_queue generate_pending_tasks.delay(task_queue, template, bucket, create_count, update_count, get_count, del_count, consume_queue) inflight = inflight + 1 else: inflight = rabbitHelper.qsize(task_queue) time.sleep(1) workload = cache.workload(workload.id) return workload
def run(workload, prevWorkload = None): rabbitHelper = run.rabbitHelper cache = WorkloadCacher() workload.active = True cache.store(workload) bucket = str(workload.bucket) task_queue = workload.task_queue inflight = 0 while workload.active: if inflight < 20: # read doc template template = TemplateCacher().template(str(workload.template)) if template != None: if workload.cc_queues is not None: # override template attribute with workload template.cc_queues = workload.cc_queues # read workload settings bucket = workload.bucket ops_sec = workload.ops_per_sec create_count = int(ops_sec * workload.create_perc/100) update_count = int(ops_sec * workload.update_perc/100) get_count = int(ops_sec * workload.get_perc/100) del_count = int(ops_sec * workload.del_perc/100) consume_queue = workload.consume_queue generate_pending_tasks.delay(task_queue, template, bucket, create_count, update_count, get_count, del_count, consume_queue) inflight = inflight + 1 else: inflight = rabbitHelper.qsize(task_queue) time.sleep(1) workload = cache.workload(workload.id) return workload
def postcondition_handler(): cache = WorkloadCacher() for workload in cache.workloads: if workload.postconditions and workload.active: bucket = workload.bucket bs = BucketStatusCacher().bucketstatus(bucket) bs.block(bucket) BucketStatusCacher().store(bs) stat_checker = StatChecker(cfg.COUCHBASE_IP +":"+cfg.COUCHBASE_PORT, bucket = bucket, username = cfg.COUCHBASE_USER, password = cfg.COUCHBASE_PWD) status = stat_checker.check(workload.postconditions) if status == True: # unblock bucket and deactivate workload bs = BucketStatusCacher().bucketstatus(bucket) bs.unblock(bucket) BucketStatusCacher().store(bs) workload.active = False cache.store(workload)
def postcondition_handler(): cache = WorkloadCacher() for workload in cache.workloads: if workload.postconditions and workload.active: bucket = workload.bucket bs = BucketStatusCacher().bucketstatus(bucket) bs.block(bucket) BucketStatusCacher().store(bs) stat_checker = StatChecker(cfg.COUCHBASE_IP + ":" + cfg.COUCHBASE_PORT, bucket=bucket, username=cfg.COUCHBASE_USER, password=cfg.COUCHBASE_PWD) status = stat_checker.check(workload.postconditions) if status == True: # unblock bucket and deactivate workload bs = BucketStatusCacher().bucketstatus(bucket) bs.unblock(bucket) BucketStatusCacher().store(bs) workload.active = False cache.store(workload)