Skip to content

Commit 589a752

Browse files
committed
cluster: notify listeners on up without pools
1 parent 2d636de commit 589a752

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
@@ -412,6 +412,22 @@ def test_update_host_endpoint_notifies_listeners_for_live_host(self):
412412
session.remove_pool.assert_called_once_with(host)
413413
session.add_or_renew_pool.assert_called_once_with(host, is_host_addition=False)
414414

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

0 commit comments

Comments
 (0)