Package org.glassfish.api.admin
Class AdminCommandLock
java.lang.Object
org.glassfish.api.admin.AdminCommandLock
The implementation of the admin command lock.
- Author:
- Bill Shannon, Chris Kasso
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The status of a suspend command attempt. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
getLock
(AdminCommand command) Return the appropriate Lock object for the specified command.getLock
(AdminCommand command, String owner) Return the appropriate Lock object for the specified command.getLock
(CommandLock.LockType type) Return the appropriate Lock object for the specified LockType.Get the message to be returned if the lock could not be acquired.Get the admin user id for the user who acquired the exclusive lock.Get the time the exclusive lock was acquired.boolean
Indicates if commands are currently suspended.Release the lock allowing the DAS to accept commands.static void
Use this method to temporarily suspend the command lock during which other operations may be performed.suspendCommands
(long timeout, String lockOwner) Lock the DAS from accepting any commands annotated with a SHARED or EXCLUSIVE CommandLock.suspendCommands
(long timeout, String lockOwner, String message) Lock the DAS from accepting any commands annotated with a SHARED or EXCLUSIVE CommandLock.
-
Constructor Details
-
AdminCommandLock
public AdminCommandLock()
-
-
Method Details
-
getLock
Return the appropriate Lock object for the specified LockType. The returned lock has not been locked. If the LockType is not SHARED or EXCLUSIVE null is returned.- Parameters:
type
- the LockType- Returns:
- the Lock object to use, or null
-
dumpState
-
getLock
Return the appropriate Lock object for the specified command. The returned lock has not been locked. If this command needs no lock, null is returned.- Parameters:
command
- the AdminCommand object- Returns:
- the Lock object to use, or null if no lock needed
-
getLock
public Lock getLock(AdminCommand command, String owner) throws AdminCommandLockTimeoutException, AdminCommandLockException Return the appropriate Lock object for the specified command. The returned lock has been locked. If this command needs no lock, null is returned.- Parameters:
command
- the AdminCommand objectowner
- the authority who requested the lock- Returns:
- the Lock object to use, or null if no lock needed
- Throws:
AdminCommandLockTimeoutException
AdminCommandLockException
-
getLockOwner
Get the admin user id for the user who acquired the exclusive lock. This does not imply the lock is still held.- Returns:
- the admin user who acquired the lock
-
getLockMessage
Get the message to be returned if the lock could not be acquired.- Returns:
- the message indicating why the domain is locked.
-
getLockTimeOfAcquisition
Get the time the exclusive lock was acquired. This does not imply the lock is still held.- Returns:
- the time the lock was acquired
-
isSuspended
public boolean isSuspended()Indicates if commands are currently suspended. -
suspendCommands
Lock the DAS from accepting any commands annotated with a SHARED or EXCLUSIVE CommandLock. This method will result in the acquisition of an EXCLUSIVE lock. This method will not return until the lock is acquired, it times out or an error occurs.- Parameters:
timeout
- lock timeout in secondslockOwner
- the user who acquired the lock- Returns:
- status regarding acquisition of the lock
-
suspendCommands
public AdminCommandLock.SuspendStatus suspendCommands(long timeout, String lockOwner, String message) Lock the DAS from accepting any commands annotated with a SHARED or EXCLUSIVE CommandLock. This method will result in the acquisition of an EXCLUSIVE lock. This method will not return until the lock is acquired, it times out or an error occurs.- Parameters:
timeout
- lock timeout in secondslockOwner
- the user who acquired the lockmessage
- message to return when a command is blocked- Returns:
- status regarding acquisition of the lock
-
resumeCommands
Release the lock allowing the DAS to accept commands. This method may return before the lock is released. When the thread exits the lock will have been released.- Returns:
- the thread maintaining the lock, null if the DAS is not in a suspended state. The caller may join() the thread to determine when the lock is released.
-
runWithSuspendedLock
Use this method to temporarily suspend the command lock during which other operations may be performed. When the method returns the lock will be reestablished. This method must be invoked from the same thread which acquired the original lock.- Parameters:
r
- A Runnable which will be invoked by the method after the lock is suspended
-