o
    `۷i                     @   s  d dl Z d dlmZ d dlmZ d dlmZmZ d dlm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ e eZg dZd ZdZdZ d	Z!d	Z"g ej#d
e fde fde!fde"fZ$dde%fddZ&G dd dZ'	dde%de(de%de)de%dee% fddZ*dS )    N)Optional)ray_constants)	ErrorType	JobConfig)ActorTableDataAvailableResourcesErrorTableDataGcsEntryGcsNodeInfoJobTableDataPlacementGroupTableDataPubSubMessageResourceDemandResourceLoadResourcesDataResourceUsageBatchDataTablePrefixTablePubsub
TaskEventsTotalResourcesWorkerTableData)r   r
   r   r   r   r   r   r   r	   r   r   r   r   r   r   r   r   r   r      i    i`  zgrpc.max_send_message_lengthzgrpc.max_receive_message_lengthzgrpc.keepalive_time_mszgrpc.keepalive_timeout_msFaddressc                 C   s   ddl m} || t|dS )zReturns a GRPC channel to GCS.

    Args:
        address: GCS address string, e.g. ip:port
        aio: Whether using grpc.aio
    Returns:
        grpc.Channel or grpc.aio.Channel to GCS
    r   )init_grpc_channel)optionsasynchronous)ray._private.grpc_utilsr   _GRPC_OPTIONS)r   aior    r   L/home/ubuntu/vllm_env/lib/python3.10/site-packages/ray/_private/gcs_utils.pycreate_gcs_channelI   s   	r!   c                   @   s@   e Zd Zddee defddZedd Zd	d
 Z	dd Z
dS )
GcsChannelNFgcs_addressr   c                 C   s   || _ || _d S N)_gcs_address_aio)selfr#   r   r   r   r    __init__X   s   
zGcsChannel.__init__c                 C      | j S r$   )r%   r'   r   r   r    r   \   s   zGcsChannel.addressc                 C   s   t | j| j| _d S r$   )r!   r%   r&   _channelr*   r   r   r    connect`   s   zGcsChannel.connectc                 C   r)   r$   )r+   r*   r   r   r    channelf   s   zGcsChannel.channel)NF)__name__
__module____qualname__r   strboolr(   propertyr   r,   r-   r   r   r   r    r"   W   s    
r"   hostportpassworduse_sslstorage_namespaceusernamec                 C   s   ddl m} t| tstd|du rd}t|tstdt|ts'td|dk r2td| t|ts;td	t|tsDtd
|| |||||S )a  This function is used to cleanup the GCS storage in Redis.
    It supports Redis in cluster and non-cluster modes.

    Args:
       host: The Redis host address.
       port: The Redis port.
       username: The Redis username.
       password: The Redis password.
       use_ssl: Whether to encrypt the connection.
       storage_namespace: The namespace of the storage to be deleted.
    r   )del_key_prefix_from_storagezHost must be a stringN zUsername must be a stringzPassword must be a stringzInvalid port: zuse_ssl must be a booleanz"storage namespace must be a string)ray._rayletr:   
isinstancer1   
ValueErrorr2   	TypeError)r4   r5   r6   r7   r8   r9   r:   r   r   r    cleanup_redis_storagej   s$   




r@   )Fr$   )+loggingtypingr   ray._privater   ray.core.generated.common_pb2r   r   ray.core.generated.gcs_pb2r   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   	getLoggerr.   logger__all__WORKERDRIVER_MAX_MESSAGE_LENGTH_GRPC_KEEPALIVE_TIME_MS_GRPC_KEEPALIVE_TIMEOUT_MSGLOBAL_GRPC_OPTIONSr   r1   r!   r"   intr2   r@   r   r   r   r    <module>   sN    L
	