ProvidedReplica (Apache Hadoop HDFS 3.5.0 API)
Description: declaration: package: org.apache.hadoop.hdfs.server.datanode, class: ProvidedReplica

Package org.apache.hadoop.hdfs.server.datanode

# Class ProvidedReplica

java.lang.Object
org.apache.hadoop.hdfs.protocol.Block
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
org.apache.hadoop.hdfs.server.datanode.ProvidedReplica

All Implemented Interfaces:
  `Comparable<org.apache.hadoop.hdfs.protocol.Block>`, `Replica`, `org.apache.hadoop.io.Writable`, `org.apache.hadoop.util.LightWeightGSet.LinkedElement`

Direct Known Subclasses:
  `FinalizedProvidedReplica`

@Private @Unstable public abstract class ProvidedReplica extends ReplicaInfo
This abstract class is used as a base class for provided replicas.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final org.slf4j.Logger`
  `LOG`

  ### Fields inherited from class org.apache.hadoop.hdfs.protocol.Block

  `BLOCK_FILE_PREFIX, blockFilePattern, METADATA_EXTENSION, metaFilePattern, metaOrBlockFilePattern`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ProvidedReplica(long blockId, URI fileURI, long fileOffset, long blockLen, long genStamp, org.apache.hadoop.fs.PathHandle pathHandle, FsVolumeSpi volume, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem remoteFS)`
  Constructor.
  `ProvidedReplica(long blockId, org.apache.hadoop.fs.Path pathPrefix, String pathSuffix, long fileOffset, long blockLen, long genStamp, org.apache.hadoop.fs.PathHandle pathHandle, FsVolumeSpi volume, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem remoteFS)`
  Constructor.
  `ProvidedReplica(ProvidedReplica r)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `blockDataExists()`
  `boolean`
  `breakHardLinksIfNeeded()`
  `void`
  `bumpReplicaGS(long newGS)`
  Bump a replica's generation stamp to a new one.
  `int`
  `compareWith(FsVolumeSpi.ScanInfo info)`
  `void`
  `copyBlockdata(URI destination)`
  `void`
  `copyMetadata(URI destination)`
  `ReplicaRecoveryInfo`
  `createInfo()`
  `boolean`
  `deleteBlockData()`
  Used to deletes the replica's block data.
  `boolean`
  `deleteMetadata()`
  Used to deletes the replica's metadata.
  `long`
  `getBlockDataLength()`
  `URI`
  `getBlockURI()`
  Get the `URI` for where the data of this replica is stored.
  `InputStream`
  `getDataInputStream(long seekOffset)`
  Returns an `InputStream` to the replica's data.
  `OutputStream`
  `getDataOutputStream(boolean append)`
  Returns an `OutputStream` to the replica's data.
  `LengthInputStream`
  `getMetadataInputStream(long offset)`
  Returns an `InputStream` to the replica's metadata.
  `long`
  `getMetadataLength()`
  `OutputStream`
  `getMetadataOutputStream(boolean append)`
  Returns an `OutputStream` to the replica's metadata.
  `URI`
  `getMetadataURI()`
  Get the `URI` for where the metadata of this replica is stored.
  `org.apache.hadoop.fs.Path`
  `getPathPrefix()`
  `String`
  `getPathSuffix()`
  `boolean`
  `getPinning(org.apache.hadoop.fs.LocalFileSystem localFS)`
  Check whether the block was pinned.
  `boolean`
  `metadataExists()`
  `boolean`
  `renameData(URI destURI)`
  Rename the data `URI` to that referenced by `destURI`.
  `boolean`
  `renameMeta(URI destURI)`
  Rename the metadata `URI` to that referenced by `destURI`.
  `void`
  `setPathHandle(org.apache.hadoop.fs.PathHandle pathHandle)`
  `void`
  `setPinning(org.apache.hadoop.fs.LocalFileSystem localFS)`
  Set a block to be pinned on this datanode so that it cannot be moved by Balancer/Mover.
  `void`
  `truncateBlock(long newLength)`
  `void`
  `updateWithReplica(StorageLocation replicaLocation)`
  Update this replica with the `StorageLocation` found.

  ### Methods inherited from class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo

  `getBytesReserved, getFileIoProvider, getNext, getOriginalBytesReserved, getOriginalReplica, getRecoveryID, getStorageUuid, getVolume, isOnTransientStorage, setNext, setRecoveryID, toString`

  ### Methods inherited from class org.apache.hadoop.hdfs.protocol.Block

  `appendStringTo, compareTo, equals, filename2id, getBlockId, getBlockId, getBlockName, getGenerationStamp, getGenerationStamp, getNumBytes, hashCode, isBlockFilename, isMetaFilename, matchingIdAndGenStamp, metaToBlockFile, readFields, readId, set, setBlockId, setGenerationStamp, setNumBytes, toString, write, writeId`

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

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.apache.hadoop.hdfs.server.datanode.Replica

  `getBlockId, getBytesOnDisk, getGenerationStamp, getNumBytes, getState, getVisibleLength`

- ## Field Details

  - ### LOG

    public static final org.slf4j.Logger LOG

- ## Constructor Details

  - ### ProvidedReplica

    public ProvidedReplica(long blockId, URI fileURI, long fileOffset, long blockLen, long genStamp, org.apache.hadoop.fs.PathHandle pathHandle, FsVolumeSpi volume, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem remoteFS)
    Constructor.
    Parameters:
      `blockId` - block id
      `fileURI` - remote URI this block is to be read from
      `fileOffset` - the offset in the remote URI
      `blockLen` - the length of the block
      `genStamp` - the generation stamp of the block
      `volume` - the volume this block belongs to
      `conf` - the configuration
      `remoteFS` - reference to the remote filesystem to use for this replica.

  - ### ProvidedReplica

    public ProvidedReplica(long blockId, org.apache.hadoop.fs.Path pathPrefix, String pathSuffix, long fileOffset, long blockLen, long genStamp, org.apache.hadoop.fs.PathHandle pathHandle, FsVolumeSpi volume, org.apache.hadoop.conf.Configuration conf, org.apache.hadoop.fs.FileSystem remoteFS)
    Constructor.
    Parameters:
      `blockId` - block id
      `pathPrefix` - A prefix of the `Path` associated with this replica on the remote `FileSystem`.
      `pathSuffix` - A suffix of the `Path` associated with this replica on the remote `FileSystem`. Resolving the `pathSuffix` against the `pathPrefix` should provide the exact `Path` of the data associated with this replica on the remote `FileSystem`.
      `fileOffset` - the offset in the remote URI
      `blockLen` - the length of the block
      `genStamp` - the generation stamp of the block
      `volume` - the volume this block belongs to
      `conf` - the configuration
      `remoteFS` - reference to the remote filesystem to use for this replica.

  - ### ProvidedReplica

    public ProvidedReplica(ProvidedReplica r)

- ## Method Details

  - ### getBlockURI

    public URI getBlockURI()
    Description copied from class: `ReplicaInfo`
    Get the `URI` for where the data of this replica is stored.
    Specified by:
      `getBlockURI` in class `ReplicaInfo`
    Returns:
      `URI` for the location of replica data.

  - ### getPathSuffix

    @VisibleForTesting public String getPathSuffix()

  - ### getPathPrefix

    @VisibleForTesting public org.apache.hadoop.fs.Path getPathPrefix()

  - ### getDataInputStream

    public InputStream getDataInputStream(long seekOffset) throws IOException
    Description copied from class: `ReplicaInfo`
    Returns an `InputStream` to the replica's data.
    Specified by:
      `getDataInputStream` in class `ReplicaInfo`
    Parameters:
      `seekOffset` - the offset at which the read is started from.
    Returns:
      the `InputStream` to read the replica data.
    Throws:
      `IOException` - if an error occurs in opening a stream to the data.

  - ### getDataOutputStream

    public OutputStream getDataOutputStream(boolean append) throws IOException
    Description copied from class: `ReplicaInfo`
    Returns an `OutputStream` to the replica's data.
    Specified by:
      `getDataOutputStream` in class `ReplicaInfo`
    Parameters:
      `append` - indicates if the block should be opened for append.
    Returns:
      the `OutputStream` to write to the replica.
    Throws:
      `IOException` - if an error occurs in creating an `OutputStream`.

  - ### getMetadataURI

    public URI getMetadataURI()
    Description copied from class: `ReplicaInfo`
    Get the `URI` for where the metadata of this replica is stored.
    Specified by:
      `getMetadataURI` in class `ReplicaInfo`
    Returns:
      `URI` for the location of replica metadata.

  - ### getMetadataOutputStream

    public OutputStream getMetadataOutputStream(boolean append) throws IOException
    Description copied from class: `ReplicaInfo`
    Returns an `OutputStream` to the replica's metadata.
    Specified by:
      `getMetadataOutputStream` in class `ReplicaInfo`
    Parameters:
      `append` - indicates if the block metadata should be opened for append.
    Returns:
      the `OutputStream` to write to the replica's metadata.
    Throws:
      `IOException` - if an error occurs in creating an `OutputStream`.

  - ### blockDataExists

    public boolean blockDataExists()
    Specified by:
      `blockDataExists` in class `ReplicaInfo`
    Returns:
      true if the replica's data exists.

  - ### deleteBlockData

    public boolean deleteBlockData()
    Description copied from class: `ReplicaInfo`
    Used to deletes the replica's block data.
    Specified by:
      `deleteBlockData` in class `ReplicaInfo`
    Returns:
      true if the replica's data is successfully deleted.

  - ### getBlockDataLength

    public long getBlockDataLength()
    Specified by:
      `getBlockDataLength` in class `ReplicaInfo`
    Returns:
      the length of the block on storage.

  - ### getMetadataInputStream

    public LengthInputStream getMetadataInputStream(long offset) throws IOException
    Description copied from class: `ReplicaInfo`
    Returns an `InputStream` to the replica's metadata.
    Specified by:
      `getMetadataInputStream` in class `ReplicaInfo`
    Parameters:
      `offset` - the offset at which the read is started from.
    Returns:
      the `LengthInputStream` to read the replica metadata.
    Throws:
      `IOException`

  - ### metadataExists

    public boolean metadataExists()
    Specified by:
      `metadataExists` in class `ReplicaInfo`
    Returns:
      true if the replica's metadata exists.

  - ### deleteMetadata

    public boolean deleteMetadata()
    Description copied from class: `ReplicaInfo`
    Used to deletes the replica's metadata.
    Specified by:
      `deleteMetadata` in class `ReplicaInfo`
    Returns:
      true if the replica's metadata is successfully deleted.

  - ### getMetadataLength

    public long getMetadataLength()
    Specified by:
      `getMetadataLength` in class `ReplicaInfo`
    Returns:
      the length of the metadata on storage.

  - ### renameMeta

    public boolean renameMeta(URI destURI) throws IOException
    Description copied from class: `ReplicaInfo`
    Rename the metadata `URI` to that referenced by `destURI`.
    Specified by:
      `renameMeta` in class `ReplicaInfo`
    Parameters:
      `destURI` - the target `URI`.
    Returns:
      true if the rename is successful.
    Throws:
      `IOException` - if an exception occurs in the rename.

  - ### renameData

    public boolean renameData(URI destURI) throws IOException
    Description copied from class: `ReplicaInfo`
    Rename the data `URI` to that referenced by `destURI`.
    Specified by:
      `renameData` in class `ReplicaInfo`
    Parameters:
      `destURI` - the target `URI`.
    Returns:
      true if the rename is successful.
    Throws:
      `IOException` - if an exception occurs in the rename.

  - ### getPinning

    public boolean getPinning(org.apache.hadoop.fs.LocalFileSystem localFS) throws IOException
    Description copied from class: `ReplicaInfo`
    Check whether the block was pinned.
    Specified by:
      `getPinning` in class `ReplicaInfo`
    Parameters:
      `localFS` - the local filesystem to use.
    Returns:
      true if the block is pinned.
    Throws:
      `IOException`

  - ### setPinning

    public void setPinning(org.apache.hadoop.fs.LocalFileSystem localFS) throws IOException
    Description copied from class: `ReplicaInfo`
    Set a block to be pinned on this datanode so that it cannot be moved by Balancer/Mover.
    Specified by:
      `setPinning` in class `ReplicaInfo`
    Parameters:
      `localFS` - the local filesystem to use.
    Throws:
      `IOException` - if there is an exception in the pinning.

  - ### bumpReplicaGS

    public void bumpReplicaGS(long newGS) throws IOException
    Description copied from class: `ReplicaInfo`
    Bump a replica's generation stamp to a new one. Its on-disk meta file name is renamed to be the new one too.
    Specified by:
      `bumpReplicaGS` in class `ReplicaInfo`
    Parameters:
      `newGS` - new generation stamp
    Throws:
      `IOException` - if the change fails

  - ### breakHardLinksIfNeeded

    public boolean breakHardLinksIfNeeded() throws IOException
    Specified by:
      `breakHardLinksIfNeeded` in class `ReplicaInfo`
    Throws:
      `IOException`

  - ### createInfo

    public ReplicaRecoveryInfo createInfo() throws UnsupportedOperationException
    Specified by:
      `createInfo` in class `ReplicaInfo`
    Throws:
      `UnsupportedOperationException`

  - ### compareWith

    public int compareWith(FsVolumeSpi.ScanInfo info)
    Specified by:
      `compareWith` in class `ReplicaInfo`

  - ### truncateBlock

    public void truncateBlock(long newLength) throws IOException
    Specified by:
      `truncateBlock` in class `ReplicaInfo`
    Throws:
      `IOException`

  - ### updateWithReplica

    public void updateWithReplica(StorageLocation replicaLocation)
    Description copied from class: `ReplicaInfo`
    Update this replica with the `StorageLocation` found.
    Specified by:
      `updateWithReplica` in class `ReplicaInfo`
    Parameters:
      `replicaLocation` - the `StorageLocation` found for this replica.

  - ### copyMetadata

    public void copyMetadata(URI destination) throws IOException
    Specified by:
      `copyMetadata` in class `ReplicaInfo`
    Throws:
      `IOException`

  - ### copyBlockdata

    public void copyBlockdata(URI destination) throws IOException
    Specified by:
      `copyBlockdata` in class `ReplicaInfo`
    Throws:
      `IOException`

  - ### setPathHandle

    @VisibleForTesting public void setPathHandle(org.apache.hadoop.fs.PathHandle pathHandle)