Exemplo n.º 1
0
    def actor_table(self, actor_id=None):
        """Fetch and parse the actor table information for one or more actor IDs.

        Args:
            actor_id: A hex string of the actor ID to fetch information about.
                If this is None, then the actor table is fetched.

        Returns:
            Information from the actor table.
        """
        self._check_connected()
        if actor_id is not None:
            actor_id = ray.ActorID(hex_to_binary(actor_id))
            return self._actor_table(actor_id)
        else:
            actor_table_keys = list(
                self.redis_client.scan_iter(
                    match=gcs_utils.TablePrefix_ACTOR_string + "*"))
            actor_ids_binary = [
                key[len(gcs_utils.TablePrefix_ACTOR_string):]
                for key in actor_table_keys
            ]

            results = {}
            for actor_id_binary in actor_ids_binary:
                results[binary_to_hex(actor_id_binary)] = self._actor_table(
                    ray.ActorID(actor_id_binary))
            return results
Exemplo n.º 2
0
    def actor_table(self, actor_id):
        """Fetch and parse the actor table information for a single actor ID.

        Args:
            actor_id: A hex string of the actor ID to fetch information about.
                If this is None, then the actor table is fetched.

        Returns:
            Information from the actor table.
        """
        self._check_connected()

        if actor_id is not None:
            actor_id = ray.ActorID(hex_to_binary(actor_id))
            actor_info = self.global_state_accessor.get_actor_info(actor_id)
            if actor_info is None:
                return {}
            else:
                actor_table_data = gcs_utils.ActorTableData.FromString(
                    actor_info)
                return self._gen_actor_info(actor_table_data)
        else:
            actor_table = self.global_state_accessor.get_actor_table()
            results = {}
            for i in range(len(actor_table)):
                actor_table_data = gcs_utils.ActorTableData.FromString(
                    actor_table[i])
                results[binary_to_hex(actor_table_data.actor_id)] = \
                    self._gen_actor_info(actor_table_data)

            return results