Interface ReplicaInPipeline
- All Superinterfaces:
Replica
- All Known Implementing Classes:
LocalReplicaInPipeline,ReplicaBeingWritten
This defines the interface of a replica in Pipeline that's being written to
-
Method Summary
Modifier and TypeMethodDescriptionbooleanattemptToSetWriter(Thread prevWriter, Thread newWriter) Attempt to set the writer to a new value.Create an output stream to write restart metadata in case of datanode shutting down for quick restart.createStreams(boolean isCreate, org.apache.hadoop.util.DataChecksum requestedChecksum) Create output streams for writing to this replica, one for block file and one for CRC filelongGet the number of bytes ackedgets the last chunk checksum and the length of the block corresponding to that checksumvoidvoidRelease any disk space reserved for this replica.voidRelease the reserved space from the ReplicaInfo.voidsetBytesAcked(long bytesAcked) Set the number bytes that have ackedvoidsetLastChecksumAndDataLen(long dataLength, byte[] lastChecksum) store the checksum for the last chunk along with the data lengthvoidsetNumBytes(long bytesReceived) Set the number of bytes receivedvoidSet the thread that is writing to this replicavoidstopWriter(long xceiverStopTimeout) Interrupt the writing thread and wait until it dies.voidwaitForMinLength(long minLength, long time, TimeUnit unit) Causes the current thread to wait until a minimum length is reached, the thread is interrupted, or the specified waiting time elapses.Methods inherited from interface org.apache.hadoop.hdfs.server.datanode.Replica
getBlockId, getBytesOnDisk, getGenerationStamp, getNumBytes, getState, getStorageUuid, getVisibleLength, getVolume, isOnTransientStorage
-
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 disklastChecksum- - 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 creationrequestedChecksum- the checksum the writer would prefer to use- Returns:
- output streams for writing
- Throws:
IOException- if any error occurs
-
createRestartMetaStream
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
Set the thread that is writing to this replica- Parameters:
writer- a thread writing to this replica
-
interruptThread
void interruptThread() -
attemptToSetWriter
Attempt to set the writer to a new value. -
stopWriter
Interrupt the writing thread and wait until it dies.- Throws:
IOException- the waiting is interrupted
-
waitForMinLength
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 achievetime- the maximum time to waitunit- 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.
-