Skip to content

Commit

Permalink
CBQE-1198: cleanup cache miss queues between runs
Browse files Browse the repository at this point in the history
Change-Id: I2df1f6b0e799e1442923024496f6eb2b60e03688
Reviewed-on: http://review.couchbase.org/25522
Tested-by: buildbot <build@couchbase.com>
Reviewed-by: Tommie McAfee <tommie@couchbase.com>
  • Loading branch information
tahmmee committed Apr 8, 2013
1 parent ae4561e commit e03ff80
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pysystests/app/init.py
Expand Up @@ -46,7 +46,7 @@
os.system("cd .. && ./testrunner -i " + cfg.CLUSTER['ini'] + " -t cluster_setup.SETUP." + function + " && cd pysystests")

# delete queues (note using --purge will remove cc_queues)
queues = CacheHelper.task_queues()
queues = CacheHelper.task_queues() + CacheHelper.miss_queues()

# when --purge set delete cc_queue's as well
# as seriesly db
Expand Down
10 changes: 9 additions & 1 deletion pysystests/app/workload_manager.py
Expand Up @@ -834,7 +834,6 @@ def updateIndexKeys(self, key):
def __setattr__(self, name, value):
super(Workload, self).__setattr__(name, value)


# auto cache workload when certain attributes change
# if object has been fully setup
if name in Workload.AUTOCACHEKEYS and self.initialized:
Expand All @@ -859,11 +858,18 @@ def requeueNonDeletedKeys(self):
# put back on to consume_queue
msg = json.dumps(keys[0][0])
rabbitHelper.putMsg(self.consume_queue, msg)

try:
# delete task queue
rabbitHelper.delete(self.task_queue)

# delete consume queue if it was a miss_queue
if self.miss_queue is not None and self.consume_queue is not None:
rabbitHelper.delete(self.consume_queue)
except:
pass


@staticmethod
def from_cache(id_):
return ObjCacher().instance(CacheHelper.WORKLOADCACHEKEY, id_)
Expand Down Expand Up @@ -906,6 +912,8 @@ def latestWorkload(self, bucket):
if len(self.history) > 0 and bucket in self.history:
taskId, workload = self.history[bucket]["tasks"][-1]

# retrieve latest workload in case it has changed since last cached
workload = Workload.from_cache(workload.id)
return workload

def mode(self, bucket):
Expand Down
11 changes: 10 additions & 1 deletion pysystests/cache.py
Expand Up @@ -159,6 +159,14 @@ def consume_queues():
queues.append(workload.consume_queue)
return queues

@staticmethod
def miss_queues():
queues = []
for workload in CacheHelper.workloads():
if workload.miss_queue is not None and workload.consume_queue is not None:
queues.append(workload.consume_queue)
return queues

@staticmethod
def task_queues():
kv = [workload.task_queue for workload in CacheHelper.workloads()]
Expand All @@ -169,7 +177,8 @@ def task_queues():
def queues():
return CacheHelper.task_queues() +\
CacheHelper.cc_queues() +\
CacheHelper.consume_queues()
CacheHelper.consume_queues() +\
CacheHelper.miss_queues()

@staticmethod
def cacheClean():
Expand Down

0 comments on commit e03ff80

Please sign in to comment.