public abstract class LocalReplica
extends org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
| Modifier and Type | Class and Description | 
|---|---|
| static class  | LocalReplica.ReplicaDirInfo | 
| Modifier and Type | Method and 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(URI destination) | 
| void | copyMetadata(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() | 
| File | getBlockFile()Get the full path of this replica's data file. | 
| URI | getBlockURI()Get the  URIfor where the data of this replica is stored. | 
| InputStream | getDataInputStream(long seekOffset)Returns an  InputStreamto the replica's data. | 
| OutputStream | getDataOutputStream(boolean append)Returns an  OutputStreamto the replica's data. | 
| protected File | getDir()Return the parent directory path where this replica is located. | 
| LengthInputStream | getMetadataInputStream(long offset)Returns an  InputStreamto the replica's metadata. | 
| long | getMetadataLength() | 
| OutputStream | getMetadataOutputStream(boolean append)Returns an  OutputStreamto the replica's metadata. | 
| URI | getMetadataURI()Get the  URIfor where the metadata of this replica is stored. | 
| 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(File dir,
            long blockId) | 
| boolean | renameData(URI destURI)Rename the data  URIto that referenced bydestURI. | 
| boolean | renameMeta(URI destURI)Rename the metadata  URIto that referenced bydestURI. | 
| 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. | 
| static void | truncateBlock(FsVolumeSpi volume,
             File blockFile,
             File metaFile,
             long oldlen,
             long newlen,
             org.apache.hadoop.hdfs.server.datanode.FileIoProvider fileIoProvider) | 
| void | truncateBlock(long newLength) | 
| void | updateWithReplica(org.apache.hadoop.hdfs.server.datanode.StorageLocation replicaLocation)Update this replica with the  StorageLocationfound. | 
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, writeIdpublic File getBlockFile()
public File getMetaFile()
protected File getDir()
public static LocalReplica.ReplicaDirInfo parseBaseDir(File dir, long blockId)
public boolean breakHardLinksIfNeeded()
                               throws IOException
breakHardLinksIfNeeded in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfoIOExceptionpublic URI getBlockURI()
org.apache.hadoop.hdfs.server.datanode.ReplicaInfoURI for where the data of this replica is stored.getBlockURI in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfoURI for the location of replica data.public InputStream getDataInputStream(long seekOffset) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfoInputStream to the replica's data.getDataInputStream in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfoseekOffset - the offset at which the read is started from.InputStream to read the replica data.IOException - if an error occurs in opening a stream to the data.public OutputStream getDataOutputStream(boolean append) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfoOutputStream to the replica's data.getDataOutputStream in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfoappend - indicates if the block should be opened for append.OutputStream to write to the replica.IOException - if an error occurs in creating an OutputStream.public boolean blockDataExists()
blockDataExists in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfopublic boolean deleteBlockData()
org.apache.hadoop.hdfs.server.datanode.ReplicaInfodeleteBlockData in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfopublic long getBlockDataLength()
getBlockDataLength in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfopublic URI getMetadataURI()
org.apache.hadoop.hdfs.server.datanode.ReplicaInfoURI for where the metadata of this replica is stored.getMetadataURI in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfoURI for the location of replica metadata.public LengthInputStream getMetadataInputStream(long offset) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfoInputStream to the replica's metadata.getMetadataInputStream in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfooffset - the offset at which the read is started from.LengthInputStream to read the replica metadata.IOExceptionpublic OutputStream getMetadataOutputStream(boolean append) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfoOutputStream to the replica's metadata.getMetadataOutputStream in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfoappend - indicates if the block metadata should be opened for append.OutputStream to write to the replica's metadata.IOException - if an error occurs in creating an OutputStream.public boolean metadataExists()
metadataExists in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfopublic boolean deleteMetadata()
org.apache.hadoop.hdfs.server.datanode.ReplicaInfodeleteMetadata in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfopublic long getMetadataLength()
getMetadataLength in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfopublic boolean renameMeta(URI destURI) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfoURI to that referenced by destURI.renameMeta in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfodestURI - the target URI.IOException - if an exception occurs in the rename.public boolean renameData(URI destURI) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfoURI to that referenced by destURI.renameData in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfodestURI - the target URI.IOException - if an exception occurs in the rename.public void updateWithReplica(org.apache.hadoop.hdfs.server.datanode.StorageLocation replicaLocation)
org.apache.hadoop.hdfs.server.datanode.ReplicaInfoStorageLocation found.updateWithReplica in class org.apache.hadoop.hdfs.server.datanode.ReplicaInforeplicaLocation - the StorageLocation found for this replica.public boolean getPinning(org.apache.hadoop.fs.LocalFileSystem localFS)
                   throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfogetPinning in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfolocalFS - the local filesystem to use.IOExceptionpublic void setPinning(org.apache.hadoop.fs.LocalFileSystem localFS)
                throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfosetPinning in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfolocalFS - the local filesystem to use.IOException - if there is an exception in the pinning.public void bumpReplicaGS(long newGS)
                   throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfobumpReplicaGS in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfonewGS - new generation stampIOException - if the change failspublic void truncateBlock(long newLength)
                   throws IOException
truncateBlock in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfoIOExceptionpublic int compareWith(FsVolumeSpi.ScanInfo info)
compareWith in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfopublic void copyMetadata(URI destination) throws IOException
copyMetadata in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfoIOExceptionpublic void copyBlockdata(URI destination) throws IOException
copyBlockdata in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfoIOExceptionpublic boolean getPinning(org.apache.hadoop.fs.LocalFileSystem localFS,
                          org.apache.hadoop.fs.Path path)
                   throws IOException
localFS - local file systempath - path to be checkedIOExceptionpublic void setPinning(org.apache.hadoop.fs.LocalFileSystem localFS,
                       org.apache.hadoop.fs.Path path)
                throws IOException
localFS - local file systempath - path to be pinned with sticky bitIOExceptionpublic static void truncateBlock(FsVolumeSpi volume, File blockFile, File metaFile, long oldlen, long newlen, org.apache.hadoop.hdfs.server.datanode.FileIoProvider fileIoProvider) throws IOException
IOExceptionpublic void fsyncDirectory()
                    throws IOException
IOExceptionCopyright © 2008–2023 Apache Software Foundation. All rights reserved.