class_docstr: Provide access to cached node information in the cluster.
class_docstr_tok: ["Provide","access","to","cached","node","information","in","the","cluster","."]
docstr: Update the cache by fetching latest node information from GCS.
  
  This should be called once in each update cycle.
  Within an update cycle, everyone will see the same
  cached node info avoiding any potential issues
  caused by inconsistent node info seen by different components.
docstr_tok: ["Update","the","cache","by","fetching","latest","node","information","from","GCS",".","This","should","be","called","once","in","each","update","cycle",".","Within","an","update","cycle",",","everyone","will","see","the","same","cached","node","info","avoiding","any","potential","issues","caused","by","inconsistent","node","info","seen","by","different","components","."]
code: def update(self):
      """Update the cache by fetching latest node information from GCS.
  
      This should be called once in each update cycle.
      Within an update cycle, everyone will see the same
      cached node info avoiding any potential issues
      caused by inconsistent node info seen by different components.
      """
      nodes = self._gcs_client.get_all_node_info(
          timeout=RAY_GCS_RPC_TIMEOUT_S
      )
      alive_nodes = [
          (
              ray.NodeID.from_binary(node_id).hex(),
              node["node_name"].decode("utf-8"),
          )
          for (node_id, node) in nodes.items()
          if node["state"]
          == ray.core.generated.gcs_pb2.GcsNodeInfo.ALIVE
      ]
  
      # Sort on NodeID to ensure the ordering is deterministic across the cluster.
      sorted(alive_nodes)
      self._cached_alive_nodes = alive_nodes
      self._cached_node_labels = {
          ray.NodeID.from_binary(node_id).hex(): {
              label_name.decode("utf-8"): label_value.decode("utf-8")
              for label_name, label_value in node["labels"].items()
          }
          for (node_id, node) in nodes.items()
      }
  
file_path: ray/python/ray/serve/_private/cluster_node_info_cache.py
imports: from abc import ABC, abstractmethod
  from typing import List, Optional, Set, Tuple
  import ray
  from ray._raylet import GcsClient
  from ray.serve._private.constants import RAY_GCS_RPC_TIMEOUT_S
label_desc: Use image node_id 2 for calling the ClusterNodeInfoCache obj's underlying member method code with example usage: obj.update() without return types