public class AgentLockService extends Object implements LockLevelService, ServiceLifecycle, AgentService
| Modifier and Type | Class and Description |
|---|---|
static interface |
AgentLockService.AgentLockUpdateListener
Interface for being notified of lock update events.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
LOCK_MANAGER_SUBSYSTEM_NAME |
| Constructor and Description |
|---|
AgentLockService() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAgentLockUpdateListener(AgentLockService.AgentLockUpdateListener slul) |
void |
attachLock(String agentName)
Request for this agent to attach a lock on the given subsystem that is
already owned by the user.
|
void |
destroyLock(String agentName,
String userId)
Destroys a lock.
|
void |
detachLock(String agentName)
Request for this agent to detach a lock on the given subsystem.
|
AgentLoginService |
getAgentLoginService() |
String |
getAgentServiceName()
Get the name of this service.
|
AgentStateService |
getAgentStateService() |
List<String> |
getAllWorkerAgents() |
List<String> |
getAttachableAgents() |
List<String> |
getDetachableAgents() |
AgentLock |
getExistingLockForAgent(String agentName)
Returns a lock for the specified subsystem if there is one,
null otherwise. |
Map<String,AgentLock> |
getHeldLocks()
Returns a map of attached locks.
|
int |
getLevelForAgent(String agentName)
Returns this agent's authorized level at which it can operate the specified subsystem.
|
List<String> |
getLocallyLockedAgents() |
List<String> |
getLockableAgents() |
List<String> |
getLockedAgents() |
AgentLock |
getLockForAgent(String agentName)
Returns a lock for the specified subsystem if there is one attached to this agent,
null otherwise. |
Map<String,AgentLock> |
getLocks()
Returns a map of all existing locks, regardless of who owns them and what agents they are attached to.
|
String |
getUserId()
Returns the current user.
|
void |
lockAgent(String agentName)
Request for this agent to obtain a lock on the given subsystem.
|
void |
preInit() |
void |
preStart()
Called from the enclosing
Subsystem when
org.lsst.ccs.Subsystem#start() has been called. |
void |
removeAgentLockUpdateListener(AgentLockService.AgentLockUpdateListener l) |
void |
setLevelForAgent(String agentName,
int level)
Set this agent's operational level for the given subsystem.
|
void |
unlockAgent(String agentName)
Request to release a lock on the given subsystem.
|
boolean |
validateLock(AgentLock lock)
Validate a lock object.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitafterBuild, afterInit, afterStart, preBuild, preShutdownstartForAgentpublic static final String LOCK_MANAGER_SUBSYSTEM_NAME
public AgentStateService getAgentStateService()
public AgentLoginService getAgentLoginService()
public String getAgentServiceName()
AgentServicegetAgentServiceName in interface AgentServicepublic void preInit()
preInit in interface ServiceLifecyclepublic void preStart()
ServiceLifecycleSubsystem when
org.lsst.ccs.Subsystem#start() has been called.
The preceding lifecycle step is HasLifecycle.postInit()
The following lifecycle step is HasLifecycle.start()
At the time it is called :
PhaseState is
INITIALIZING
connection with the messaging layer is effective, the enclosing
subsystem has started StatusHeartBeat
publication
preStart in interface ServiceLifecyclepublic void setLevelForAgent(String agentName, int level) throws UnauthorizedLevelException, UnauthorizedLockException
AgentLevelListener will be notified with the new level valueagentName - Target subsystem name.level - Desired level.UnauthorizedLevelException - If the lock on the target subsystem has been
successfully acquired, but the desired level
cannot be set because the current user is not
authorized to operate at that level.UnauthorizedLockException - If the target subsystem cannot be locked.RuntimeException - If there was a communication problem on
the buses.public int getLevelForAgent(String agentName)
getLevelForAgent in interface LockLevelServiceagentName - Target subsystem name.public AgentLock getLockForAgent(String agentName)
null otherwise.
In order to be returned by this method, the lock must be owned by the current user and attached to this agent.getLockForAgent in interface LockLevelServiceagentName - Target subsystem name.public AgentLock getExistingLockForAgent(String agentName)
null otherwise.
The lock might be owned by any user and attached to any agent.agentName - Target subsystem name.null otherwise.public void lockAgent(String agentName) throws UnauthorizedLockException
AgentLockUpdateListener will be notified. The list of owned valid
locks will be updated. This command will return only when the lock has been
acknowledged trough network exchanges.agentName - Target subsystem name.UnauthorizedLockException - If the target subsystem cannot be locked.RuntimeException - If there was a communication problem on the buses.public void unlockAgent(String agentName) throws UnauthorizedLockException
AgentLockUpdateListener
will be notified. The list of owned valid locks will be updated. Non-blocking.
Calling this method for an agent that is already unlocked has no effect.agentName - Target subsystem name.UnauthorizedLockException - If the target is locked, and the lock is not owned by the current user.RuntimeException - If there was a communication problem on the buses.public void attachLock(String agentName) throws UnauthorizedLockException
AgentLockUpdateListener will be notified. This command
will return only when the lock has been acknowledged trough network
exchanges.agentName - Target subsystem name.UnauthorizedLockException - If the user does not own a lock on the specified subsystem.RuntimeException - If there was a communication problem on the buses.public void detachLock(String agentName) throws UnauthorizedLockException
AgentLockUpdateListener will be notified. The list of
owned valid locks will be updated. Non-blocking.agentName - Target subsystem name.UnauthorizedLockException - If the user does not have a lock on the specified subsystem.RuntimeException - If there was a communication problem on the buses.public Map<String,AgentLock> getLocks()
public Map<String,AgentLock> getHeldLocks()
public boolean validateLock(AgentLock lock)
lock - the lock object to validatepublic String getUserId()
public void addAgentLockUpdateListener(AgentLockService.AgentLockUpdateListener slul)
slul - public void removeAgentLockUpdateListener(AgentLockService.AgentLockUpdateListener l)
Copyright © 2023 LSST. All rights reserved.