Class NativeIO.Windows

java.lang.Object
org.apache.hadoop.io.nativeio.NativeIO.Windows
Enclosing class:
NativeIO

public static class NativeIO.Windows extends Object
  • Field Details

  • Constructor Details

    • Windows

      public Windows()
  • Method Details

    • createDirectoryWithMode

      public static void createDirectoryWithMode(File path, int mode) throws IOException
      Create a directory with permissions set to the specified mode. By setting permissions at creation time, we avoid issues related to the user lacking WRITE_DAC rights on subsequent chmod calls. One example where this can occur is writing to an SMB share where the user does not have Full Control rights, and therefore WRITE_DAC is denied.
      Parameters:
      path - directory to create
      mode - permissions of new directory
      Throws:
      IOException - if there is an I/O error
    • createFile

      public static FileDescriptor createFile(String path, long desiredAccess, long shareMode, long creationDisposition) throws IOException
      Parameters:
      path - input path.
      desiredAccess - input desiredAccess.
      shareMode - input shareMode.
      creationDisposition - input creationDisposition.
      Returns:
      Wrapper around CreateFile() on Windows.
      Throws:
      IOException - raised on errors performing I/O.
    • createFileOutputStreamWithMode

      public static FileOutputStream createFileOutputStreamWithMode(File path, boolean append, int mode) throws IOException
      Create a file for write with permissions set to the specified mode. By setting permissions at creation time, we avoid issues related to the user lacking WRITE_DAC rights on subsequent chmod calls. One example where this can occur is writing to an SMB share where the user does not have Full Control rights, and therefore WRITE_DAC is denied. This method mimics the semantics implemented by the JDK in FileOutputStream. The file is opened for truncate or append, the sharing mode allows other readers and writers, and paths longer than MAX_PATH are supported. (See io_util_md.c in the JDK.)
      Parameters:
      path - file to create
      append - if true, then open file for append
      mode - permissions of new directory
      Returns:
      FileOutputStream of opened file
      Throws:
      IOException - if there is an I/O error
    • setFilePointer

      public static long setFilePointer(FileDescriptor fd, long distanceToMove, long moveMethod) throws IOException
      Parameters:
      fd - input fd.
      distanceToMove - input distanceToMove.
      moveMethod - input moveMethod.
      Returns:
      Wrapper around SetFilePointer() on Windows.
      Throws:
      IOException - raised on errors performing I/O.
    • access

      public static boolean access(String path, NativeIO.Windows.AccessRight desiredAccess) throws IOException
      Checks whether the current process has desired access rights on the given path. Longer term this native function can be substituted with JDK7 function Files#isReadable, isWritable, isExecutable.
      Parameters:
      path - input path
      desiredAccess - ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE
      Returns:
      true if access is allowed
      Throws:
      IOException - I/O exception on error
    • extendWorkingSetSize

      public static void extendWorkingSetSize(long delta) throws IOException
      Extends both the minimum and maximum working set size of the current process. This method gets the current minimum and maximum working set size, adds the requested amount to each and then sets the minimum and maximum working set size to the new values. Controlling the working set size of the process also controls the amount of memory it can lock.
      Parameters:
      delta - amount to increment minimum and maximum working set size
      Throws:
      IOException - for any error
      See Also:
      • NativeIO.POSIX.mlock(ByteBuffer, long)