Permalink
Browse files
add support to clear a node's queues to get you a fresh start
- Loading branch information...
Showing
with
15 additions
and
0 deletions.
-
+6
−0
tweetf0rm/client.py
-
+9
−0
tweetf0rm/redis_helper.py
|
|
@@ -103,6 +103,8 @@ |
|
|
|
|
|
}, 'NODE_QSIZES': {
|
|
|
|
|
|
+ }, 'CLEAR_NODE_QUEUES': {
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -172,6 +174,8 @@ def cmd(config, args): |
|
|
#node_coordinator.remove_node(nid)
|
|
|
#pp.pprint(node_coordinator.list_nodes())
|
|
|
raise NotImplemented("NotImplemented yet...")
|
|
|
+ elif (args.command == 'CLEAR_NODE_QUEUES'):
|
|
|
+ node_queue.clear_all_queues()
|
|
|
else:
|
|
|
args_dict = copy.copy(args.__dict__)
|
|
|
cmd = new_cmd(args.command, args_dict)
|
|
|
@@ -225,6 +229,8 @@ def print_avaliable_cmd(): |
|
|
'-nid/--node_id': dictionary['-nid/--node_id']
|
|
|
}, 'NODE_QSIZES':{
|
|
|
'-nid/--node_id': dictionary['-nid/--node_id']
|
|
|
+ }, 'CLEAR_NODE_QUEUES':{
|
|
|
+ '-nid/--node_id': dictionary['-nid/--node_id']
|
|
|
}}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -92,6 +92,15 @@ class NodeQueue(RedisQueue): |
|
|
|
|
|
def __init__(self, node_id, redis_config=None):
|
|
|
super(NodeQueue, self).__init__(node_id, redis_config=redis_config)
|
|
|
+ self.node_id = node_id
|
|
|
+
|
|
|
+ def clear_all_queues(self):
|
|
|
+ '''This will not only clear the node queue (mostly for control cmds); but also the crawlers' cmd queues to give you a fresh start'''
|
|
|
+ #self.conn().delete('queue:%s*'%(self.node_id))
|
|
|
+ for key in self.conn().keys('queue:%s:*'%self.node_id):
|
|
|
+ self.conn().delete(key)
|
|
|
+
|
|
|
+ self.conn().delete('queue:%s'%self.node_id)
|
|
|
|
|
|
class NodeCoordinator(RedisBase):
|
|
|
'''
|
|
|
|
0 comments on commit
8bb2ff8