@InterfaceAudience.Private public class FileLink extends java.lang.Object
The Problem:
HFileLink is a more concrete implementation of the FileLink.
Back-references:
To help the CleanerChore to keep track of
the links to a particular file, during the FileLink creation, a new file is placed
inside a back-reference directory. There's one back-reference directory for each file that
has links, and in the directory there's one file per link.
HFileLink Example
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BACK_REFERENCES_DIRECTORY_PREFIX
Define the Back-reference directory name prefix: .links-
|
| Modifier | Constructor and Description |
|---|---|
protected |
FileLink() |
|
FileLink(java.util.Collection<Path> locations) |
|
FileLink(Path originPath,
Path... alternativePaths) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(java.lang.Object obj) |
boolean |
exists(FileSystem fs) |
Path |
getAvailablePath(FileSystem fs) |
static java.lang.String |
getBackReferenceFileName(Path dirPath)
Get the referenced file name from the reference link directory path.
|
static Path |
getBackReferencesDir(Path storeDir,
java.lang.String fileName)
Get the directory to store the link back references
|
FileStatus |
getFileStatus(FileSystem fs)
Get the FileStatus of the referenced file.
|
Path[] |
getLocations() |
int |
hashCode() |
static boolean |
isBackReferencesDir(Path dirPath)
Checks if the specified directory path is a back reference links folder.
|
FSDataInputStream |
open(FileSystem fs)
Open the FileLink for read.
|
FSDataInputStream |
open(FileSystem fs,
int bufferSize)
Open the FileLink for read.
|
protected void |
setLocations(Path originPath,
Path... alternativePaths)
NOTE: This method must be used only in the constructor!
It creates a List with the specified locations for the link.
|
java.lang.String |
toString() |
public static final java.lang.String BACK_REFERENCES_DIRECTORY_PREFIX
protected FileLink()
public FileLink(Path originPath,
Path... alternativePaths)
originPath - Original location of the file to linkalternativePaths - Alternative locations to look for the linked filepublic FileLink(java.util.Collection<Path> locations)
locations - locations to look for the linked filepublic Path[] getLocations()
public java.lang.String toString()
toString in class java.lang.Objectpublic boolean exists(FileSystem fs)
throws java.io.IOException
java.io.IOExceptionpublic Path getAvailablePath(FileSystem fs)
throws java.io.IOException
java.io.IOExceptionpublic FileStatus getFileStatus(FileSystem fs)
throws java.io.IOException
fs - FileSystem on which to get the file statusjava.io.IOException - on unexpected error.public FSDataInputStream open(FileSystem fs)
throws java.io.IOException
It uses a wrapper of FSDataInputStream that is agnostic to the location of the file, even if the file switches between locations.
fs - FileSystem on which to open the FileLinkjava.io.IOException - on unexpected error.public FSDataInputStream open(FileSystem fs,
int bufferSize)
throws java.io.IOException
It uses a wrapper of FSDataInputStream that is agnostic to the location of the file, even if the file switches between locations.
fs - FileSystem on which to open the FileLinkbufferSize - the size of the buffer to be used.java.io.IOException - on unexpected error.protected void setLocations(Path originPath,
Path... alternativePaths)
public static Path getBackReferencesDir(Path storeDir,
java.lang.String fileName)
To simplify the reference count process, during the FileLink creation a back-reference is added to the back-reference directory of the specified file.
storeDir - Root directory for the link reference folderfileName - File Name with linkspublic static java.lang.String getBackReferenceFileName(Path dirPath)
dirPath - Link references directory pathpublic static boolean isBackReferencesDir(Path dirPath)
dirPath - Directory path to verifypublic boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object