Package org.apache.hadoop.fs
Class HardLink
java.lang.Object
org.apache.hadoop.fs.HardLink
- Direct Known Subclasses:
FileUtil.HardLink
Class for creating hardlinks.
Supports Unix/Linux, Windows via winutils , and Mac OS X.
The HardLink class was formerly a static inner class of FSUtil,
and the methods provided were blatantly non-thread-safe.
To enable volume-parallel Update snapshots, we now provide static
threadsafe methods that allocate new buffer string arrays
upon each call. We also provide an API to hardlink all files in a
directory with a single command, which is up to 128 times more
efficient - and minimizes the impact of the extra buffer creations.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHardLink statistics counters and methods. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcreateHardLink(File file, File linkName) Creates a hardlink.static voidcreateHardLinkMult(File parentDir, String[] fileBaseNames, File linkDir) Creates hardlinks from multiple existing files within one parent directory, into one target directory.static intgetLinkCount(File fileName) Retrieves the number of links to the specified file.static booleanDetermines whether the system supports hardlinks.
-
Field Details
-
linkStats
-
-
Constructor Details
-
HardLink
public HardLink()
-
-
Method Details
-
createHardLink
Creates a hardlink.- Parameters:
file- - existing source filelinkName- - desired target link file- Throws:
IOException- raised on errors performing I/O.
-
createHardLinkMult
public static void createHardLinkMult(File parentDir, String[] fileBaseNames, File linkDir) throws IOException Creates hardlinks from multiple existing files within one parent directory, into one target directory.- Parameters:
parentDir- - directory containing source filesfileBaseNames- - list of path-less file names, as returned by parentDir.list()linkDir- - where the hardlinks should be put. It must already exist.- Throws:
IOException- raised on errors performing I/O.
-
supportsHardLink
Determines whether the system supports hardlinks.- Parameters:
f- - file to examine- Returns:
- true if hardlinks are supported, false otherwise
-
getLinkCount
Retrieves the number of links to the specified file.- Parameters:
fileName- file name.- Returns:
- link count.
- Throws:
IOException- raised on errors performing I/O.
-