@InterfaceAudience.Private public class FileLink extends 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 String | 
BACK_REFERENCES_DIRECTORY_PREFIX
Define the Back-reference directory name prefix: .links- 
 | 
| Modifier | Constructor and Description | 
|---|---|
protected  | 
FileLink()  | 
  | 
FileLink(Collection<Path> locations)  | 
  | 
FileLink(Path originPath,
        Path... alternativePaths)  | 
| Modifier and Type | Method and Description | 
|---|---|
boolean | 
equals(Object obj)  | 
boolean | 
exists(FileSystem fs)  | 
Path | 
getAvailablePath(FileSystem fs)  | 
static String | 
getBackReferenceFileName(Path dirPath)
Get the referenced file name from the reference link directory path. 
 | 
static Path | 
getBackReferencesDir(Path storeDir,
                    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. 
 | 
String | 
toString()  | 
public static final 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(Collection<Path> locations)
locations - locations to look for the linked filepublic Path[] getLocations()
public boolean exists(FileSystem fs)
               throws IOException
IOExceptionpublic Path getAvailablePath(FileSystem fs)
                      throws IOException
IOExceptionpublic FileStatus getFileStatus(FileSystem fs)
                         throws IOException
fs - FileSystem on which to get the file statusIOException - on unexpected error.public FSDataInputStream open(FileSystem fs)
                       throws 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 FileLinkIOException - on unexpected error.public FSDataInputStream open(FileSystem fs,
                              int bufferSize)
                       throws 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.IOException - on unexpected error.protected void setLocations(Path originPath,
                            Path... alternativePaths)
public static Path getBackReferencesDir(Path storeDir,
                                        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 String getBackReferenceFileName(Path dirPath)
dirPath - Link references directory pathpublic static boolean isBackReferencesDir(Path dirPath)
dirPath - Directory path to verify