Class CaptureAgentStateServiceImpl
java.lang.Object
org.opencastproject.capture.admin.impl.CaptureAgentStateServiceImpl
- All Implemented Interfaces:
org.opencastproject.capture.admin.api.CaptureAgentStateService,org.osgi.service.cm.ManagedServiceFactory
public class CaptureAgentStateServiceImpl
extends Object
implements org.opencastproject.capture.admin.api.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 org.opencastproject.db.DBSessionprotected org.opencastproject.db.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 org.opencastproject.security.api.SecurityServiceThe security service -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidactivate(org.osgi.service.component.ComponentContext cc) voidvoidorg.opencastproject.capture.admin.api.Agentprotected AgentImplGets an agent by name and organization.getAgentCapabilities(String agentName) getAgentConfiguration(String agentName) protected org.opencastproject.util.function.ThrowingFunction<javax.persistence.EntityManager, AgentImpl, org.opencastproject.util.NotFoundException> getAgentEntityQuery(String name, String organization) Gets an agent by name and organization, using an open entitymanager.getAgentState(String agentName) getName()voidremoveAgent(String agentName) booleansetAgentConfiguration(String agentName, Properties configuration) booleansetAgentState(String agentName, String state) booleansetAgentUrl(String agentName, String agentUrl) voidsetDBSessionFactory(org.opencastproject.db.DBSessionFactory dbSessionFactory) voidsetSecurityService(org.opencastproject.security.api.SecurityService securityService) protected voidsetupAgentCache(int count, TimeUnit unit) protected voidupdateAgentInDatabase(AgentImpl agent) Updates or adds an agent to the database.protected org.opencastproject.capture.admin.api.AgentupdateCachedLastHeardFrom(org.opencastproject.capture.admin.api.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
protected org.opencastproject.db.DBSessionFactory dbSessionFactory -
db
protected org.opencastproject.db.DBSession db -
securityService
protected org.opencastproject.security.api.SecurityService securityServiceThe 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
public void setDBSessionFactory(org.opencastproject.db.DBSessionFactory dbSessionFactory) -
setSecurityService
public void setSecurityService(org.opencastproject.security.api.SecurityService securityService) - Parameters:
securityService- the securityService to set
-
activate
public void activate(org.osgi.service.component.ComponentContext cc) -
deactivate
public void deactivate() -
getAgent
public org.opencastproject.capture.admin.api.Agent getAgent(String name) throws org.opencastproject.util.NotFoundException - Specified by:
getAgentin interfaceorg.opencastproject.capture.admin.api.CaptureAgentStateService- Throws:
org.opencastproject.util.NotFoundException- See Also:
-
getAgent
protected AgentImpl getAgent(String name, String org) throws org.opencastproject.util.NotFoundException Gets an agent by name and organization.- Parameters:
name- the unique agent nameorg- the organization identifier- Returns:
- the agent
- Throws:
org.opencastproject.util.NotFoundException
-
getAgentEntityQuery
protected org.opencastproject.util.function.ThrowingFunction<javax.persistence.EntityManager,AgentImpl, getAgentEntityQueryorg.opencastproject.util.NotFoundException> (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
protected org.opencastproject.capture.admin.api.Agent updateCachedLastHeardFrom(org.opencastproject.capture.admin.api.Agent agent, String org) Mix in the last-seen timestamp from the agent cache- Parameters:
agent- The Agent you wish to updateorg- the organization- Returns:
- the agent
-
getAgentState
- Specified by:
getAgentStatein interfaceorg.opencastproject.capture.admin.api.CaptureAgentStateService- Throws:
org.opencastproject.util.NotFoundException- See Also:
-
setAgentState
- Specified by:
setAgentStatein interfaceorg.opencastproject.capture.admin.api.CaptureAgentStateService- See Also:
-
setAgentUrl
public boolean setAgentUrl(String agentName, String agentUrl) throws org.opencastproject.util.NotFoundException - Specified by:
setAgentUrlin interfaceorg.opencastproject.capture.admin.api.CaptureAgentStateService- Throws:
org.opencastproject.util.NotFoundException- See Also:
-
removeAgent
- Specified by:
removeAgentin interfaceorg.opencastproject.capture.admin.api.CaptureAgentStateService- Throws:
org.opencastproject.util.NotFoundException- See Also:
-
getKnownAgents
- Specified by:
getKnownAgentsin interfaceorg.opencastproject.capture.admin.api.CaptureAgentStateService- See Also:
-
getAgentCapabilities
public Properties getAgentCapabilities(String agentName) throws org.opencastproject.util.NotFoundException - Specified by:
getAgentCapabilitiesin interfaceorg.opencastproject.capture.admin.api.CaptureAgentStateService- Throws:
org.opencastproject.util.NotFoundException- See Also:
-
getAgentConfiguration
public Properties getAgentConfiguration(String agentName) throws org.opencastproject.util.NotFoundException - Specified by:
getAgentConfigurationin interfaceorg.opencastproject.capture.admin.api.CaptureAgentStateService- Throws:
org.opencastproject.util.NotFoundException- See Also:
-
setAgentConfiguration
- Specified by:
setAgentConfigurationin interfaceorg.opencastproject.capture.admin.api.CaptureAgentStateService- 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:
-