Package org.apache.hadoop.io.nativeio
Class NativeIO.POSIX
java.lang.Object
org.apache.hadoop.io.nativeio.NativeIO.POSIX
- Enclosing class:
- NativeIO
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classUsed to manipulate the operating system cache.static classA CacheManipulator used for testing which does not actually call mlock.static classJNI wrapper of persist memory operations.static classDenote memory region for a file mapped.static classResult type of the fstat callstatic enumKeeps the support state of PMDK. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic booleanstatic final intstatic final intstatic final intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic intstatic int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic NativeIO.POSIX.StatReturns the file stat for a file descriptor.static Stringstatic NativeIO.POSIX.StatReturn the file stat for a file path.static booleanstatic booleanstatic longmmap(FileDescriptor fd, int prot, boolean shared, long length) static voidmunmap(long addr, long length) static voidmunmap(MappedByteBuffer buffer) Unmaps the block from memory.static FileDescriptorWrapper around open(2) .static voidsetCacheManipulator(NativeIO.POSIX.CacheManipulator cacheManipulator) static voidsetPmdkSupportState(int stateCode) static voidsyncFileRangeIfPossible(FileDescriptor fd, long offset, long nbytes, int flags) Call sync_file_range on the given file descriptor.
-
Field Details
-
O_RDONLY
public static int O_RDONLY -
O_WRONLY
public static int O_WRONLY -
O_RDWR
public static int O_RDWR -
O_CREAT
public static int O_CREAT -
O_EXCL
public static int O_EXCL -
O_NOCTTY
public static int O_NOCTTY -
O_TRUNC
public static int O_TRUNC -
O_APPEND
public static int O_APPEND -
O_NONBLOCK
public static int O_NONBLOCK -
O_SYNC
public static int O_SYNC -
POSIX_FADV_NORMAL
public static int POSIX_FADV_NORMAL -
POSIX_FADV_RANDOM
public static int POSIX_FADV_RANDOM -
POSIX_FADV_SEQUENTIAL
public static int POSIX_FADV_SEQUENTIAL -
POSIX_FADV_WILLNEED
public static int POSIX_FADV_WILLNEED -
POSIX_FADV_DONTNEED
public static int POSIX_FADV_DONTNEED -
POSIX_FADV_NOREUSE
public static int POSIX_FADV_NOREUSE -
SYNC_FILE_RANGE_WAIT_BEFORE
public static int SYNC_FILE_RANGE_WAIT_BEFORE -
SYNC_FILE_RANGE_WRITE
public static int SYNC_FILE_RANGE_WRITE -
SYNC_FILE_RANGE_WAIT_AFTER
public static int SYNC_FILE_RANGE_WAIT_AFTER -
fadvisePossible
public static boolean fadvisePossible -
MMAP_PROT_READ
public static final int MMAP_PROT_READ- See Also:
-
MMAP_PROT_WRITE
public static final int MMAP_PROT_WRITE- See Also:
-
MMAP_PROT_EXEC
public static final int MMAP_PROT_EXEC- See Also:
-
-
Constructor Details
-
POSIX
public POSIX()
-
-
Method Details
-
getCacheManipulator
-
setCacheManipulator
-
setPmdkSupportState
public static void setPmdkSupportState(int stateCode) -
getPmdkSupportStateMessage
-
isPmdkAvailable
public static boolean isPmdkAvailable() -
isAvailable
public static boolean isAvailable()- Returns:
- Return true if the JNI-based native IO extensions are available.
-
open
Wrapper around open(2) .- Parameters:
path- input path.flags- input flags.mode- input mode.- Returns:
- FileDescriptor.
- Throws:
IOException- raised on errors performing I/O.
-
chmod
- Throws:
IOException
-
syncFileRangeIfPossible
public static void syncFileRangeIfPossible(FileDescriptor fd, long offset, long nbytes, int flags) throws NativeIOException Call sync_file_range on the given file descriptor. See the manpage for this syscall for more information. On systems where this call is not available, does nothing.- Parameters:
fd- input fd.offset- input offset.nbytes- input nbytes.flags- input flag.- Throws:
NativeIOException- if there is an error with the syscall
-
munmap
Unmaps the block from memory. See munmap(2). There isn't any portable way to unmap a memory region in Java. So we use the sun.nio method here. Note that unmapping a memory region could cause crashes if code continues to reference the unmapped code. However, if we don't manually unmap the memory, we are dependent on the finalizer to do it, and we have no idea when the finalizer will run.- Parameters:
buffer- The buffer to unmap.
-
getFstat
Returns the file stat for a file descriptor.- Parameters:
fd- file descriptor.- Returns:
- the file descriptor file stat.
- Throws:
IOException- thrown if there was an IO error while obtaining the file stat.
-
getStat
Return the file stat for a file path.- Parameters:
path- file path- Returns:
- the file stat
- Throws:
IOException- thrown if there is an IO error while obtaining the file stat
-
mmap
public static long mmap(FileDescriptor fd, int prot, boolean shared, long length) throws IOException - Throws:
IOException
-
munmap
- Throws:
IOException
-