Class SharedCacheClient

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.yarn.client.api.SharedCacheClient
All Implemented Interfaces:
Closeable, AutoCloseable, Service

@Public @Unstable public abstract class SharedCacheClient extends AbstractService
This is the client for YARN's shared cache.
  • Constructor Details

    • SharedCacheClient

      @Private public SharedCacheClient(String name)
  • Method Details

    • createSharedCacheClient

      @Public public static SharedCacheClient createSharedCacheClient()
    • use

      @Public @Unstable public abstract URL use(ApplicationId applicationId, String resourceKey) throws YarnException

      The method to claim a resource with the SharedCacheManager. The client uses a checksum to identify the resource and an ApplicationId to identify which application will be using the resource.

      The SharedCacheManager responds with whether or not the resource exists in the cache. If the resource exists, a URL to the resource in the shared cache is returned. If the resource does not exist, null is returned instead.

      Once a URL has been returned for a resource, that URL is safe to use for the lifetime of the application that corresponds to the provided ApplicationId.

      Parameters:
      applicationId - ApplicationId of the application using the resource
      resourceKey - the key (i.e. checksum) that identifies the resource
      Returns:
      URL to the resource, or null if it does not exist
      Throws:
      YarnException
    • release

      @Public @Unstable public abstract void release(ApplicationId applicationId, String resourceKey) throws YarnException

      The method to release a resource with the SharedCacheManager. This method is called once an application is no longer using a claimed resource in the shared cache. The client uses a checksum to identify the resource and an ApplicationId to identify which application is releasing the resource.

      Note: This method is an optimization and the client is not required to call it for correctness.

      Parameters:
      applicationId - ApplicationId of the application releasing the resource
      resourceKey - the key (i.e. checksum) that identifies the resource
      Throws:
      YarnException
    • getFileChecksum

      @Public @Unstable public abstract String getFileChecksum(Path sourceFile) throws IOException
      A convenience method to calculate the checksum of a specified file.
      Parameters:
      sourceFile - A path to the input file
      Returns:
      A hex string containing the checksum digest
      Throws:
      IOException