HardLink (Apache Hadoop Common 3.5.0 API)
Description: declaration: package: org.apache.hadoop.fs, class: HardLink

Package org.apache.hadoop.fs

# Class HardLink

java.lang.Object
org.apache.hadoop.fs.HardLink

Direct Known Subclasses:
  `FileUtil.HardLink`

public class HardLink extends Object
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 Classes
  Modifier and Type
  Class
  Description
  `static class`
  `HardLink.LinkStats`
  HardLink statistics counters and methods.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `final HardLink.LinkStats`
  `linkStats`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HardLink()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static void`
  `createHardLink(File file, File linkName)`
  Creates a hardlink.
  `static void`
  `createHardLinkMult(File parentDir, String[] fileBaseNames, File linkDir)`
  Creates hardlinks from multiple existing files within one parent directory, into one target directory.
  `static int`
  `getLinkCount(File fileName)`
  Retrieves the number of links to the specified file.
  `static boolean`
  `supportsHardLink(File f)`
  Determines whether the system supports hardlinks.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### linkStats

    public final HardLink.LinkStats linkStats

- ## Constructor Details

  - ### HardLink

    public HardLink()

- ## Method Details

  - ### createHardLink

    public static void createHardLink(File file, File linkName) throws IOException
    Creates a hardlink.
    Parameters:
      `file` - - existing source file
      `linkName` - - 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 files
      `fileBaseNames` - - 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

    public static boolean supportsHardLink(File f)
    Determines whether the system supports hardlinks.
    Parameters:
      `f` - - file to examine
    Returns:
      true if hardlinks are supported, false otherwise

  - ### getLinkCount

    public static int getLinkCount(File fileName) throws IOException
    Retrieves the number of links to the specified file.
    Parameters:
      `fileName` - file name.
    Returns:
      link count.
    Throws:
      `IOException` - raised on errors performing I/O.