mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 23:57:45 +08:00
Heartbeat table uses gcs pub-sub instead of redis accessor (#8655)
This commit is contained in:
+18
-6
@@ -71,11 +71,22 @@ class Monitor:
|
||||
"""
|
||||
self.primary_subscribe_client.subscribe(channel)
|
||||
|
||||
def psubscribe(self, pattern):
|
||||
"""Subscribe to the given pattern on the primary Redis shard.
|
||||
|
||||
Args:
|
||||
pattern (str): The pattern to subscribe to.
|
||||
|
||||
Raises:
|
||||
Exception: An exception is raised if the subscription fails.
|
||||
"""
|
||||
self.primary_subscribe_client.psubscribe(pattern)
|
||||
|
||||
def xray_heartbeat_batch_handler(self, unused_channel, data):
|
||||
"""Handle an xray heartbeat batch message from Redis."""
|
||||
|
||||
gcs_entries = ray.gcs_utils.GcsEntry.FromString(data)
|
||||
heartbeat_data = gcs_entries.entries[0]
|
||||
pub_message = ray.gcs_utils.PubSubMessage.FromString(data)
|
||||
heartbeat_data = pub_message.data
|
||||
|
||||
message = ray.gcs_utils.HeartbeatBatchTableData.FromString(
|
||||
heartbeat_data)
|
||||
@@ -155,14 +166,15 @@ class Monitor:
|
||||
break
|
||||
|
||||
# Parse the message.
|
||||
pattern = message["pattern"]
|
||||
channel = message["channel"]
|
||||
data = message["data"]
|
||||
|
||||
# Determine the appropriate message handler.
|
||||
if channel == ray.gcs_utils.XRAY_HEARTBEAT_BATCH_CHANNEL:
|
||||
if pattern == ray.gcs_utils.XRAY_HEARTBEAT_BATCH_PATTERN:
|
||||
# Similar functionality as raylet info channel
|
||||
message_handler = self.xray_heartbeat_batch_handler
|
||||
elif channel == ray.gcs_utils.XRAY_JOB_CHANNEL:
|
||||
elif pattern == ray.gcs_utils.XRAY_JOB_PATTERN:
|
||||
# Handles driver death.
|
||||
message_handler = self.xray_job_notification_handler
|
||||
elif (channel ==
|
||||
@@ -199,8 +211,8 @@ class Monitor:
|
||||
clients and cleaning up state accordingly.
|
||||
"""
|
||||
# Initialize the subscription channel.
|
||||
self.subscribe(ray.gcs_utils.XRAY_HEARTBEAT_BATCH_CHANNEL)
|
||||
self.subscribe(ray.gcs_utils.XRAY_JOB_CHANNEL)
|
||||
self.psubscribe(ray.gcs_utils.XRAY_HEARTBEAT_BATCH_PATTERN)
|
||||
self.psubscribe(ray.gcs_utils.XRAY_JOB_PATTERN)
|
||||
|
||||
if self.autoscaler:
|
||||
self.subscribe(
|
||||
|
||||
Reference in New Issue
Block a user