Class PeerAwareInstanceRegistryImpl

    • Field Detail

      • eurekaClient

        protected final com.netflix.discovery.EurekaClient eurekaClient
    • Constructor Detail

      • PeerAwareInstanceRegistryImpl

        @Inject
        public PeerAwareInstanceRegistryImpl​(EurekaServerConfig serverConfig,
                                             com.netflix.discovery.EurekaClientConfig clientConfig,
                                             ServerCodecs serverCodecs,
                                             com.netflix.discovery.EurekaClient eurekaClient,
                                             EurekaServerHttpClientFactory eurekaServerHttpClientFactory)
    • Method Detail

      • syncUp

        public int syncUp()
        Populates the registry information from a peer eureka node. This operation fails over to other nodes until the list is exhausted if the communication fails.
        Specified by:
        syncUp in interface PeerAwareInstanceRegistry
      • openForTraffic

        public void openForTraffic​(com.netflix.appinfo.ApplicationInfoManager applicationInfoManager,
                                   int count)
        Specified by:
        openForTraffic in interface InstanceRegistry
      • shouldAllowAccess

        public boolean shouldAllowAccess​(boolean remoteRegionRequired)
        Checks to see if the registry access is allowed or the server is in a situation where it does not all getting registry information. The server does not return registry information for a period specified in EurekaServerConfig.getWaitTimeInMsWhenSyncEmpty(), if it cannot get the registry information from the peer eureka nodes at start up.
        Specified by:
        shouldAllowAccess in interface PeerAwareInstanceRegistry
        Returns:
        false - if the instances count from a replica transfer returned zero and if the wait time has not elapsed, otherwise returns true
      • shouldAllowAccess

        public boolean shouldAllowAccess()
      • shouldAllowAccessMetric

        @Monitor(name="eurekaServer.registry.shouldAllowAccess",
                 type=GAUGE)
        public int shouldAllowAccessMetric()
      • getReplicaNodes

        @Deprecated
        public java.util.List<PeerEurekaNode> getReplicaNodes()
        Deprecated.
        use PeerEurekaNodes.getPeerEurekaNodes() directly. Gets the list of peer eureka nodes which is the list to replicate information to.
        Returns:
        the list of replica nodes.
      • cancel

        public boolean cancel​(java.lang.String appName,
                              java.lang.String id,
                              boolean isReplication)
        Description copied from class: AbstractInstanceRegistry
        Cancels the registration of an instance.

        This is normally invoked by a client when it shuts down informing the server to remove the instance from traffic.

        Specified by:
        cancel in interface LeaseManager<com.netflix.appinfo.InstanceInfo>
        Overrides:
        cancel in class AbstractInstanceRegistry
        Parameters:
        appName - the application name of the application.
        id - the unique identifier of the instance.
        isReplication - true if this is a replication event from other nodes, false otherwise.
        Returns:
        true if the instance was removed from the AbstractInstanceRegistry successfully, false otherwise.
      • register

        public void register​(com.netflix.appinfo.InstanceInfo info,
                             boolean isReplication)
        Registers the information about the InstanceInfo and replicates this information to all peer eureka nodes. If this is replication event from other replica nodes then it is not replicated.
        Specified by:
        register in interface PeerAwareInstanceRegistry
        Parameters:
        info - the InstanceInfo to be registered and replicated.
        isReplication - true if this is a replication event from other replica nodes, false otherwise.
      • statusUpdate

        public boolean statusUpdate​(java.lang.String appName,
                                    java.lang.String id,
                                    com.netflix.appinfo.InstanceInfo.InstanceStatus newStatus,
                                    java.lang.String lastDirtyTimestamp,
                                    boolean isReplication)
        Description copied from class: AbstractInstanceRegistry
        Updates the status of an instance. Normally happens to put an instance between InstanceInfo.InstanceStatus.OUT_OF_SERVICE and InstanceInfo.InstanceStatus.UP to put the instance in and out of traffic.
        Specified by:
        statusUpdate in interface InstanceRegistry
        Overrides:
        statusUpdate in class AbstractInstanceRegistry
        Parameters:
        appName - the application name of the instance.
        id - the unique identifier of the instance.
        newStatus - the new InstanceInfo.InstanceStatus.
        lastDirtyTimestamp - last timestamp when this instance information was updated.
        isReplication - true if this is a replication event from other nodes, false otherwise.
        Returns:
        true if the status was successfully updated, false otherwise.
      • deleteStatusOverride

        public boolean deleteStatusOverride​(java.lang.String appName,
                                            java.lang.String id,
                                            com.netflix.appinfo.InstanceInfo.InstanceStatus newStatus,
                                            java.lang.String lastDirtyTimestamp,
                                            boolean isReplication)
        Description copied from class: AbstractInstanceRegistry
        Removes status override for a give instance.
        Specified by:
        deleteStatusOverride in interface InstanceRegistry
        Overrides:
        deleteStatusOverride in class AbstractInstanceRegistry
        Parameters:
        appName - the application name of the instance.
        id - the unique identifier of the instance.
        newStatus - the new InstanceInfo.InstanceStatus.
        lastDirtyTimestamp - last timestamp when this instance information was updated.
        isReplication - true if this is a replication event from other nodes, false otherwise.
        Returns:
        true if the status was successfully updated, false otherwise.
      • statusUpdate

        public void statusUpdate​(java.lang.String asgName,
                                 ASGResource.ASGStatus newStatus,
                                 boolean isReplication)
        Replicate the ASG status updates to peer eureka nodes. If this event is a replication from other nodes, then it is not replicated to other nodes.
        Specified by:
        statusUpdate in interface PeerAwareInstanceRegistry
        Parameters:
        asgName - the asg name for which the status needs to be replicated.
        newStatus - the ASGResource.ASGStatus information that needs to be replicated.
        isReplication - true if this is a replication event from other nodes, false otherwise.
      • isLeaseExpirationEnabledMetric

        @Monitor(name="eurekaServer.registry.isLeaseExpirationEnabled",
                 type=GAUGE)
        public int isLeaseExpirationEnabledMetric()
      • isSelfPreservationModeEnabledMetric

        @Monitor(name="eurekaServer.registry.isSelfPreservationModeEnabled",
                 type=GAUGE)
        public int isSelfPreservationModeEnabledMetric()
      • getNextServerFromEureka

        public com.netflix.appinfo.InstanceInfo getNextServerFromEureka​(java.lang.String virtualHostname,
                                                                        boolean secure)
        Specified by:
        getNextServerFromEureka in interface com.netflix.discovery.shared.LookupService<java.lang.String>
      • getSortedApplications

        public java.util.List<com.netflix.discovery.shared.Application> getSortedApplications()
        Gets the list of all Applications from the registry in sorted lexical order of Application.getName().
        Specified by:
        getSortedApplications in interface InstanceRegistry
        Returns:
        the list of Applications in lexical order.
      • getNumOfReplicationsInLastMin

        @Monitor(name="numOfReplicationsInLastMin",
                 description="Number of total replications received in the last minute",
                 type=GAUGE)
        public long getNumOfReplicationsInLastMin()
        Gets the number of renewals in the last minute.
        Returns:
        a long value representing the number of renewals in the last minute.
      • isBelowRenewThresold

        @Monitor(name="isBelowRenewThreshold",
                 description="0 = false, 1 = true",
                 type=GAUGE)
        public int isBelowRenewThresold()
        Checks if the number of renewals is lesser than threshold.
        Specified by:
        isBelowRenewThresold in interface InstanceRegistry
        Returns:
        0 if the renewals are greater than threshold, 1 otherwise.
      • isRegisterable

        public boolean isRegisterable​(com.netflix.appinfo.InstanceInfo instanceInfo)
        Checks if an instance is registerable in this region. Instances from other regions are rejected.
        Parameters:
        instanceInfo - th instance info information of the instance
        Returns:
        true, if it can be registered in this server, false otherwise.