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 Details

    • PERSISTENCE_UNIT

      public static final String PERSISTENCE_UNIT
      The name of the persistence unit for this class
      See Also:
    • emf

      protected javax.persistence.EntityManagerFactory emf
      The 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 securityService
      The security service
    • pidMap

      protected Map<String,String> pidMap
      Maps the configuration PID to the agent ID, so agents can be updated via the configuration factory pattern
    • CAPTURE_AGENT_TIMEOUT_KEY

      public static final String CAPTURE_AGENT_TIMEOUT_KEY
      Configuration key for capture agent timeout in minutes before being marked offline
      See Also:
    • nullToken

      protected Object 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:
      getAgent in interface org.opencastproject.capture.admin.api.CaptureAgentStateService
      Throws:
      org.opencastproject.util.NotFoundException
      See Also:
      • CaptureAgentStateService.getAgent(java.lang.String)
    • 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 name
      org - the organization identifier
      Returns:
      the agent
      Throws:
      org.opencastproject.util.NotFoundException
    • getAgentEntityQuery

      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.
      Parameters:
      name - the unique agent name
      organization - the organization
      Returns:
      the agent or null if 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 update
      org - the organization
      Returns:
      the agent
    • getAgentState

      public String getAgentState(String agentName) throws org.opencastproject.util.NotFoundException
      Specified by:
      getAgentState in interface org.opencastproject.capture.admin.api.CaptureAgentStateService
      Throws:
      org.opencastproject.util.NotFoundException
      See Also:
      • CaptureAgentStateService.getAgentState(java.lang.String)
    • setAgentState

      public boolean setAgentState(String agentName, String state)
      Specified by:
      setAgentState in interface org.opencastproject.capture.admin.api.CaptureAgentStateService
      See Also:
      • CaptureAgentStateService.setAgentState(java.lang.String, java.lang.String)
    • setAgentUrl

      public boolean setAgentUrl(String agentName, String agentUrl) throws org.opencastproject.util.NotFoundException
      Specified by:
      setAgentUrl in interface org.opencastproject.capture.admin.api.CaptureAgentStateService
      Throws:
      org.opencastproject.util.NotFoundException
      See Also:
      • CaptureAgentStateService.setAgentUrl(String, String)
    • removeAgent

      public void removeAgent(String agentName) throws org.opencastproject.util.NotFoundException
      Specified by:
      removeAgent in interface org.opencastproject.capture.admin.api.CaptureAgentStateService
      Throws:
      org.opencastproject.util.NotFoundException
      See Also:
      • CaptureAgentStateService.removeAgent(java.lang.String)
    • getKnownAgents

      public Map<String,org.opencastproject.capture.admin.api.Agent> getKnownAgents()
      Specified by:
      getKnownAgents in interface org.opencastproject.capture.admin.api.CaptureAgentStateService
      See Also:
      • CaptureAgentStateService.getKnownAgents()
    • getAgentCapabilities

      public Properties getAgentCapabilities(String agentName) throws org.opencastproject.util.NotFoundException
      Specified by:
      getAgentCapabilities in interface org.opencastproject.capture.admin.api.CaptureAgentStateService
      Throws:
      org.opencastproject.util.NotFoundException
      See Also:
      • CaptureAgentStateService.getAgentCapabilities(java.lang.String)
    • getAgentConfiguration

      public Properties getAgentConfiguration(String agentName) throws org.opencastproject.util.NotFoundException
      Specified by:
      getAgentConfiguration in interface org.opencastproject.capture.admin.api.CaptureAgentStateService
      Throws:
      org.opencastproject.util.NotFoundException
      See Also:
      • CaptureAgentStateService.getAgentConfiguration(java.lang.String)
    • setAgentConfiguration

      public boolean setAgentConfiguration(String agentName, Properties configuration)
      Specified by:
      setAgentConfiguration in interface org.opencastproject.capture.admin.api.CaptureAgentStateService
      See Also:
      • CaptureAgentStateService.setAgentConfiguration(java.lang.String, java.util.Properties)
    • updateAgentInDatabase

      protected void updateAgentInDatabase(AgentImpl agent)
      Updates or adds an agent to the database.
      Parameters:
      agent - The Agent you wish to modify or add in the database.
    • getName

      public String getName()
      Specified by:
      getName in interface org.osgi.service.cm.ManagedServiceFactory
      See Also:
      • ManagedServiceFactory.getName()
    • setupAgentCache

      protected void setupAgentCache(int count, TimeUnit unit)
    • updated

      public void updated(String pid, Dictionary<String,?> properties) throws org.osgi.service.cm.ConfigurationException
      Specified by:
      updated in interface org.osgi.service.cm.ManagedServiceFactory
      Throws:
      org.osgi.service.cm.ConfigurationException
      See Also:
      • ManagedServiceFactory.updated(java.lang.String, java.util.Dictionary)
    • deleted

      public void deleted(String pid)
      Specified by:
      deleted in interface org.osgi.service.cm.ManagedServiceFactory
      See Also:
      • ManagedServiceFactory.deleted(java.lang.String)