mirror of
https://github.com/wassname/ray.git
synced 2026-07-07 05:35:39 +08:00
Move global state API out of global_state object. (#4857)
This commit is contained in:
committed by
Philipp Moritz
parent
ea8d7b4dc0
commit
6703519144
@@ -37,8 +37,7 @@ class Monitor(object):
|
||||
|
||||
def __init__(self, redis_address, autoscaling_config, redis_password=None):
|
||||
# Initialize the Redis clients.
|
||||
self.state = ray.experimental.state.GlobalState()
|
||||
self.state._initialize_global_state(
|
||||
ray.state.state._initialize_global_state(
|
||||
args.redis_address, redis_password=redis_password)
|
||||
self.redis = ray.services.create_redis_client(
|
||||
redis_address, password=redis_password)
|
||||
@@ -149,7 +148,7 @@ class Monitor(object):
|
||||
xray_object_table_prefix = (
|
||||
ray.gcs_utils.TablePrefix_OBJECT_string.encode("ascii"))
|
||||
|
||||
task_table_objects = self.state.task_table()
|
||||
task_table_objects = ray.tasks()
|
||||
driver_id_hex = binary_to_hex(driver_id)
|
||||
driver_task_id_bins = set()
|
||||
for task_id_hex, task_info in task_table_objects.items():
|
||||
@@ -161,7 +160,7 @@ class Monitor(object):
|
||||
driver_task_id_bins.add(hex_to_binary(task_id_hex))
|
||||
|
||||
# Get objects associated with the driver.
|
||||
object_table_objects = self.state.object_table()
|
||||
object_table_objects = ray.objects()
|
||||
driver_object_id_bins = set()
|
||||
for object_id, _ in object_table_objects.items():
|
||||
task_id_bin = ray._raylet.compute_task_id(object_id).binary()
|
||||
@@ -171,13 +170,13 @@ class Monitor(object):
|
||||
def to_shard_index(id_bin):
|
||||
if len(id_bin) == ray.TaskID.size():
|
||||
return binary_to_task_id(id_bin).redis_shard_hash() % len(
|
||||
self.state.redis_clients)
|
||||
ray.state.state.redis_clients)
|
||||
else:
|
||||
return binary_to_object_id(id_bin).redis_shard_hash() % len(
|
||||
self.state.redis_clients)
|
||||
ray.state.state.redis_clients)
|
||||
|
||||
# Form the redis keys to delete.
|
||||
sharded_keys = [[] for _ in range(len(self.state.redis_clients))]
|
||||
sharded_keys = [[] for _ in range(len(ray.state.state.redis_clients))]
|
||||
for task_id_bin in driver_task_id_bins:
|
||||
sharded_keys[to_shard_index(task_id_bin)].append(
|
||||
xray_task_table_prefix + task_id_bin)
|
||||
@@ -190,7 +189,7 @@ class Monitor(object):
|
||||
keys = sharded_keys[shard_index]
|
||||
if len(keys) == 0:
|
||||
continue
|
||||
redis = self.state.redis_clients[shard_index]
|
||||
redis = ray.state.state.redis_clients[shard_index]
|
||||
num_deleted = redis.delete(*keys)
|
||||
logger.info("Monitor: "
|
||||
"Removed {} dead redis entries of the "
|
||||
@@ -256,7 +255,7 @@ class Monitor(object):
|
||||
message_handler(channel, data)
|
||||
|
||||
def update_raylet_map(self):
|
||||
all_raylet_nodes = self.state.client_table()
|
||||
all_raylet_nodes = ray.nodes()
|
||||
self.raylet_id_to_ip_map = {}
|
||||
for raylet_info in all_raylet_nodes:
|
||||
client_id = (raylet_info.get("DBClientID")
|
||||
|
||||
Reference in New Issue
Block a user