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
URI for where the data of this replica is stored. |
InputStream |
getDataInputStream(long seekOffset)
Returns an
InputStream to the replica's data. |
OutputStream |
getDataOutputStream(boolean append)
Returns an
OutputStream to the replica's data. |
protected 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() |
OutputStream |
getMetadataOutputStream(boolean append)
Returns an
OutputStream to the replica's metadata. |
URI |
getMetadataURI()
Get the
URI for 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) |
boolean |
renameData(URI destURI)
Rename the data
URI to that referenced by destURI . |
boolean |
renameMeta(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.
|
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
StorageLocation found. |
createInfo, getBytesReserved, getFileIoProvider, getNext, getOriginalBytesReserved, getOriginalReplica, getRecoveryID, getStorageUuid, getVolume, isOnTransientStorage, setNext, setRecoveryID, toString
appendStringTo, compareTo, equals, filename2id, getBlockId, getBlockId, getBlockName, getGenerationStamp, getGenerationStamp, getNumBytes, hashCode, isBlockFilename, isMetaFilename, matchingIdAndGenStamp, metaToBlockFile, readFields, readId, set, setBlockId, setGenerationStamp, setNumBytes, toString, write, writeId
public File getBlockFile()
public File getMetaFile()
protected File getDir()
public static LocalReplica.ReplicaDirInfo parseBaseDir(File dir)
public boolean breakHardLinksIfNeeded() throws IOException
breakHardLinksIfNeeded
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
IOException
public URI getBlockURI()
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
URI
for where the data of this replica is stored.getBlockURI
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
URI
for the location of replica data.public InputStream getDataInputStream(long seekOffset) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
InputStream
to the replica's data.getDataInputStream
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
seekOffset
- 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.ReplicaInfo
OutputStream
to the replica's data.getDataOutputStream
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
append
- 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.ReplicaInfo
public boolean deleteBlockData()
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
deleteBlockData
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
public long getBlockDataLength()
getBlockDataLength
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
public URI getMetadataURI()
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
URI
for where the metadata of this replica is stored.getMetadataURI
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
URI
for the location of replica metadata.public LengthInputStream getMetadataInputStream(long offset) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
InputStream
to the replica's metadata.getMetadataInputStream
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
offset
- the offset at which the read is started from.LengthInputStream
to read the replica metadata.IOException
public OutputStream getMetadataOutputStream(boolean append) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
OutputStream
to the replica's metadata.getMetadataOutputStream
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
append
- 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.ReplicaInfo
public boolean deleteMetadata()
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
deleteMetadata
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
public long getMetadataLength()
getMetadataLength
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
public boolean renameMeta(URI destURI) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
URI
to that referenced by destURI
.renameMeta
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
destURI
- the target URI
.IOException
- if an exception occurs in the rename.public boolean renameData(URI destURI) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
URI
to that referenced by destURI
.renameData
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
destURI
- 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.ReplicaInfo
StorageLocation
found.updateWithReplica
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
replicaLocation
- the StorageLocation
found for this replica.public boolean getPinning(org.apache.hadoop.fs.LocalFileSystem localFS) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
getPinning
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
localFS
- the local filesystem to use.IOException
public void setPinning(org.apache.hadoop.fs.LocalFileSystem localFS) throws IOException
org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
setPinning
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
localFS
- 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.ReplicaInfo
bumpReplicaGS
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
newGS
- new generation stampIOException
- if the change failspublic void truncateBlock(long newLength) throws IOException
truncateBlock
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
IOException
public int compareWith(FsVolumeSpi.ScanInfo info)
compareWith
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
public void copyMetadata(URI destination) throws IOException
copyMetadata
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
IOException
public void copyBlockdata(URI destination) throws IOException
copyBlockdata
in class org.apache.hadoop.hdfs.server.datanode.ReplicaInfo
IOException
public boolean getPinning(org.apache.hadoop.fs.LocalFileSystem localFS, org.apache.hadoop.fs.Path path) throws IOException
localFS
- local file systempath
- path to be checkedIOException
public 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 bitIOException
public static void truncateBlock(FsVolumeSpi volume, File blockFile, File metaFile, long oldlen, long newlen, org.apache.hadoop.hdfs.server.datanode.FileIoProvider fileIoProvider) throws IOException
IOException
public void fsyncDirectory() throws IOException
IOException
Copyright © 2008–2018 Apache Software Foundation. All rights reserved.