org.apache.hadoop.hdfs.server.datanode

## Class ReplicaBeingWritten

- java.lang.Object
- - org.apache.hadoop.hdfs.protocol.Block
  - - org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
    - - org.apache.hadoop.hdfs.server.datanode.LocalReplica
      - - org.apache.hadoop.hdfs.server.datanode.LocalReplicaInPipeline
        - - org.apache.hadoop.hdfs.server.datanode.ReplicaBeingWritten

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

      public class ReplicaBeingWritten
      extends LocalReplicaInPipeline

  This class represents replicas being written. Those are the replicas that are created in a pipeline initiated by a dfs client.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.hadoop.hdfs.server.datanode.LocalReplica

      `LocalReplica.ReplicaDirInfo`

  - ### Field Summary

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

      `BLOCK_FILE_PREFIX, blockFilePattern, METADATA_EXTENSION, metaFilePattern, metaOrBlockFilePattern`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReplicaBeingWritten(org.apache.hadoop.hdfs.protocol.Block block, FsVolumeSpi vol, File dir, Thread writer)` Constructor.
    `ReplicaBeingWritten(long blockId, long genStamp, FsVolumeSpi vol, File dir, long bytesToReserve)` Constructor for a zero length replica.
    `ReplicaBeingWritten(long blockId, long len, long genStamp, FsVolumeSpi vol, File dir, Thread writer, long bytesToReserve)` Constructor.
    `ReplicaBeingWritten(ReplicaBeingWritten from)` Copy constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)`
    `HdfsServerConstants.ReplicaState` | `getState()` Get the replica state
    `long` | `getVisibleLength()` Get the number of bytes that are visible to readers
    `int` | `hashCode()`

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

      `attemptToSetWriter, createInfo, createRestartMetaStream, createStreams, getBytesAcked, getBytesOnDisk, getBytesReserved, getLastChecksumAndDataLen, getOriginalBytesReserved, getOriginalReplica, getRecoveryID, getReplicaInfo, interruptThread, moveReplicaFrom, releaseAllBytesReserved, setBytesAcked, setLastChecksumAndDataLen, setRecoveryID, setWriter, stopWriter, toString`

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

      `blockDataExists, breakHardLinksIfNeeded, bumpReplicaGS, compareWith, copyBlockdata, copyMetadata, deleteBlockData, deleteMetadata, fsyncDirectory, getBlockDataLength, getBlockFile, getBlockURI, getDataInputStream, getDataOutputStream, getDir, getMetadataInputStream, getMetadataLength, getMetadataOutputStream, getMetadataURI, getMetaFile, getPinning, getPinning, metadataExists, parseBaseDir, renameData, renameMeta, setPinning, setPinning, truncateBlock, truncateBlock, updateWithReplica`

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

      `getFileIoProvider, getNext, getStorageUuid, getVolume, isOnTransientStorage, setNext`

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

      `appendStringTo, compareTo, filename2id, getBlockId, getBlockId, getBlockName, getGenerationStamp, getGenerationStamp, getNumBytes, 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.ReplicaInPipeline

      `setNumBytes`

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

      `getBlockId, getGenerationStamp, getNumBytes, getStorageUuid, isOnTransientStorage`

- - ### Constructor Detail

    - #### ReplicaBeingWritten

          public ReplicaBeingWritten(long blockId,
                                     long genStamp,
                                     FsVolumeSpi vol,
                                     File dir,
                                     long bytesToReserve)

      Constructor for a zero length replica.
      Parameters:
        `blockId` - block id
        `genStamp` - replica generation stamp
        `vol` - volume where replica is located
        `dir` - directory path where block and meta files are located
        `bytesToReserve` - disk space to reserve for this replica, based on the estimated maximum block length.

    - #### ReplicaBeingWritten

          public ReplicaBeingWritten(org.apache.hadoop.hdfs.protocol.Block block,
                                     FsVolumeSpi vol,
                                     File dir,
                                     Thread writer)

      Constructor.
      Parameters:
        `block` - a block
        `vol` - volume where replica is located
        `dir` - directory path where block and meta files are located
        `writer` - a thread that is writing to this replica

    - #### ReplicaBeingWritten

          public ReplicaBeingWritten(long blockId,
                                     long len,
                                     long genStamp,
                                     FsVolumeSpi vol,
                                     File dir,
                                     Thread writer,
                                     long bytesToReserve)

      Constructor.
      Parameters:
        `blockId` - block id
        `len` - replica length
        `genStamp` - replica generation stamp
        `vol` - volume where replica is located
        `dir` - directory path where block and meta files are located
        `writer` - a thread that is writing to this replica
        `bytesToReserve` - disk space to reserve for this replica, based on the estimated maximum block length.

    - #### ReplicaBeingWritten

          public ReplicaBeingWritten(ReplicaBeingWritten from)

      Copy constructor.
      Parameters:
        `from` - where to copy from

  - ### Method Detail

    - #### getVisibleLength

          public long getVisibleLength()

      Description copied from interface: `org.apache.hadoop.hdfs.server.datanode.Replica`
      Get the number of bytes that are visible to readers
      Specified by:
        `getVisibleLength` in interface `org.apache.hadoop.hdfs.server.datanode.Replica`
      Overrides:
        `getVisibleLength` in class `LocalReplicaInPipeline`
      Returns:
        the number of bytes that are visible to readers

    - #### getState

          public HdfsServerConstants.ReplicaState getState()

      Description copied from interface: `org.apache.hadoop.hdfs.server.datanode.Replica`
      Get the replica state
      Specified by:
        `getState` in interface `org.apache.hadoop.hdfs.server.datanode.Replica`
      Overrides:
        `getState` in class `LocalReplicaInPipeline`
      Returns:
        the replica state

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `LocalReplicaInPipeline`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `LocalReplicaInPipeline`

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.