Class InstanceRegistry

java.lang.Object
com.netflix.eureka.registry.AbstractInstanceRegistry
com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl
org.springframework.cloud.netflix.eureka.server.InstanceRegistry
All Implemented Interfaces:
com.netflix.discovery.shared.LookupService<String>, com.netflix.eureka.lease.LeaseManager<com.netflix.appinfo.InstanceInfo>, com.netflix.eureka.registry.InstanceRegistry, com.netflix.eureka.registry.PeerAwareInstanceRegistry, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

public class InstanceRegistry extends com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl implements org.springframework.context.ApplicationContextAware
Author:
Spencer Gibb
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl

    com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl.Action
  • Field Summary

    Fields inherited from class com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl

    eurekaClient, peerEurekaNodes

    Fields inherited from class com.netflix.eureka.registry.AbstractInstanceRegistry

    allKnownRemoteRegions, clientConfig, expectedNumberOfClientsSendingRenews, lock, numberOfRenewsPerMinThreshold, overriddenInstanceStatusMap, regionNameVSRemoteRegistry, responseCache, serverCodecs, serverConfig
  • Constructor Summary

    Constructors
    Constructor
    Description
    InstanceRegistry(com.netflix.eureka.EurekaServerConfig serverConfig, com.netflix.discovery.EurekaClientConfig clientConfig, com.netflix.eureka.resources.ServerCodecs serverCodecs, com.netflix.discovery.EurekaClient eurekaClient, com.netflix.eureka.transport.EurekaServerHttpClientFactory eurekaServerHttpClientFactory, int expectedNumberOfClientsSendingRenews, int defaultOpenForTrafficCount)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    cancel(String appName, String serverId, boolean isReplication)
     
    protected boolean
    internalCancel(String appName, String id, boolean isReplication)
     
    void
    openForTraffic(com.netflix.appinfo.ApplicationInfoManager applicationInfoManager, int count)
    If PeerAwareInstanceRegistryImpl.openForTraffic(ApplicationInfoManager, int) is called with a zero argument, it means that leases are not automatically cancelled if the instance hasn't sent any renewals recently.
    void
    register(com.netflix.appinfo.InstanceInfo info, boolean isReplication)
     
    void
    register(com.netflix.appinfo.InstanceInfo info, int leaseDuration, boolean isReplication)
     
    boolean
    renew(String appName, String serverId, boolean isReplication)
     
    void
    setApplicationContext(org.springframework.context.ApplicationContext context)
     

    Methods inherited from class com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl

    deleteStatusOverride, getInstanceInfoOverrideRule, getLocalRegistrySize, getNextServerFromEureka, getNumOfReplicationsInLastMin, getReplicaNodes, getSortedApplications, init, isBelowRenewThresold, isLeaseExpirationEnabled, isLeaseExpirationEnabledMetric, isRegisterable, isSelfPreservationModeEnabled, isSelfPreservationModeEnabledMetric, shouldAllowAccess, shouldAllowAccess, shouldAllowAccessMetric, shutdown, statusUpdate, statusUpdate, syncUp

    Methods inherited from class com.netflix.eureka.registry.AbstractInstanceRegistry

    clearRegistry, evict, evict, getApplication, getApplication, getApplicationDeltas, getApplicationDeltasFromMultipleRegions, getApplications, getApplications, getApplicationsFromAllRemoteRegions, getApplicationsFromLocalRegionOnly, getApplicationsFromMultipleRegions, getInstanceByAppAndId, getInstanceByAppAndId, getInstancesById, getInstancesById, getLastNCanceledInstances, getLastNRegisteredInstances, getNumberofElementsininstanceCache, getNumOfRenewsInLastMin, getNumOfRenewsPerMinThreshold, getOverriddenInstanceStatus, getResponseCache, initializedResponseCache, initRemoteRegionRegistry, overriddenInstanceStatusesSnapshot, postInit, storeOverriddenStatusIfRequired, storeOverriddenStatusIfRequired, updateRenewsPerMinThreshold

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.netflix.eureka.registry.InstanceRegistry

    clearRegistry, getApplication, getApplicationsFromLocalRegionOnly, getInstanceByAppAndId, getInstanceByAppAndId, getLastNCanceledInstances, getLastNRegisteredInstances, getNumOfRenewsInLastMin, getNumOfRenewsPerMinThreshold, getResponseCache, initializedResponseCache, overriddenInstanceStatusesSnapshot, storeOverriddenStatusIfRequired, storeOverriddenStatusIfRequired

    Methods inherited from interface com.netflix.eureka.lease.LeaseManager

    evict

    Methods inherited from interface com.netflix.discovery.shared.LookupService

    getApplication, getApplications, getInstancesById
  • Constructor Details

    • InstanceRegistry

      public InstanceRegistry(com.netflix.eureka.EurekaServerConfig serverConfig, com.netflix.discovery.EurekaClientConfig clientConfig, com.netflix.eureka.resources.ServerCodecs serverCodecs, com.netflix.discovery.EurekaClient eurekaClient, com.netflix.eureka.transport.EurekaServerHttpClientFactory eurekaServerHttpClientFactory, int expectedNumberOfClientsSendingRenews, int defaultOpenForTrafficCount)
  • Method Details

    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext context) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • openForTraffic

      public void openForTraffic(com.netflix.appinfo.ApplicationInfoManager applicationInfoManager, int count)
      If PeerAwareInstanceRegistryImpl.openForTraffic(ApplicationInfoManager, int) is called with a zero argument, it means that leases are not automatically cancelled if the instance hasn't sent any renewals recently. This happens for a standalone server. It seems like a bad default, so we set it to the smallest non-zero value we can, so that any instances that subsequently register can bump up the threshold.
      Specified by:
      openForTraffic in interface com.netflix.eureka.registry.InstanceRegistry
      Overrides:
      openForTraffic in class com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl
    • register

      public void register(com.netflix.appinfo.InstanceInfo info, int leaseDuration, boolean isReplication)
      Specified by:
      register in interface com.netflix.eureka.lease.LeaseManager<com.netflix.appinfo.InstanceInfo>
      Overrides:
      register in class com.netflix.eureka.registry.AbstractInstanceRegistry
    • register

      public void register(com.netflix.appinfo.InstanceInfo info, boolean isReplication)
      Specified by:
      register in interface com.netflix.eureka.registry.PeerAwareInstanceRegistry
      Overrides:
      register in class com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl
    • cancel

      public boolean cancel(String appName, String serverId, boolean isReplication)
      Specified by:
      cancel in interface com.netflix.eureka.lease.LeaseManager<com.netflix.appinfo.InstanceInfo>
      Overrides:
      cancel in class com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl
    • renew

      public boolean renew(String appName, String serverId, boolean isReplication)
      Specified by:
      renew in interface com.netflix.eureka.lease.LeaseManager<com.netflix.appinfo.InstanceInfo>
      Overrides:
      renew in class com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl
    • internalCancel

      protected boolean internalCancel(String appName, String id, boolean isReplication)
      Overrides:
      internalCancel in class com.netflix.eureka.registry.AbstractInstanceRegistry