Class HardLink.HardLinkCGUnix

java.lang.Object
org.apache.bookkeeper.util.HardLink.HardLinkCGUnix
Enclosing class:
HardLink

static class HardLink.HardLinkCGUnix extends Object
Implementation of HardLinkCommandGetter class for Unix.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) int
    getLinkMultArgLength(File fileDir, String[] fileBaseNames, File linkDir)
    Calculate the total string length of the shell command resulting from execution of linkMult, plus the length of the source directory name (which will also be provided to the shell).
    (package private) int
    Get the maximum allowed string length of a shell command on this OS, which is just the documented minimum guaranteed supported command length - aprx.
    (package private) String[]
    Get the command string to query the hardlink count of a file.
    (package private) String[]
    linkMult(String[] fileBaseNames, File linkDir)
    Get the command string needed to hardlink a bunch of files from a single source directory into a target directory.
    (package private) String[]
    linkOne(File file, File linkName)
    Get the command string needed to hardlink a single file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • HardLinkCGUnix

      HardLinkCGUnix()
  • Method Details

    • linkOne

      String[] linkOne(File file, File linkName) throws IOException
      Get the command string needed to hardlink a single file.
      Throws:
      IOException
    • linkMult

      String[] linkMult(String[] fileBaseNames, File linkDir) throws IOException
      Get the command string needed to hardlink a bunch of files from a single source directory into a target directory. The source directory is not specified here, but the command will be executed using the source directory as the "current working directory" of the shell invocation.
      Parameters:
      fileBaseNames - - array of path-less file names, relative to the source directory
      linkDir - - target directory where the hardlinks will be put
      Returns:
      - an array of Strings suitable for use as a single shell command with Runtime.exec()
      Throws:
      IOException - - if any of the file or path names misbehave
    • linkCount

      String[] linkCount(File file) throws IOException
      Get the command string to query the hardlink count of a file.
      Throws:
      IOException
    • getLinkMultArgLength

      int getLinkMultArgLength(File fileDir, String[] fileBaseNames, File linkDir) throws IOException
      Calculate the total string length of the shell command resulting from execution of linkMult, plus the length of the source directory name (which will also be provided to the shell).
      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

      int getMaxAllowedCmdArgLength()
      Get the maximum allowed string length of a shell command on this OS, which is just the documented minimum guaranteed supported command length - aprx. 32KB for Unix, and 8KB for Windows.