Package org.apache.hadoop.io.nativeio
Class NativeIO.Windows
java.lang.Object
org.apache.hadoop.io.nativeio.NativeIO.Windows
- Enclosing class:
- NativeIO
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumSupported list of Windows access right flags -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final longstatic final long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaccess(String path, NativeIO.Windows.AccessRight desiredAccess) Checks whether the current process has desired access rights on the given path.static voidcreateDirectoryWithMode(File path, int mode) Create a directory with permissions set to the specified mode.static FileDescriptorcreateFile(String path, long desiredAccess, long shareMode, long creationDisposition) static FileOutputStreamcreateFileOutputStreamWithMode(File path, boolean append, int mode) Create a file for write with permissions set to the specified mode.static voidextendWorkingSetSize(long delta) Extends both the minimum and maximum working set size of the current process.static longsetFilePointer(FileDescriptor fd, long distanceToMove, long moveMethod)
-
Field Details
-
GENERIC_READ
public static final long GENERIC_READ- See Also:
-
GENERIC_WRITE
public static final long GENERIC_WRITE- See Also:
-
FILE_SHARE_READ
public static final long FILE_SHARE_READ- See Also:
-
FILE_SHARE_WRITE
public static final long FILE_SHARE_WRITE- See Also:
-
FILE_SHARE_DELETE
public static final long FILE_SHARE_DELETE- See Also:
-
CREATE_NEW
public static final long CREATE_NEW- See Also:
-
CREATE_ALWAYS
public static final long CREATE_ALWAYS- See Also:
-
OPEN_EXISTING
public static final long OPEN_EXISTING- See Also:
-
OPEN_ALWAYS
public static final long OPEN_ALWAYS- See Also:
-
TRUNCATE_EXISTING
public static final long TRUNCATE_EXISTING- See Also:
-
FILE_BEGIN
public static final long FILE_BEGIN- See Also:
-
FILE_CURRENT
public static final long FILE_CURRENT- See Also:
-
FILE_END
public static final long FILE_END- See Also:
-
FILE_ATTRIBUTE_NORMAL
public static final long FILE_ATTRIBUTE_NORMAL- See Also:
-
-
Constructor Details
-
Windows
public Windows()
-
-
Method Details
-
createDirectoryWithMode
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 createmode- 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 inFileOutputStream. 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 createappend- if true, then open file for appendmode- 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 pathdesiredAccess- ACCESS_READ, ACCESS_WRITE or ACCESS_EXECUTE- Returns:
- true if access is allowed
- Throws:
IOException- I/O exception on error
-
extendWorkingSetSize
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)
-