Class VirtualMachine.ForOpenJ9.Dispatcher.ForJnaPosixEnvironment
java.lang.Object
net.bytebuddy.agent.VirtualMachine.ForOpenJ9.Dispatcher.ForJnaPosixEnvironment
- All Implemented Interfaces:
VirtualMachine.ForOpenJ9.Dispatcher
- Enclosing interface:
VirtualMachine.ForOpenJ9.Dispatcher
public static class VirtualMachine.ForOpenJ9.Dispatcher.ForJnaPosixEnvironment
extends Object
implements VirtualMachine.ForOpenJ9.Dispatcher
A connector implementation for a POSIX environment using JNA.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceAn API for interaction with POSIX systems.protected static interfaceRepresents a system that supports POSIX ownership.Nested classes/interfaces inherited from interface VirtualMachine.ForOpenJ9.Dispatcher
VirtualMachine.ForOpenJ9.Dispatcher.ForJnaPosixEnvironment, VirtualMachine.ForOpenJ9.Dispatcher.ForJnaWindowsEnvironment -
Field Summary
FieldsModifier and TypeFieldDescriptionThe JNA library to use.The POSIX owner provider to use. -
Constructor Summary
ConstructorsConstructorDescriptionForJnaPosixEnvironment(int attempts, long pause, TimeUnit timeUnit) Creates a new connector for a POSIX environment using JNA. -
Method Summary
Modifier and TypeMethodDescriptionvoidchownFileToUser(File file, long userId) Changes the ownership of a file.voiddecrementSemaphore(File directory, String name, boolean global, int count) Decrements a semaphore.intgetOwnerIdOf(File file) Returns the user id of the owner of the supplied file.getTemporaryFolder(String processId) Returns this machine's temporary folder.voidincrementSemaphore(File directory, String name, boolean global, int count) Increments a semaphore.booleanisExistingProcess(int processId) Returnstrueif the supplied process id is a running process.private voidnotifySemaphore(File directory, String name, int count, short operation, short flags, boolean acceptUnavailable) Notifies a POSIX semaphore.intpid()Returns the process id of this process.voidsetPermissions(File file, int permissions) Sets permissions for the supplied file.intuserId()Returns the user id of this process.
-
Field Details
-
library
The JNA library to use. -
provider
private final VirtualMachine.ForOpenJ9.Dispatcher.ForJnaPosixEnvironment.PosixOwnerProvider providerThe POSIX owner provider to use.
-
-
Constructor Details
-
ForJnaPosixEnvironment
Creates a new connector for a POSIX environment using JNA.- Parameters:
attempts- The maximum amount of attempts for checking the result of a foreign process.pause- The pause between two checks for another process to return.timeUnit- The time unit of the pause time.
-
-
Method Details
-
getTemporaryFolder
Returns this machine's temporary folder.- Specified by:
getTemporaryFolderin interfaceVirtualMachine.ForOpenJ9.Dispatcher- Parameters:
processId- The target process's id.- Returns:
- The temporary folder.
-
pid
public int pid()Returns the process id of this process.- Specified by:
pidin interfaceVirtualMachine.ForOpenJ9.Dispatcher- Returns:
- The process id of this process.
-
userId
public int userId()Returns the user id of this process.- Specified by:
userIdin interfaceVirtualMachine.ForOpenJ9.Dispatcher- Returns:
- The user id of this process
-
isExistingProcess
public boolean isExistingProcess(int processId) Returnstrueif the supplied process id is a running process.- Specified by:
isExistingProcessin interfaceVirtualMachine.ForOpenJ9.Dispatcher- Parameters:
processId- The process id to evaluate.- Returns:
trueif the supplied process id is currently running.
-
getOwnerIdOf
Returns the user id of the owner of the supplied file.- Specified by:
getOwnerIdOfin interfaceVirtualMachine.ForOpenJ9.Dispatcher- Parameters:
file- The file for which to locate the owner.- Returns:
- The owner id of the supplied file.
-
setPermissions
Sets permissions for the supplied file.- Specified by:
setPermissionsin interfaceVirtualMachine.ForOpenJ9.Dispatcher- Parameters:
file- The file for which to set the permissions.permissions- The permission bits to set.
-
incrementSemaphore
Increments a semaphore.- Specified by:
incrementSemaphorein interfaceVirtualMachine.ForOpenJ9.Dispatcher- Parameters:
directory- The sempahore's control directory.name- The semaphore's name.global-trueif the semaphore is in the global namespace (only applicable on Windows).count- The amount of increments.
-
decrementSemaphore
Decrements a semaphore.- Specified by:
decrementSemaphorein interfaceVirtualMachine.ForOpenJ9.Dispatcher- Parameters:
directory- The sempahore's control directory.name- The semaphore's name.global-trueif the semaphore is in the global namespace (only applicable on Windows).count- The amount of decrements.
-
chownFileToUser
Changes the ownership of a file. Can be called only if this process is owned by root.- Specified by:
chownFileToUserin interfaceVirtualMachine.ForOpenJ9.Dispatcher- Parameters:
file- The path of the file to change ownership of.userId- The user that should own the file.
-
notifySemaphore
private void notifySemaphore(File directory, String name, int count, short operation, short flags, boolean acceptUnavailable) Notifies a POSIX semaphore.- Parameters:
directory- The semaphore's directory.name- The semaphore's name.count- The amount of notifications to send.operation- The operation to apply.flags- The flags to set.acceptUnavailable-trueif aEAGAINcode should be accepted.
-