Skip to content

Commit fab5d7b

Browse files
committed
cluster: notify listeners on up without pools
1 parent 7aee63e commit fab5d7b

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

cassandra/cluster.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,6 +2106,10 @@ def on_up(self, host):
21062106
with host.lock:
21072107
host.set_up()
21082108
host._currently_handling_node_up = False
2109+
for listener in self.listeners:
2110+
listener.on_up(host)
2111+
for session in tuple(self.sessions):
2112+
session.update_created_pools()
21092113

21102114
# for testing purposes
21112115
return futures

tests/unit/test_cluster.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,22 @@ def test_update_host_endpoint_notifies_listeners_for_live_host(self):
352352
session.remove_pool.assert_called_once_with(host)
353353
session.add_or_renew_pool.assert_called_once_with(host, is_host_addition=False)
354354

355+
def test_on_up_without_pool_futures_notifies_listeners(self):
356+
cluster = Cluster(load_balancing_policy=RoundRobinPolicy(), protocol_version=4)
357+
self.addCleanup(cluster.shutdown)
358+
359+
host = Host(DefaultEndPoint("127.0.0.1"), SimpleConvictionPolicy, host_id=uuid.uuid4())
360+
host.set_down()
361+
cluster.metadata.add_or_return_host(host)
362+
363+
listener = _RecordingHostStateListener()
364+
cluster.register_listener(listener)
365+
366+
cluster.on_up(host)
367+
368+
assert host.is_up is True
369+
assert listener.events == [("up", "127.0.0.1")]
370+
355371
def test_update_host_endpoint_restarts_reconnector_when_replacement_pool_fails(self):
356372
cluster = Cluster(load_balancing_policy=RoundRobinPolicy(), protocol_version=4)
357373
self.addCleanup(cluster.shutdown)

0 commit comments

Comments
 (0)