org.glassfish.api.admin
Class AdminCommandLock

java.lang.Object
  extended by org.glassfish.api.admin.AdminCommandLock

@Service
@Scoped(value=org.jvnet.hk2.component.Singleton.class)
public class AdminCommandLock
extends java.lang.Object

The implementation of the admin command lock.

Author:
Bill Shannon, Chris Kasso

Nested Class Summary
static class AdminCommandLock.SuspendStatus
          The status of a suspend command attempt.
 
Constructor Summary
AdminCommandLock()
           
 
Method Summary
 java.util.concurrent.locks.Lock getLock(AdminCommand command)
          Return the appropriate Lock object for the specified command.
 java.util.concurrent.locks.Lock getLock(AdminCommand command, java.lang.String owner)
          Return the appropriate Lock object for the specified command.
 java.util.concurrent.locks.Lock getLock(CommandLock.LockType type)
          Return the appropriate Lock object for the specified LockType.
 java.lang.String getLockMessage()
          Get the message to be returned if the lock could not be acquired.
 java.lang.String getLockOwner()
          Get the admin user id for the user who acquired the exclusive lock.
 java.util.Date getLockTimeOfAcquisition()
          Get the time the exclusive lock was acquired.
 boolean isSuspended()
          Indicates if commands are currently suspended.
 java.lang.Thread resumeCommands()
          Release the lock allowing the DAS to accept commands.
 AdminCommandLock.SuspendStatus suspendCommands(long timeout, java.lang.String lockOwner)
          Lock the DAS from accepting any commands annotated with a SHARED or EXCLUSIVE CommandLock.
 AdminCommandLock.SuspendStatus suspendCommands(long timeout, java.lang.String lockOwner, java.lang.String message)
          Lock the DAS from accepting any commands annotated with a SHARED or EXCLUSIVE CommandLock.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AdminCommandLock

public AdminCommandLock()
Method Detail

getLock

public java.util.concurrent.locks.Lock getLock(CommandLock.LockType type)
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

getLock

public java.util.concurrent.locks.Lock getLock(AdminCommand command)
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 java.util.concurrent.locks.Lock getLock(AdminCommand command,
                                               java.lang.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 object
owner - the authority who requested the lock
Returns:
the Lock object to use, or null if no lock needed
Throws:
AdminCommandLockTimeoutException
AdminCommandLockException

getLockOwner

public java.lang.String 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

public java.lang.String getLockMessage()
Get the message to be returned if the lock could not be acquired.

Returns:
the message indicating why the domain is locked.

getLockTimeOfAcquisition

public java.util.Date 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

public AdminCommandLock.SuspendStatus suspendCommands(long timeout,
                                                      java.lang.String lockOwner)
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 seconds
lockOwner - the user who acquired the lock
Returns:
status regarding acquisition of the lock

suspendCommands

public AdminCommandLock.SuspendStatus suspendCommands(long timeout,
                                                      java.lang.String lockOwner,
                                                      java.lang.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 seconds
lockOwner - the user who acquired the lock
message - message to return when a command is blocked
Returns:
status regarding acquisition of the lock

resumeCommands

public java.lang.Thread 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.


Copyright © 2012 GlassFish Community. All Rights Reserved.