@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 | Class and Description | 
|---|---|
| private static class  | FileLink.FileLinkInputStreamFileLink InputStream that handles the switch between the original path
 and the alternative locations, when the file is moved. | 
| Modifier and Type | Field and Description | 
|---|---|
| static String | BACK_REFERENCES_DIRECTORY_PREFIXDefine the Back-reference directory name prefix: .links-<hfile>/ | 
| private org.apache.hadoop.fs.Path[] | locations | 
| private static org.slf4j.Logger | LOG | 
| Modifier | Constructor and Description | 
|---|---|
| protected  | FileLink() | 
|   | FileLink(Collection<org.apache.hadoop.fs.Path> locations) | 
|   | FileLink(org.apache.hadoop.fs.Path originPath,
        org.apache.hadoop.fs.Path... alternativePaths) | 
| Modifier and Type | Method and Description | 
|---|---|
| boolean | equals(Object obj) | 
| boolean | exists(org.apache.hadoop.fs.FileSystem fs) | 
| org.apache.hadoop.fs.Path | getAvailablePath(org.apache.hadoop.fs.FileSystem fs) | 
| static String | getBackReferenceFileName(org.apache.hadoop.fs.Path dirPath)Get the referenced file name from the reference link directory path. | 
| static org.apache.hadoop.fs.Path | getBackReferencesDir(org.apache.hadoop.fs.Path storeDir,
                    String fileName)Get the directory to store the link back references | 
| org.apache.hadoop.fs.FileStatus | getFileStatus(org.apache.hadoop.fs.FileSystem fs)Get the FileStatus of the referenced file. | 
| org.apache.hadoop.fs.Path[] | getLocations() | 
| private static IOException | handleAccessLocationException(FileLink fileLink,
                             IOException newException,
                             IOException previousException)Handle exceptions which are thrown when access locations of file link | 
| int | hashCode() | 
| static boolean | isBackReferencesDir(org.apache.hadoop.fs.Path dirPath)Checks if the specified directory path is a back reference links folder. | 
| org.apache.hadoop.fs.FSDataInputStream | open(org.apache.hadoop.fs.FileSystem fs)Open the FileLink for read. | 
| org.apache.hadoop.fs.FSDataInputStream | open(org.apache.hadoop.fs.FileSystem fs,
    int bufferSize)Open the FileLink for read. | 
| protected void | setLocations(org.apache.hadoop.fs.Path originPath,
            org.apache.hadoop.fs.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() | 
private static final org.slf4j.Logger LOG
public static final String BACK_REFERENCES_DIRECTORY_PREFIX
private org.apache.hadoop.fs.Path[] locations
protected FileLink()
public FileLink(org.apache.hadoop.fs.Path originPath, org.apache.hadoop.fs.Path... alternativePaths)
originPath - Original location of the file to linkalternativePaths - Alternative locations to look for the linked filepublic FileLink(Collection<org.apache.hadoop.fs.Path> locations)
locations - locations to look for the linked filepublic org.apache.hadoop.fs.Path[] getLocations()
public boolean exists(org.apache.hadoop.fs.FileSystem fs) throws IOException
IOExceptionpublic org.apache.hadoop.fs.Path getAvailablePath(org.apache.hadoop.fs.FileSystem fs) throws IOException
IOExceptionpublic org.apache.hadoop.fs.FileStatus getFileStatus(org.apache.hadoop.fs.FileSystem fs) throws IOException
fs - FileSystem on which to get the file statusIOException - on unexpected error.private static IOException handleAccessLocationException(FileLink fileLink, IOException newException, IOException previousException) throws IOException
fileLink - the file linknewException - the exception caught by access the current locationpreviousException - the previous exception caught by access the other locationsSnapshotScannerHDFSAclController.IOException - if the exception is neither AccessControlException nor
           FileNotFoundExceptionpublic org.apache.hadoop.fs.FSDataInputStream open(org.apache.hadoop.fs.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 org.apache.hadoop.fs.FSDataInputStream open(org.apache.hadoop.fs.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(org.apache.hadoop.fs.Path originPath, org.apache.hadoop.fs.Path... alternativePaths)
public static org.apache.hadoop.fs.Path getBackReferencesDir(org.apache.hadoop.fs.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(org.apache.hadoop.fs.Path dirPath)
dirPath - Link references directory pathpublic static boolean isBackReferencesDir(org.apache.hadoop.fs.Path dirPath)
dirPath - Directory path to verifyCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.