Interface DiscoveryAgent

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void close()
      Stops the agent after which no new remote peers will be found.
      boolean isSchedulerRequired()
      Indicates if this DiscoveryAgent requires a ScheduledExecutorService in order to perform its discovery work.
      void resume()
      Resumes discovery by this agent if it was previously suspended.
      void setDiscoveryListener​(DiscoveryListener listener)
      Sets the discovery listener
      void setScheduler​(ScheduledExecutorService scheduler)
      Provider a ScheduledExecutorService to the DiscoveryAgent that requires a scheduler to perform its discovery work.
      void start()
      Starts the agent after which new remote peers can start to be found.
      void suspend()
      Suspends the Agent which suppresses any new attempts to discover remote peers until the agent is resumed.
    • Method Detail

      • isSchedulerRequired

        boolean isSchedulerRequired()
        Indicates if this DiscoveryAgent requires a ScheduledExecutorService in order to perform its discovery work.
        Returns:
        true if the agent requires that its parent provide it with a scheduler.
      • setScheduler

        void setScheduler​(ScheduledExecutorService scheduler)
        Provider a ScheduledExecutorService to the DiscoveryAgent that requires a scheduler to perform its discovery work. If the agent performs long polling style operations such as a socket read then it should not use the provided scheduler as that could block other agents from performing their own work.
        Parameters:
        scheduler - An initialized Scheduler service that this agent can use for its work.
      • setDiscoveryListener

        void setDiscoveryListener​(DiscoveryListener listener)
        Sets the discovery listener
        Parameters:
        listener - the listener to notify on discovery events, or null to clear.
      • close

        void close()
        Stops the agent after which no new remote peers will be found. This method should attempt to close any agent resources and if an error occurs it should handle it and not re-throw to the calling entity.
      • suspend

        void suspend()
        Suspends the Agent which suppresses any new attempts to discover remote peers until the agent is resumed. If the service is not able to be suspended then this method should not throw an Exception, simply return as if successful.
      • resume

        void resume()
        Resumes discovery by this agent if it was previously suspended. If the agent does not support being suspended or is closed this method should simply return without throwing any exceptions.