def task_prerun_handler(sender=None, task_id=None, task=None, args=None, kwargs=None, signal=None): if sender == run: workload = args[0] prevWorkload = args[1] if workload.preconditions is not None: # block tasks against bucket until pre-conditions met bucket = str(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) while not stat_checker.check(workload.preconditions): time.sleep(1) prevWorkload.active = False WorkloadCacher().store(prevWorkload) bs = BucketStatusCacher().bucketstatus(bucket) bs.unblock(bucket) BucketStatusCacher().store(bs)
def postcondition_handler(): workloads = CacheHelper.workloads() for workload in workloads: if workload.postconditions and workload.active: bucket = workload.bucket bs = BucketStatus.from_cache(bucket) bs.block(bucket) 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 = BucketStatus.from_cache(bucket) bs.unblock(bucket) workload.active = False
def task_prerun_handler(sender=None, task_id=None, task=None, args=None, kwargs=None, signal=None): if sender == run: workload = args[0] bucket = str(workload.bucket) stat_checker = StatChecker(cfg.COUCHBASE_IP + ":" + cfg.COUCHBASE_PORT, bucket=bucket, username=cfg.COUCHBASE_USER, password=cfg.COUCHBASE_PWD) # convert item count postcondition's to curr_item conditions if workload.postconditions: stat, cmp_type, value = \ stat_checker.parse_condition(workload.postconditions) if stat == 'count': curr_items = stat_checker.get_curr_items() value = int(value) + int(curr_items) workload.postconditions = "curr_items >= %s" % value prevWorkload = None if len(args) > 1 and isinstance(args[1], Workload): prevWorkload = args[1] if workload.preconditions is not None: # block tasks against bucket until pre-conditions met bs = BucketStatus.from_cache(bucket) bs.block(bucket) while not stat_checker.check(workload.preconditions): time.sleep(1) prevWorkload.active = False bs = BucketStatus.from_cache(bucket) bs.unblock(bucket)
def postcondition_handler(): workloads = CacheHelper.workloads() for workload in workloads: if workload.postconditions and workload.active: bucket = workload.bucket bs = BucketStatus.from_cache(bucket) bs.block(bucket) 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 = BucketStatus.from_cache(bucket) bs.unblock(bucket) workload.active = False
def task_prerun_handler(sender=None, task_id=None, task=None, args=None, kwargs=None, signal = None): if sender == run: workload = args[0] prevWorkload = args[1] if workload.preconditions is not None: # block tasks against bucket until pre-conditions met bucket = str(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) while not stat_checker.check(workload.preconditions): time.sleep(1) prevWorkload.active = False WorkloadCacher().store(prevWorkload) bs = BucketStatusCacher().bucketstatus(bucket) bs.unblock(bucket) BucketStatusCacher().store(bs)
def task_prerun_handler(sender=None, task_id=None, task=None, args=None, kwargs=None, signal = None): if sender == run: workload = args[0] bucket = str(workload.bucket) stat_checker = StatChecker(cfg.COUCHBASE_IP +":"+cfg.COUCHBASE_PORT, bucket = bucket, username = cfg.COUCHBASE_USER, password = cfg.COUCHBASE_PWD) # convert item count postcondition's to curr_item conditions if workload.postconditions: stat, cmp_type, value = \ stat_checker.parse_condition(workload.postconditions) if stat == 'count': curr_items = stat_checker.get_curr_items() value = int(value) + int(curr_items) workload.postconditions = "curr_items >= %s" % value prevWorkload = None if len(args) > 1 and isinstance(args[1], Workload): prevWorkload = args[1] if workload.preconditions is not None: # block tasks against bucket until pre-conditions met bs = BucketStatus.from_cache(bucket) bs.block(bucket) while not stat_checker.check(workload.preconditions): time.sleep(1) prevWorkload.active = False bs = BucketStatus.from_cache(bucket) bs.unblock(bucket)
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)