Interface ReplicaInPipeline

All Superinterfaces:
Replica
All Known Implementing Classes:
LocalReplicaInPipeline, ReplicaBeingWritten

public interface ReplicaInPipeline extends Replica
This defines the interface of a replica in Pipeline that's being written to
  • Method Details

    • setNumBytes

      void setNumBytes(long bytesReceived)
      Set the number of bytes received
      Parameters:
      bytesReceived - number of bytes received
    • getBytesAcked

      long getBytesAcked()
      Get the number of bytes acked
      Returns:
      the number of bytes acked
    • setBytesAcked

      void setBytesAcked(long bytesAcked)
      Set the number bytes that have acked
      Parameters:
      bytesAcked - number bytes acked
    • releaseAllBytesReserved

      void releaseAllBytesReserved()
      Release any disk space reserved for this replica.
    • releaseReplicaInfoBytesReserved

      void releaseReplicaInfoBytesReserved()
      Release the reserved space from the ReplicaInfo.
    • setLastChecksumAndDataLen

      void setLastChecksumAndDataLen(long dataLength, byte[] lastChecksum)
      store the checksum for the last chunk along with the data length
      Parameters:
      dataLength - number of bytes on disk
      lastChecksum - - checksum bytes for the last chunk
    • getLastChecksumAndDataLen

      ChunkChecksum getLastChecksumAndDataLen()
      gets the last chunk checksum and the length of the block corresponding to that checksum
    • createStreams

      ReplicaOutputStreams createStreams(boolean isCreate, org.apache.hadoop.util.DataChecksum requestedChecksum) throws IOException
      Create output streams for writing to this replica, one for block file and one for CRC file
      Parameters:
      isCreate - if it is for creation
      requestedChecksum - the checksum the writer would prefer to use
      Returns:
      output streams for writing
      Throws:
      IOException - if any error occurs
    • createRestartMetaStream

      OutputStream createRestartMetaStream() throws IOException
      Create an output stream to write restart metadata in case of datanode shutting down for quick restart.
      Returns:
      output stream for writing.
      Throws:
      IOException - if any error occurs
    • getReplicaInfo

      ReplicaInfo getReplicaInfo()
    • setWriter

      void setWriter(Thread writer)
      Set the thread that is writing to this replica
      Parameters:
      writer - a thread writing to this replica
    • interruptThread

      void interruptThread()
    • attemptToSetWriter

      boolean attemptToSetWriter(Thread prevWriter, Thread newWriter)
      Attempt to set the writer to a new value.
    • stopWriter

      void stopWriter(long xceiverStopTimeout) throws IOException
      Interrupt the writing thread and wait until it dies.
      Throws:
      IOException - the waiting is interrupted
    • waitForMinLength

      void waitForMinLength(long minLength, long time, TimeUnit unit) throws IOException
      Causes the current thread to wait until a minimum length is reached, the thread is interrupted, or the specified waiting time elapses.
      Parameters:
      minLength - The minimum length to achieve
      time - the maximum time to wait
      unit - the time unit of the time argument
      Throws:
      IOException - if the current thread is interrupted or the minimum length is not achieved within the time allowed.