Class CaptureAgentStateServiceImpl
java.lang.Object
org.opencastproject.capture.admin.impl.CaptureAgentStateServiceImpl
- All Implemented Interfaces:
CaptureAgentStateService,org.osgi.service.cm.ManagedServiceFactory
public class CaptureAgentStateServiceImpl
extends Object
implements CaptureAgentStateService, org.osgi.service.cm.ManagedServiceFactory
IMPL for the capture-admin service (MH-1336, MH-1394, MH-1457, MH-1475 and MH-1476).
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConfiguration key for capture agent timeout in minutes before being marked offlineprotected DBSessionprotected DBSessionFactoryprotected javax.persistence.EntityManagerFactoryThe factory used to generate the entity managerprotected ObjectA token to store in the miss cachestatic final StringThe name of the persistence unit for this classMaps the configuration PID to the agent ID, so agents can be updated via the configuration factory patternprotected SecurityServiceThe security service -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) voidvoidReturns an agent by its nameprotected AgentImplGets an agent by name and organization.getAgentCapabilities(String agentName) Returns the list of known agent capabilities.getAgentConfiguration(String agentName) Returns the list of known agent configurations.protected ThrowingFunction<javax.persistence.EntityManager, AgentImpl, NotFoundException> getAgentEntityQuery(String name, String organization) Gets an agent by name and organization, using an open entitymanager.getAgentState(String agentName) Returns the last known agent state by its nameReturns the list of known agents that the current user is authorized to schedule.getName()voidremoveAgent(String agentName) Remove an agent from the system, if the agent exists.booleansetAgentConfiguration(String agentName, Properties configuration) Sets the capabilities for the specified agentbooleansetAgentState(String agentName, String state) Sets a given agent's state.booleansetAgentUrl(String agentName, String agentUrl) voidsetDBSessionFactory(DBSessionFactory dbSessionFactory) voidsetSecurityService(SecurityService securityService) protected voidsetupAgentCache(int count, TimeUnit unit) protected voidupdateAgentInDatabase(AgentImpl agent) Updates or adds an agent to the database.protected AgentupdateCachedLastHeardFrom(Agent agent, String org) Mix in the last-seen timestamp from the agent cachevoidupdated(String pid, Dictionary<String, ?> properties)
-
Field Details
-
PERSISTENCE_UNIT
The name of the persistence unit for this class- See Also:
-
emf
protected javax.persistence.EntityManagerFactory emfThe factory used to generate the entity manager -
dbSessionFactory
-
db
-
securityService
The security service -
pidMap
Maps the configuration PID to the agent ID, so agents can be updated via the configuration factory pattern -
CAPTURE_AGENT_TIMEOUT_KEY
Configuration key for capture agent timeout in minutes before being marked offline- See Also:
-
nullToken
A token to store in the miss cache
-
-
Constructor Details
-
CaptureAgentStateServiceImpl
public CaptureAgentStateServiceImpl()
-
-
Method Details
-
setDBSessionFactory
-
setSecurityService
- Parameters:
securityService- the securityService to set
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) -
deactivate
public void deactivate() -
getAgent
Returns an agent by its name- Specified by:
getAgentin interfaceCaptureAgentStateService- Parameters:
name- The name of the agent.- Returns:
- The agent
- Throws:
NotFoundException- if no agent with the given name has been found- See Also:
-
getAgent
Gets an agent by name and organization.- Parameters:
name- the unique agent nameorg- the organization identifier- Returns:
- the agent
- Throws:
NotFoundException
-
getAgentEntityQuery
protected ThrowingFunction<javax.persistence.EntityManager,AgentImpl, getAgentEntityQueryNotFoundException> (String name, String organization) Gets an agent by name and organization, using an open entitymanager.- Parameters:
name- the unique agent nameorganization- the organization- Returns:
- the agent or
nullif no agent has been found
-
updateCachedLastHeardFrom
Mix in the last-seen timestamp from the agent cache- Parameters:
agent- The Agent you wish to updateorg- the organization- Returns:
- the agent
-
getAgentState
Returns the last known agent state by its name- Specified by:
getAgentStatein interfaceCaptureAgentStateService- Parameters:
agentName- The name of the agent.- Returns:
- The agent state
- Throws:
NotFoundException- if no agent with the given name has been found- See Also:
-
setAgentState
Sets a given agent's state. Note that this will create the agent if it does not already exist. The state should be defined inAgentState.- Specified by:
setAgentStatein interfaceCaptureAgentStateService- Parameters:
agentName- The name of the agent.state- The current state of the agent.- See Also:
-
setAgentUrl
- Specified by:
setAgentUrlin interfaceCaptureAgentStateService- Parameters:
agentName- The name of the agent.agentUrl- The url of the agent.- Throws:
NotFoundException- if no agent with the given name has been found- See Also:
-
removeAgent
Remove an agent from the system, if the agent exists.- Specified by:
removeAgentin interfaceCaptureAgentStateService- Parameters:
agentName- The name of the agent.- Throws:
NotFoundException- if no agent with the given name has been found- See Also:
-
getKnownAgents
Returns the list of known agents that the current user is authorized to schedule.- Specified by:
getKnownAgentsin interfaceCaptureAgentStateService- Returns:
- A
Mapof name-agent pairs. - See Also:
-
getAgentCapabilities
Returns the list of known agent capabilities.- Specified by:
getAgentCapabilitiesin interfaceCaptureAgentStateService- Returns:
- A
Propertiesof name-value capability pairs. - Throws:
NotFoundException- if no agent with the given name has been found- See Also:
-
getAgentConfiguration
Returns the list of known agent configurations.- Specified by:
getAgentConfigurationin interfaceCaptureAgentStateService- Returns:
- A
Propertiesof name-value configuration pairs. - Throws:
NotFoundException- if no agent with the given name has been found- See Also:
-
setAgentConfiguration
Sets the capabilities for the specified agent- Specified by:
setAgentConfigurationin interfaceCaptureAgentStateService- Parameters:
agentName-configuration-- Returns:
- One of the constants defined in this class
- See Also:
-
updateAgentInDatabase
Updates or adds an agent to the database.- Parameters:
agent- The Agent you wish to modify or add in the database.
-
getName
- Specified by:
getNamein interfaceorg.osgi.service.cm.ManagedServiceFactory- See Also:
-
setupAgentCache
-
updated
public void updated(String pid, Dictionary<String, ?> properties) throws org.osgi.service.cm.ConfigurationException- Specified by:
updatedin interfaceorg.osgi.service.cm.ManagedServiceFactory- Throws:
org.osgi.service.cm.ConfigurationException- See Also:
-
deleted
- Specified by:
deletedin interfaceorg.osgi.service.cm.ManagedServiceFactory- See Also:
-