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.
|
| 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 for this agent 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 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, IOException
AgentLevelListener will be notified with the new level valueagentName - the subsystem for which to change the levellevel - the level to setUnauthorizedLevelException - if the requested level cannot be set. This
happens if this agent owns a lock on the
given subsystem and that lock defines a
maximum level that is lower than the
requested level, or if this agent does not
hold a lock on the given subsystem and
this agent's default subsystem level is
lower than the requested level.UnauthorizedLockException - if the user is not allowed to acquire a
lock on the specified AgentIOException - 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, IOException
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 user is not allowed to acquire a
lock on the specified AgentIOException - if there was a communication problem on the
buses.public void unlockAgent(String agentName) throws UnauthorizedLockException, IOException
AgentLockUpdateListener will be notified. The
list of owned valid locks will be updated. Non-blocking.agentName - Target subsystem name.UnauthorizedLockException - if the user did not have a lock on the
specified AgentIOException - if there was a communication problem on the
buses.public void attachLock(String agentName) throws UnauthorizedLockException, IOException
AgentLockUpdateListener will be notified. This command
will return only when the lock has been acknowledged tbrough network
exchanges.agentName - Target subsystem name.UnauthorizedLockException - if the user is not allowed to acquire a
lock on the specified AgentIOException - if there was a communication problem on the
buses.public void detachLock(String agentName) throws UnauthorizedLockException, IOException
AgentLockUpdateListener will be notified. The list of
owned valid locks will be updated. Non-blocking.agentName - Target subsystem name.UnauthorizedLockException - if the user did not have a lock on the
specified AgentIOException - 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.