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] 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(): 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)