Class AgentRoutingServiceCuratorDiscoveryImpl

  • All Implemented Interfaces:
    AgentRoutingService

    public class AgentRoutingServiceCuratorDiscoveryImpl
    extends java.lang.Object
    implements AgentRoutingService
    Implementation of AgentRoutingService that relies on Curator's Discovery extension. Rather than the traditional use of this recipe (register a service for the node itself, this class registers one service instance for each agent locally connected.
    Since:
    4.0.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Optional<java.lang.String> getHostnameForAgentConnection​(@NotBlank java.lang.String jobId)
      Look up the hostname of the Genie node currently handling the agent connection for a given job.
      void handleClientConnected​(@NotBlank java.lang.String jobId)
      Handle a new agent connection.
      void handleClientDisconnected​(@NotBlank java.lang.String jobId)
      Handle connected agent disconnection.
      boolean isAgentConnected​(java.lang.String jobId)
      Whether the agent executing a given job is currently connected.
      boolean isAgentConnectionLocal​(@NotBlank java.lang.String jobId)
      Tells whether the agent running a given job is connected to the local node.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AgentRoutingServiceCuratorDiscoveryImpl

        public AgentRoutingServiceCuratorDiscoveryImpl​(GenieHostInfo genieHostInfo,
                                                       org.apache.curator.x.discovery.ServiceDiscovery<AgentRoutingServiceCuratorDiscoveryImpl.Agent> serviceDiscovery,
                                                       org.springframework.scheduling.TaskScheduler taskScheduler,
                                                       org.apache.curator.framework.listen.Listenable<org.apache.curator.framework.state.ConnectionStateListener> listenableCuratorConnectionState,
                                                       io.micrometer.core.instrument.MeterRegistry registry,
                                                       AgentRoutingServiceProperties properties)
        Constructor.
        Parameters:
        genieHostInfo - The genie local host information
        serviceDiscovery - The service discovery client
        taskScheduler - The task scheduler
        listenableCuratorConnectionState - The listenable curator client connection status
        registry - The metrics registry
        properties - The service properties
    • Method Detail

      • getHostnameForAgentConnection

        public java.util.Optional<java.lang.String> getHostnameForAgentConnection​(@NotBlank
                                                                                  @NotBlank java.lang.String jobId)
        Look up the hostname of the Genie node currently handling the agent connection for a given job.
        Specified by:
        getHostnameForAgentConnection in interface AgentRoutingService
        Parameters:
        jobId - the job id
        Returns:
        a boxed hostname string, empty if the connection for the given job id is not found
      • isAgentConnectionLocal

        public boolean isAgentConnectionLocal​(@NotBlank
                                              @NotBlank java.lang.String jobId)
        Tells whether the agent running a given job is connected to the local node.
        Specified by:
        isAgentConnectionLocal in interface AgentRoutingService
        Parameters:
        jobId - the job id
        Returns:
        true if the agent has an active connection to this node
      • handleClientConnected

        public void handleClientConnected​(@NotBlank
                                          @NotBlank java.lang.String jobId)
        Description copied from interface: AgentRoutingService
        Handle a new agent connection.
        Specified by:
        handleClientConnected in interface AgentRoutingService
        Parameters:
        jobId - the job id the connected agent is running
      • handleClientDisconnected

        public void handleClientDisconnected​(@NotBlank
                                             @NotBlank java.lang.String jobId)
        Description copied from interface: AgentRoutingService
        Handle connected agent disconnection.
        Specified by:
        handleClientDisconnected in interface AgentRoutingService
        Parameters:
        jobId - the job id the disconnected agent is running
      • isAgentConnected

        public boolean isAgentConnected​(java.lang.String jobId)
        Whether the agent executing a given job is currently connected.
        Specified by:
        isAgentConnected in interface AgentRoutingService
        Parameters:
        jobId - the job id
        Returns:
        true if an agent running the job is connected