Class NodeServiceCache

java.lang.Object
i5.las2peer.p2p.NodeServiceCache

public class NodeServiceCache extends Object
Caches the knowledge about existing services
  • Constructor Details

    • NodeServiceCache

      public NodeServiceCache(Node parent, long lifeTime, int resultCount)
  • Method Details

    • setWaitForResults

      public void setWaitForResults(int c)
    • setLifeTimeSeconds

      public void setLifeTimeSeconds(int c)
    • setTimeoutMs

      public void setTimeoutMs(int timeoutMs)
    • clear

      public void clear()
      clears the global cache (needed for units tests)
    • getServiceAgentInstance

      public NodeServiceCache.ServiceInstance getServiceAgentInstance(ServiceNameVersion service, boolean exact, boolean localOnly, AgentImpl acting) throws AgentNotRegisteredException
      returns a service agent instance. whenever possible, a local version is preferred. it returns the newest version "available", where "available" does not refer to the network but to the set of service instances matching other parameters (node load, response time, ...)
      Parameters:
      service - the requested service
      exact - forces an exact version match
      localOnly - only look for local services
      acting - an acting agent invoking the service
      Returns:
      any service agent matching the requirements
      Throws:
      AgentNotRegisteredException - If the service agent is not registered
    • removeGlobalServiceInstance

      public void removeGlobalServiceInstance(NodeServiceCache.ServiceInstance instance)
      removes a global service instance to be called when an instance is detected as not available
      Parameters:
      instance - A service instance to remove
    • registerLocalService

      public void registerLocalService(ServiceAgentImpl agent)
      register a local service
      Parameters:
      agent - A service agent to register
    • unregisterLocalService

      public void unregisterLocalService(ServiceAgentImpl agent)
      unregister a local service
      Parameters:
      agent - A service agent to unregister
    • getLocalService

      public ServiceAgentImpl getLocalService(ServiceNameVersion service) throws AgentNotRegisteredException
      Gets a locally registered service agent
      Parameters:
      service - name and exact version of the service
      Returns:
      Returns the local service agent instance
      Throws:
      AgentNotRegisteredException - If no agent is registered
    • getLocalServiceNames

      public List<String> getLocalServiceNames()
    • getLocalServiceVersions

      public List<ServiceVersion> getLocalServiceVersions(String serviceName)