Skip to content

Commit

Permalink
scylla_cluster: add cluster.stop_nodes
Browse files Browse the repository at this point in the history
Refactor stop_nodes out of cluster.stop()
Can be used to stop specified nodes in parallel.

Signed-off-by: Benny Halevy <[email protected]>
  • Loading branch information
bhalevy committed Jan 21, 2020
1 parent 8764219 commit b01b9c0
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion ccmlib/scylla_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,36 @@ def start(self, no_wait=False, verbose=False, wait_for_binary_proto=False,

return started

def stop_nodes(self, nodes=None, wait=True, gently=True, wait_other_notice=False, other_nodes=None, wait_seconds=127):
if nodes is None:
nodes = self.nodes.values()
elif isinstance(nodes, ScyllaNode):
nodes = [nodes]

marks = []
if wait_other_notice:
if not other_nodes:
other_nodes = [node for node in self.nodes.values() if not node in nodes]
marks = [(node, node.mark_log()) for node in other_nodes if node.is_live()]

# stop all nodes in parallel
stopped = [node for node in nodes if node.is_running()]
for node in stopped:
node.do_stop(gently=gently)

# wait for stopped nodes is needed
if wait or wait_other_notice:
for node in stopped:
node.wait_until_stopped(wait_seconds, marks)

return [node for node in nodes if not node.is_running()]

def stop(self, wait=True, gently=True, wait_other_notice=False, other_nodes=None, wait_seconds=127):
if self._scylla_manager:
self._scylla_manager.stop(gently)
Cluster.stop(self,wait,gently,wait_seconds=wait_seconds, wait_other_notice=wait_other_notice, other_nodes=other_nodes)
args = locals()
del args['self']
return self.stop_nodes(**args)

def get_scylla_mode(self):
return self.scylla_mode
Expand Down

0 comments on commit b01b9c0

Please sign in to comment.