Skip to content

Commit be1794d

Browse files
committed
cluster: notify listeners on up without pools
1 parent fa16181 commit be1794d

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
@@ -2104,6 +2104,10 @@ def on_up(self, host):
21042104
with host.lock:
21052105
host.set_up()
21062106
host._currently_handling_node_up = False
2107+
for listener in self.listeners:
2108+
listener.on_up(host)
2109+
for session in tuple(self.sessions):
2110+
session.update_created_pools()
21072111

21082112
# for testing purposes
21092113
return futures

tests/unit/test_cluster.py

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

413+
def test_on_up_without_pool_futures_notifies_listeners(self):
414+
cluster = Cluster(load_balancing_policy=RoundRobinPolicy(), protocol_version=4)
415+
self.addCleanup(cluster.shutdown)
416+
417+
host = Host(DefaultEndPoint("127.0.0.1"), SimpleConvictionPolicy, host_id=uuid.uuid4())
418+
host.set_down()
419+
cluster.metadata.add_or_return_host(host)
420+
421+
listener = _RecordingHostStateListener()
422+
cluster.register_listener(listener)
423+
424+
cluster.on_up(host)
425+
426+
assert host.is_up is True
427+
assert listener.events == [("up", "127.0.0.1")]
428+
413429
def test_update_host_endpoint_restarts_reconnector_when_replacement_pool_fails(self):
414430
cluster = Cluster(load_balancing_policy=RoundRobinPolicy(), protocol_version=4)
415431
self.addCleanup(cluster.shutdown)

0 commit comments

Comments
 (0)