Class EIPManager

  • All Implemented Interfaces:
    AwsBinder

    @Singleton
    public class EIPManager
    extends java.lang.Object
    implements AwsBinder
    An AWS specific elastic ip binding utility for binding eureka servers for a well known IP address.

    Eureka clients talk to Eureka servers bound with well known IP addresses since that is the most reliable mechanism to discover the Eureka servers. When Eureka servers come up they bind themselves to a well known elastic ip

    This binding mechanism gravitates towards one eureka server per zone for resilience. At least one elastic ip should be slotted for each eureka server in a zone. If more than eureka server is launched per zone and there are not enough elastic ips slotted, the server tries to pick a free EIP slotted for other zones and if it still cannot find a free EIP, waits and keeps trying.

    • Constructor Summary

      Constructors 
      Constructor Description
      EIPManager​(EurekaServerConfig serverConfig, com.netflix.discovery.EurekaClientConfig clientConfig, PeerAwareInstanceRegistry registry, com.netflix.appinfo.ApplicationInfoManager applicationInfoManager)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void bindEIP()
      Checks if an EIP is bound and optionally binds the EIP.
      java.util.Collection<java.lang.String> getCandidateEIPs​(java.lang.String myInstanceId, java.lang.String myZone)
      Get the list of EIPs in the order of preference depending on instance zone.
      boolean isEIPBound()
      Checks if an EIP is already bound to the instance.
      void shutdown()  
      void start()  
      void unbindEIP()
      Unbind the EIP that this instance is associated with.
      • Methods inherited from class java.lang.Object

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

      • EIPManager

        @Inject
        public EIPManager​(EurekaServerConfig serverConfig,
                          com.netflix.discovery.EurekaClientConfig clientConfig,
                          PeerAwareInstanceRegistry registry,
                          com.netflix.appinfo.ApplicationInfoManager applicationInfoManager)
    • Method Detail

      • start

        @PostConstruct
        public void start()
        Specified by:
        start in interface AwsBinder
      • shutdown

        @PreDestroy
        public void shutdown()
        Specified by:
        shutdown in interface AwsBinder
      • isEIPBound

        public boolean isEIPBound()
        Checks if an EIP is already bound to the instance.
        Returns:
        true if an EIP is bound, false otherwise
      • bindEIP

        public void bindEIP()
        Checks if an EIP is bound and optionally binds the EIP. The list of EIPs are arranged with the EIPs allocated in the zone first followed by other EIPs. If an EIP is already bound to this instance this method simply returns. Otherwise, this method tries to find an unused EIP based on information from AWS. If it cannot find any unused EIP this method, it will be retried for a specified interval. One of the following scenarios can happen here : 1) If the instance is already bound to an EIP as deemed by AWS, no action is taken. 2) If an EIP is already bound to another instance as deemed by AWS, that EIP is skipped. 3) If an EIP is not already bound to an instance and if this instance is not bound to an EIP, then the EIP is bound to this instance.
      • unbindEIP

        public void unbindEIP()
                       throws java.lang.Exception
        Unbind the EIP that this instance is associated with.
        Throws:
        java.lang.Exception
      • getCandidateEIPs

        public java.util.Collection<java.lang.String> getCandidateEIPs​(java.lang.String myInstanceId,
                                                                       java.lang.String myZone)
        Get the list of EIPs in the order of preference depending on instance zone.
        Parameters:
        myInstanceId - the instance id for this instance
        myZone - the zone where this instance is in
        Returns:
        Collection containing the list of available EIPs