def check_queue_sizes(zk_client, threshold=5):
"""
For the most part queues should be empty. If they contain more than a given number of
entries, return information.
:param threshold: ``int`` the max number of children a queue can contain before an error is raised.
"""
errors = []
stats = get_znode_children_counts(zk_client, ZK_QUEUE_PATHS)
missing = set(stats.keys()) ^ set(ZK_QUEUE_PATHS)
for path in missing:
errors.append("queue path [%s] is missing" % path)
if stats is None:
raise ValueError("stats is None!!!")
for path, max_children in six.viewitems(stats):
if max_children > threshold:
errors.append(
"queue [%s] is backed up with: %d children, error threshold: %d" % (path, max_children, threshold)
)
return errors
评论列表
文章目录