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 and Description
    --- | ---
    `static class` | `HardLink.LinkStats` HardLink statistics counters and methods.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `HardLink.LinkStats` | `linkStats`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HardLink()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and 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.

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

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

- - ### Field Detail

    - #### linkStats

          public final HardLink.LinkStats linkStats

  - ### Constructor Detail

    - #### HardLink

          public HardLink()

  - ### Method Detail

    - #### 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`

    - #### 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`

    - #### getLinkCount

          public static int getLinkCount(File fileName)
                                  throws IOException

      Retrieves the number of links to the specified file.
      Throws:
        `IOException`

Copyright © 2008–2022 Apache Software Foundation. All rights reserved.