java.lang.Comparable<org.apache.hadoop.hdfs.protocol.Block>, Replica, org.apache.hadoop.io.Writable, org.apache.hadoop.util.LightWeightGSet.LinkedElementFinalizedReplica, LocalReplicaInPipeline, ReplicaUnderRecovery, ReplicaWaitingToBeRecoveredpublic abstract class LocalReplica extends ReplicaInfo
| Modifier and Type | Class | Description |
|---|---|---|
static class |
LocalReplica.ReplicaDirInfo |
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
blockDataExists() |
|
boolean |
breakHardLinksIfNeeded() |
This function "breaks hardlinks" to the current replica file.
|
void |
bumpReplicaGS(long newGS) |
Bump a replica's generation stamp to a new one.
|
int |
compareWith(FsVolumeSpi.ScanInfo info) |
|
void |
copyBlockdata(java.net.URI destination) |
|
void |
copyMetadata(java.net.URI destination) |
|
boolean |
deleteBlockData() |
Used to deletes the replica's block data.
|
boolean |
deleteMetadata() |
Used to deletes the replica's metadata.
|
void |
fsyncDirectory() |
Sync the parent directory changes to durable device.
|
long |
getBlockDataLength() |
|
java.io.File |
getBlockFile() |
Get the full path of this replica's data file.
|
java.net.URI |
getBlockURI() |
Get the
URI for where the data of this replica is stored. |
java.io.InputStream |
getDataInputStream(long seekOffset) |
Returns an
InputStream to the replica's data. |
java.io.OutputStream |
getDataOutputStream(boolean append) |
Returns an
OutputStream to the replica's data. |
protected java.io.File |
getDir() |
Return the parent directory path where this replica is located.
|
LengthInputStream |
getMetadataInputStream(long offset) |
Returns an
InputStream to the replica's metadata. |
long |
getMetadataLength() |
|
java.io.OutputStream |
getMetadataOutputStream(boolean append) |
Returns an
OutputStream to the replica's metadata. |
java.net.URI |
getMetadataURI() |
Get the
URI for where the metadata of this replica is stored. |
java.io.File |
getMetaFile() |
Get the full path of this replica's meta file.
|
boolean |
getPinning(org.apache.hadoop.fs.LocalFileSystem localFS) |
Check whether the block was pinned.
|
boolean |
getPinning(org.apache.hadoop.fs.LocalFileSystem localFS,
org.apache.hadoop.fs.Path path) |
Get pin status of a file by checking the sticky bit.
|
boolean |
metadataExists() |
|
static LocalReplica.ReplicaDirInfo |
parseBaseDir(java.io.File dir,
long blockId) |
|
boolean |
renameData(java.net.URI destURI) |
Rename the data
URI to that referenced by destURI. |
boolean |
renameMeta(java.net.URI destURI) |
Rename the metadata
URI to that referenced by destURI. |
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 |
setPinning(org.apache.hadoop.fs.LocalFileSystem localFS,
org.apache.hadoop.fs.Path path) |
Set sticky bit on path to pin file.
|
void |
truncateBlock(long newLength) |
|
static void |
truncateBlock(FsVolumeSpi volume,
java.io.File blockFile,
java.io.File metaFile,
long oldlen,
long newlen,
FileIoProvider fileIoProvider) |
|
void |
updateWithReplica(StorageLocation replicaLocation) |
Update this replica with the
StorageLocation found. |
createInfo, getBytesReserved, getFileIoProvider, getNext, getOriginalBytesReserved, getOriginalReplica, getRecoveryID, getStorageUuid, getVolume, isOnTransientStorage, setNext, setRecoveryID, toStringappendStringTo, compareTo, equals, filename2id, getBlockId, getBlockId, getBlockName, getGenerationStamp, getGenerationStamp, getNumBytes, hashCode, isBlockFilename, isMetaFilename, matchingIdAndGenStamp, metaToBlockFile, readFields, readId, set, setBlockId, setGenerationStamp, setNumBytes, toString, write, writeIdclone, finalize, getClass, notify, notifyAll, wait, wait, waitgetBlockId, getBytesOnDisk, getGenerationStamp, getNumBytes, getState, getVisibleLength@VisibleForTesting public java.io.File getBlockFile()
@VisibleForTesting public java.io.File getMetaFile()
protected java.io.File getDir()
@VisibleForTesting public static LocalReplica.ReplicaDirInfo parseBaseDir(java.io.File dir, long blockId)
public boolean breakHardLinksIfNeeded()
throws java.io.IOException
breakHardLinksIfNeeded in class ReplicaInfojava.io.IOExceptionpublic java.net.URI getBlockURI()
ReplicaInfoURI for where the data of this replica is stored.getBlockURI in class ReplicaInfoURI for the location of replica data.public java.io.InputStream getDataInputStream(long seekOffset)
throws java.io.IOException
ReplicaInfoInputStream to the replica's data.getDataInputStream in class ReplicaInfoseekOffset - the offset at which the read is started from.InputStream to read the replica data.java.io.IOException - if an error occurs in opening a stream to the data.public java.io.OutputStream getDataOutputStream(boolean append)
throws java.io.IOException
ReplicaInfoOutputStream to the replica's data.getDataOutputStream in class ReplicaInfoappend - indicates if the block should be opened for append.OutputStream to write to the replica.java.io.IOException - if an error occurs in creating an OutputStream.public boolean blockDataExists()
blockDataExists in class ReplicaInfopublic boolean deleteBlockData()
ReplicaInfodeleteBlockData in class ReplicaInfopublic long getBlockDataLength()
getBlockDataLength in class ReplicaInfopublic java.net.URI getMetadataURI()
ReplicaInfoURI for where the metadata of this replica is stored.getMetadataURI in class ReplicaInfoURI for the location of replica metadata.public LengthInputStream getMetadataInputStream(long offset) throws java.io.IOException
ReplicaInfoInputStream to the replica's metadata.getMetadataInputStream in class ReplicaInfooffset - the offset at which the read is started from.LengthInputStream to read the replica metadata.java.io.IOExceptionpublic java.io.OutputStream getMetadataOutputStream(boolean append)
throws java.io.IOException
ReplicaInfoOutputStream to the replica's metadata.getMetadataOutputStream in class ReplicaInfoappend - indicates if the block metadata should be opened for append.OutputStream to write to the replica's metadata.java.io.IOException - if an error occurs in creating an OutputStream.public boolean metadataExists()
metadataExists in class ReplicaInfopublic boolean deleteMetadata()
ReplicaInfodeleteMetadata in class ReplicaInfopublic long getMetadataLength()
getMetadataLength in class ReplicaInfopublic boolean renameMeta(java.net.URI destURI)
throws java.io.IOException
ReplicaInfoURI to that referenced by destURI.renameMeta in class ReplicaInfodestURI - the target URI.java.io.IOException - if an exception occurs in the rename.public boolean renameData(java.net.URI destURI)
throws java.io.IOException
ReplicaInfoURI to that referenced by destURI.renameData in class ReplicaInfodestURI - the target URI.java.io.IOException - if an exception occurs in the rename.public void updateWithReplica(StorageLocation replicaLocation)
ReplicaInfoStorageLocation found.updateWithReplica in class ReplicaInforeplicaLocation - the StorageLocation found for this replica.public boolean getPinning(org.apache.hadoop.fs.LocalFileSystem localFS)
throws java.io.IOException
ReplicaInfogetPinning in class ReplicaInfolocalFS - the local filesystem to use.java.io.IOExceptionpublic void setPinning(org.apache.hadoop.fs.LocalFileSystem localFS)
throws java.io.IOException
ReplicaInfosetPinning in class ReplicaInfolocalFS - the local filesystem to use.java.io.IOException - if there is an exception in the pinning.public void bumpReplicaGS(long newGS)
throws java.io.IOException
ReplicaInfobumpReplicaGS in class ReplicaInfonewGS - new generation stampjava.io.IOException - if the change failspublic void truncateBlock(long newLength)
throws java.io.IOException
truncateBlock in class ReplicaInfojava.io.IOExceptionpublic int compareWith(FsVolumeSpi.ScanInfo info)
compareWith in class ReplicaInfopublic void copyMetadata(java.net.URI destination)
throws java.io.IOException
copyMetadata in class ReplicaInfojava.io.IOExceptionpublic void copyBlockdata(java.net.URI destination)
throws java.io.IOException
copyBlockdata in class ReplicaInfojava.io.IOExceptionpublic boolean getPinning(org.apache.hadoop.fs.LocalFileSystem localFS,
org.apache.hadoop.fs.Path path)
throws java.io.IOException
localFS - local file systempath - path to be checkedjava.io.IOExceptionpublic void setPinning(org.apache.hadoop.fs.LocalFileSystem localFS,
org.apache.hadoop.fs.Path path)
throws java.io.IOException
localFS - local file systempath - path to be pinned with sticky bitjava.io.IOExceptionpublic static void truncateBlock(FsVolumeSpi volume, java.io.File blockFile, java.io.File metaFile, long oldlen, long newlen, FileIoProvider fileIoProvider) throws java.io.IOException
java.io.IOExceptionpublic void fsyncDirectory()
throws java.io.IOException
java.io.IOExceptionCopyright © 2008–2025 Apache Software Foundation. All rights reserved.