LocalResource (Apache Hadoop Main 3.5.0 API)
Description: declaration: package: org.apache.hadoop.yarn.api.records, class: LocalResource

Package org.apache.hadoop.yarn.api.records

# Class LocalResource

java.lang.Object
org.apache.hadoop.yarn.api.records.LocalResource

@Public @Stable public abstract class LocalResource extends Object

`LocalResource` represents a local resource required to run a container.

The `NodeManager` is responsible for localizing the resource prior to launching the container.

Applications can specify `LocalResourceType` and `LocalResourceVisibility`.

See Also:
  - `LocalResourceType`
  - `LocalResourceVisibility`
  - `ContainerLaunchContext`
  - `ApplicationSubmissionContext`
  - `ContainerManagementProtocol.startContainers(org.apache.hadoop.yarn.api.protocolrecords.StartContainersRequest)`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LocalResource()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract String`
  `getPattern()`
  Get the pattern that should be used to extract entries from the archive (only used when type is `PATTERN`).
  `abstract URL`
  `getResource()`
  Get the location of the resource to be localized.
  `abstract boolean`
  `getShouldBeUploadedToSharedCache()`
  NM uses it to decide whether if it is necessary to upload the resource to the shared cache
  `abstract long`
  `getSize()`
  Get the size of the resource to be localized.
  `abstract long`
  `getTimestamp()`
  Get the original timestamp of the resource to be localized, used for verification.
  `abstract LocalResourceType`
  `getType()`
  Get the `LocalResourceType` of the resource to be localized.
  `abstract LocalResourceVisibility`
  `getVisibility()`
  Get the `LocalResourceVisibility` of the resource to be localized.
  `static LocalResource`
  `newInstance(URL url, LocalResourceType type, LocalResourceVisibility visibility, long size, long timestamp)`
  `static LocalResource`
  `newInstance(URL url, LocalResourceType type, LocalResourceVisibility visibility, long size, long timestamp, boolean shouldBeUploadedToSharedCache)`
  `static LocalResource`
  `newInstance(URL url, LocalResourceType type, LocalResourceVisibility visibility, long size, long timestamp, String pattern)`
  `static LocalResource`
  `newInstance(URL url, LocalResourceType type, LocalResourceVisibility visibility, long size, long timestamp, String pattern, boolean shouldBeUploadedToSharedCache)`
  `abstract void`
  `setPattern(String pattern)`
  Set the pattern that should be used to extract entries from the archive (only used when type is `PATTERN`).
  `abstract void`
  `setResource(URL resource)`
  Set location of the resource to be localized.
  `abstract void`
  `setShouldBeUploadedToSharedCache(boolean shouldBeUploadedToSharedCache)`
  Inform NM whether upload to SCM is needed.
  `abstract void`
  `setSize(long size)`
  Set the size of the resource to be localized.
  `abstract void`
  `setTimestamp(long timestamp)`
  Set the timestamp of the resource to be localized, used for verification.
  `abstract void`
  `setType(LocalResourceType type)`
  Set the `LocalResourceType` of the resource to be localized.
  `abstract void`
  `setVisibility(LocalResourceVisibility visibility)`
  Set the `LocalResourceVisibility` of the resource to be localized.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### LocalResource

    public LocalResource()

- ## Method Details

  - ### newInstance

    @Public @Stable public static LocalResource newInstance(URL url, LocalResourceType type, LocalResourceVisibility visibility, long size, long timestamp, String pattern)

  - ### newInstance

    @Public @Unstable public static LocalResource newInstance(URL url, LocalResourceType type, LocalResourceVisibility visibility, long size, long timestamp, String pattern, boolean shouldBeUploadedToSharedCache)

  - ### newInstance

    @Public @Stable public static LocalResource newInstance(URL url, LocalResourceType type, LocalResourceVisibility visibility, long size, long timestamp)

  - ### newInstance

    @Public @Unstable public static LocalResource newInstance(URL url, LocalResourceType type, LocalResourceVisibility visibility, long size, long timestamp, boolean shouldBeUploadedToSharedCache)

  - ### getResource

    @Public @Stable public abstract URL getResource()
    Get the location of the resource to be localized.
    Returns:
      location of the resource to be localized

  - ### setResource

    @Public @Stable public abstract void setResource(URL resource)
    Set location of the resource to be localized.
    Parameters:
      `resource` - location of the resource to be localized

  - ### getSize

    @Public @Stable public abstract long getSize()
    Get the size of the resource to be localized.
    Returns:
      size of the resource to be localized

  - ### setSize

    @Public @Stable public abstract void setSize(long size)
    Set the size of the resource to be localized.
    Parameters:
      `size` - size of the resource to be localized

  - ### getTimestamp

    @Public @Stable public abstract long getTimestamp()
    Get the original timestamp of the resource to be localized, used for verification.
    Returns:
      timestamp of the resource to be localized

  - ### setTimestamp

    @Public @Stable public abstract void setTimestamp(long timestamp)
    Set the timestamp of the resource to be localized, used for verification.
    Parameters:
      `timestamp` - timestamp of the resource to be localized

  - ### getType

    @Public @Stable public abstract LocalResourceType getType()
    Get the `LocalResourceType` of the resource to be localized.
    Returns:
      `LocalResourceType` of the resource to be localized

  - ### setType

    @Public @Stable public abstract void setType(LocalResourceType type)
    Set the `LocalResourceType` of the resource to be localized.
    Parameters:
      `type` - `LocalResourceType` of the resource to be localized

  - ### getVisibility

    @Public @Stable public abstract LocalResourceVisibility getVisibility()
    Get the `LocalResourceVisibility` of the resource to be localized.
    Returns:
      `LocalResourceVisibility` of the resource to be localized

  - ### setVisibility

    @Public @Stable public abstract void setVisibility(LocalResourceVisibility visibility)
    Set the `LocalResourceVisibility` of the resource to be localized.
    Parameters:
      `visibility` - `LocalResourceVisibility` of the resource to be localized

  - ### getPattern

    @Public @Stable public abstract String getPattern()
    Get the pattern that should be used to extract entries from the archive (only used when type is `PATTERN`).
    Returns:
      pattern that should be used to extract entries from the archive.

  - ### setPattern

    @Public @Stable public abstract void setPattern(String pattern)
    Set the pattern that should be used to extract entries from the archive (only used when type is `PATTERN`).
    Parameters:
      `pattern` - pattern that should be used to extract entries from the archive.

  - ### getShouldBeUploadedToSharedCache

    @Public @Unstable public abstract boolean getShouldBeUploadedToSharedCache()
    NM uses it to decide whether if it is necessary to upload the resource to the shared cache
    Returns:
      true if it is necessary to upload the resource to the shared cache, false otherwise

  - ### setShouldBeUploadedToSharedCache

    @Public @Unstable public abstract void setShouldBeUploadedToSharedCache(boolean shouldBeUploadedToSharedCache)
    Inform NM whether upload to SCM is needed.
    Parameters:
      `shouldBeUploadedToSharedCache` - shouldBeUploadedToSharedCache of this request