Netflix/eureka

eureka client not register it self ofter a long time network connection problem

オープン

#1,221 opened on 2019/06/22

 (1 件のコメント) (0 件のリアクション) (0 人の担当者)Java (3,712 件のフォーク)batch import
bughelp wanted

Repository metrics

Stars
 (12,190 個のスター)
PR merge metrics
 (PR metrics pending)

説明

  1. after a long time network connection problem
  2. client instance is removed from eureka server
  3. renew thread try to send heart beat but eureka server return 404
  4. sendHeartBeat throw TransportException with 404 status code
  5. in the code below, try to re-register client but cause step 4 throw exception, so the re-register logic not executed

boolean renew() {
        EurekaHttpResponse<InstanceInfo> httpResponse;
        try {
            httpResponse = eurekaTransport.registrationClient.sendHeartBeat(instanceInfo.getAppName(), instanceInfo.getId(), instanceInfo, null);
            logger.debug(PREFIX + "{} - Heartbeat status: {}", appPathIdentifier, httpResponse.getStatusCode());
            if (httpResponse.getStatusCode() == Status.NOT_FOUND.getStatusCode()) {
                REREGISTER_COUNTER.increment();
                logger.info(PREFIX + "{} - Re-registering apps/{}", appPathIdentifier, instanceInfo.getAppName());
                long timestamp = instanceInfo.setIsDirtyWithTime();
                boolean success = register();
                if (success) {
                    instanceInfo.unsetIsDirty(timestamp);
                }
                return success;
            }
            return httpResponse.getStatusCode() == Status.OK.getStatusCode();
        } catch (Throwable e) {
            logger.error(PREFIX + "{} - was unable to send heartbeat!", appPathIdentifier, e);
            return false;
        }
    }
  1. Eureka client always retry to send heartbeat with no re-register

コントリビューターガイド