Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.hadoop.fs
Class HardLink

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

    public class HardLink

extends Object

Class for creating hardlinks. Supports Unix/Linux, WinXP/2003/Vista via Cygwin, 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
`static class` | `HardLink.LinkStats` HardLink statistics counters and methods.
`static class` | `HardLink.OSType`

Field Summary
`HardLink.LinkStats` | `linkStats`
`static HardLink.OSType` | `osType`

Constructor Summary
`HardLink()`

Method Summary
`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.
`protected static int` | `createHardLinkMult(File parentDir, String[] fileBaseNames, File linkDir, int maxLength)`
`static int` | `getLinkCount(File fileName)` Retrieves the number of links to the specified file.
`protected static int` | `getLinkMultArgLength(File fileDir, String[] fileBaseNames, File linkDir)` Calculate the nominal length of all contributors to the total commandstring length, including fixed overhead of the OS-dependent command.
`protected static int` | `getMaxAllowedCmdArgLength()` Return this private value for use by unit tests.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### osType

    public static HardLink.OSType osType

### linkStats

    public final HardLink.LinkStats linkStats

Constructor Detail

### HardLink

    public HardLink()

Method Detail

### getLinkMultArgLength

    protected static int getLinkMultArgLength(File fileDir,
                                              String[] fileBaseNames,
                                              File linkDir)
                                       throws IOException

  Calculate the nominal length of all contributors to the total commandstring length, including fixed overhead of the OS-dependent command. It's protected rather than private, to assist unit testing, but real clients are not expected to need it -- see the way createHardLinkMult() uses it internally so the user doesn't need to worry about it.

  Parameters:
    `fileDir` - - source directory, parent of fileBaseNames
    `fileBaseNames` - - array of path-less file names, relative to the source directory
    `linkDir` - - target directory where the hardlinks will be put
  Returns:
    - total data length (must not exceed maxAllowedCmdArgLength)
  Throws:
    `IOException`

### getMaxAllowedCmdArgLength

    protected static int getMaxAllowedCmdArgLength()

  Return this private value for use by unit tests. Shell commands are not allowed to have a total string length exceeding this size.

### 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. If the list of files is too long (overflows maxAllowedCmdArgLength), we will automatically split it into multiple invocations of the underlying method.
  Throws:
    `IOException`

### createHardLinkMult

    protected static int createHardLinkMult(File parentDir,
                                            String[] fileBaseNames,
                                            File linkDir,
                                            int maxLength)
                                     throws IOException

  Throws:
    `IOException`

### getLinkCount

    public static int getLinkCount(File fileName)
                            throws IOException

  Retrieves the number of links to the specified file.

  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2009 The Apache Software Foundation