- All Known Implementing Classes:
LinuxNativeAccess,MacNativeAccess,PosixNativeAccess,WindowsNativeAccess
public interface NativeAccess
Provides access to native functionality needed by Elastisearch.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumPossible stats for execution filtering. -
Method Summary
Modifier and TypeMethodDescriptionallocatedSizeInBytes(Path path) Retrieves the actual number of bytes of disk storage used to store a specified file.booleanDetermine whether this JVM is running as the root user.Return whether installing the exec system call filters was successful, and to what degree.Return limits for the current process.getZstd()Returns an accessor to zstd compression functions.static NativeAccessinstance()Get the one and only instance ofNativeAccesswhich is specific to the running platform and JVM.booleanReturn whether locking memory was successful, or false otherwise.newConfinedBuffer(int len) Creates a newCloseableByteBufferusing a confined arena.newSharedBuffer(int len) Creates a newCloseableByteBufferusing a shared arena.static voidonLinux(Consumer<LinuxNativeAccess> callback) Run the given callback if the current platform is Linux.static <T> Optional<T> onLinuxReturn(Function<LinuxNativeAccess, T> callback) Run the given callback if the current platform is Linux and return a value.static voidonMac(Consumer<MacNativeAccess> callback) Run the given callback if the current platform is Mac.static <T> Optional<T> onMacReturn(Function<MacNativeAccess, T> callback) Run the given callback if the current platform is Mac and return a value.static voidonPosix(Consumer<PosixNativeAccess> callback) Run the given callback if the current platform is POSIX.static <T> Optional<T> onPosixReturn(Function<PosixNativeAccess, T> callback) Run the given callback if the current platform is POSIX and return a value.static voidonWindows(Consumer<WindowsNativeAccess> callback) Run the given callback if the current platform is Windows.static <T> Optional<T> onWindowsReturn(Function<WindowsNativeAccess, T> callback) Run the given callback if the current platform is Windows and return a value.systemd()voidAttempts to install a system call filter to block process execution.voidAttempt to lock this process's virtual memory address space into physical RAM.voidtryPreallocate(Path file, long size)
-
Method Details
-
instance
Get the one and only instance ofNativeAccesswhich is specific to the running platform and JVM. -
onPosix
Run the given callback if the current platform is POSIX.- Parameters:
callback- A callback consuming a Posix-specific native access instance
-
onPosixReturn
Run the given callback if the current platform is POSIX and return a value.- Parameters:
callback- A callback consuming a Posix-specific native access instance and returning a value- Returns:
- An optional containing the result of the callback if the platform is POSIX, or empty otherwise
-
onWindows
Run the given callback if the current platform is Windows.- Parameters:
callback- A callback consuming a Windows-specific native access instance
-
onWindowsReturn
Run the given callback if the current platform is Windows and return a value.- Parameters:
callback- A callback consuming a Windows-specific native access instance and returning a value- Returns:
- An optional containing the result of the callback if the platform is Windows, or empty otherwise
-
onMac
Run the given callback if the current platform is Mac.- Parameters:
callback- A callback consuming a Mac-specific native access instance
-
onMacReturn
Run the given callback if the current platform is Mac and return a value.- Parameters:
callback- A callback consuming a Mac-specific native access instance and returning a value- Returns:
- An optional containing the result of the callback if the platform is Mac, or empty otherwise
-
onLinux
Run the given callback if the current platform is Linux.- Parameters:
callback- A callback consuming a Linux-specific native access instance
-
onLinuxReturn
Run the given callback if the current platform is Linux and return a value.- Parameters:
callback- A callback consuming a Linux-specific native access instance and returning a value- Returns:
- An optional containing the result of the callback if the platform is Linux, or empty otherwise
-
definitelyRunningAsRoot
boolean definitelyRunningAsRoot()Determine whether this JVM is running as the root user.- Returns:
- true if running as root, or false if unsure
-
getProcessLimits
ProcessLimits getProcessLimits()Return limits for the current process. -
tryLockMemory
void tryLockMemory()Attempt to lock this process's virtual memory address space into physical RAM. -
isMemoryLocked
boolean isMemoryLocked()Return whether locking memory was successful, or false otherwise. -
tryInstallExecSandbox
void tryInstallExecSandbox()Attempts to install a system call filter to block process execution. -
getExecSandboxState
NativeAccess.ExecSandboxState getExecSandboxState()Return whether installing the exec system call filters was successful, and to what degree. -
systemd
Systemd systemd() -
getZstd
Zstd getZstd()Returns an accessor to zstd compression functions.- Returns:
- an object used to compress and decompress bytes using zstd
-
allocatedSizeInBytes
Retrieves the actual number of bytes of disk storage used to store a specified file.- Parameters:
path- the path to the file- Returns:
- an
OptionalLongthat contains the number of allocated bytes on disk for the file, or empty if the size is invalid
-
tryPreallocate
-
getVectorSimilarityFunctions
Optional<VectorSimilarityFunctions> getVectorSimilarityFunctions() -
newConfinedBuffer
Creates a newCloseableByteBufferusing a confined arena. The buffer must be used within the same thread that it is created.- Parameters:
len- the number of bytes the buffer should allocate- Returns:
- the buffer
-