Class PosixNativeAccess

java.lang.Object
org.elasticsearch.nativeaccess.PosixNativeAccess
All Implemented Interfaces:
NativeAccess
Direct Known Subclasses:
LinuxNativeAccess, MacNativeAccess

public abstract class PosixNativeAccess extends Object
  • Field Details

    • libc

      protected final PosixCLibrary libc
    • vectorDistance

      protected final VectorSimilarityFunctions vectorDistance
    • constants

      protected final org.elasticsearch.nativeaccess.PosixConstants constants
    • processLimits

      protected final ProcessLimits processLimits
    • logger

      protected static final Logger logger
    • isMemoryLocked

      protected boolean isMemoryLocked
    • execSandboxState

      protected NativeAccess.ExecSandboxState execSandboxState
  • Method Details

    • getMaxThreads

      protected abstract long getMaxThreads()
      Return the maximum number of threads this process may start, or ProcessLimits.UNKNOWN.
    • getRLimit

      protected long getRLimit(int resource, String description)
      Return the current rlimit for the given resource. If getrlimit fails, returns ProcessLimits.UNKNOWN. If the rlimit is unlimited, returns ProcessLimits.UNLIMITED.
    • definitelyRunningAsRoot

      public boolean definitelyRunningAsRoot()
      Description copied from interface: NativeAccess
      Determine whether this JVM is running as the root user.
      Returns:
      true if running as root, or false if unsure
    • getProcessLimits

      public ProcessLimits getProcessLimits()
      Description copied from interface: NativeAccess
      Return limits for the current process.
    • tryLockMemory

      public void tryLockMemory()
      Description copied from interface: NativeAccess
      Attempt to lock this process's virtual memory address space into physical RAM.
    • logMemoryLimitInstructions

      protected abstract void logMemoryLimitInstructions()
    • allocatedSizeInBytes

      public OptionalLong allocatedSizeInBytes(Path path)
      Description copied from interface: NativeAccess
      Retrieves the actual number of bytes of disk storage used to store a specified file.
      Parameters:
      path - the path to the file
      Returns:
      an OptionalLong that contains the number of allocated bytes on disk for the file, or empty if the size is invalid
    • tryPreallocate

      public void tryPreallocate(Path file, long newSize)
    • nativePreallocate

      protected abstract boolean nativePreallocate(int fd, long currentSize, long newSize)
    • getVectorSimilarityFunctions

      public Optional<VectorSimilarityFunctions> getVectorSimilarityFunctions()
    • systemd

      public Systemd systemd()
      Specified by:
      systemd in interface NativeAccess
    • getZstd

      public Zstd getZstd()
      Description copied from interface: NativeAccess
      Returns an accessor to zstd compression functions.
      Specified by:
      getZstd in interface NativeAccess
      Returns:
      an object used to compress and decompress bytes using zstd
    • newSharedBuffer

      public CloseableByteBuffer newSharedBuffer(int len)
      Description copied from interface: NativeAccess
      Creates a new CloseableByteBuffer using a shared arena. The buffer can be used across multiple threads.
      Specified by:
      newSharedBuffer in interface NativeAccess
      Parameters:
      len - the number of bytes the buffer should allocate
      Returns:
      the buffer
    • newConfinedBuffer

      public CloseableByteBuffer newConfinedBuffer(int len)
      Description copied from interface: NativeAccess
      Creates a new CloseableByteBuffer using a confined arena. The buffer must be used within the same thread that it is created.
      Specified by:
      newConfinedBuffer in interface NativeAccess
      Parameters:
      len - the number of bytes the buffer should allocate
      Returns:
      the buffer
    • isMemoryLocked

      public boolean isMemoryLocked()
      Description copied from interface: NativeAccess
      Return whether locking memory was successful, or false otherwise.
      Specified by:
      isMemoryLocked in interface NativeAccess
    • getExecSandboxState

      public NativeAccess.ExecSandboxState getExecSandboxState()
      Description copied from interface: NativeAccess
      Return whether installing the exec system call filters was successful, and to what degree.
      Specified by:
      getExecSandboxState in interface NativeAccess