Skip to content

Commit

Permalink
Merge pull request #668 from tbak/master
Browse files Browse the repository at this point in the history
1.x Fix bug in PeerEurekaNode, that did not check for missing LeaseInfo
  • Loading branch information
tbak committed Oct 2, 2015
2 parents 507bb14 + 4d70b37 commit a07a839
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.netflix.eureka.EurekaServerConfig;
import com.netflix.eureka.PeerAwareInstanceRegistry;
import com.netflix.eureka.PeerAwareInstanceRegistryImpl.Action;
import com.netflix.eureka.lease.Lease;
import com.netflix.eureka.resources.ASGResource.ASGStatus;
import com.netflix.eureka.util.batcher.TaskDispatcher;
import com.netflix.eureka.util.batcher.TaskDispatchers;
Expand Down Expand Up @@ -131,7 +132,7 @@ public PeerEurekaNode(PeerAwareInstanceRegistry registry, String targetHost, Str
* @throws Exception
*/
public void register(final InstanceInfo info) throws Exception {
long expiryTime = System.currentTimeMillis() + info.getLeaseInfo().getRenewalIntervalInSecs() * 1000;
long expiryTime = System.currentTimeMillis() + getLeaseRenewalOf(info);
batchingDispatcher.process(
taskId("register", info),
new InstanceReplicationTask(targetHost, Action.Register, info, null, true) {
Expand Down Expand Up @@ -222,7 +223,7 @@ public void handleFailure(int statusCode, Object responseEntity) throws Throwabl
}
}
};
long expiryTime = System.currentTimeMillis() + info.getLeaseInfo().getRenewalIntervalInSecs() * 1000;
long expiryTime = System.currentTimeMillis() + getLeaseRenewalOf(info);
batchingDispatcher.process(taskId("heartbeat", info), replicationTask, expiryTime);
}

Expand Down Expand Up @@ -388,4 +389,8 @@ private static String taskId(String requestType, String appName, String id) {
private static String taskId(String requestType, InstanceInfo info) {
return taskId(requestType, info.getAppName(), info.getId());
}

private static int getLeaseRenewalOf(InstanceInfo info) {
return (info.getLeaseInfo() == null ? Lease.DEFAULT_DURATION_IN_SECS : info.getLeaseInfo().getRenewalIntervalInSecs()) * 1000;
}
}

0 comments on commit a07a839

Please sign in to comment.