Commit 1a96e594 by Dave Syer

Do not override register() method in instance registry

The super class deals with syncing to peers, so we need that call. It still delegates to the other register method and seems to work just fine without the override. Fixes gh-838
parent 32b3ca41
...@@ -18,8 +18,6 @@ package org.springframework.cloud.netflix.eureka.server; ...@@ -18,8 +18,6 @@ package org.springframework.cloud.netflix.eureka.server;
import java.util.List; import java.util.List;
import lombok.extern.apachecommons.CommonsLog;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent; import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceCanceledEvent;
import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent; import org.springframework.cloud.netflix.eureka.server.event.EurekaInstanceRegisteredEvent;
...@@ -33,22 +31,25 @@ import com.netflix.discovery.EurekaClient; ...@@ -33,22 +31,25 @@ import com.netflix.discovery.EurekaClient;
import com.netflix.discovery.EurekaClientConfig; import com.netflix.discovery.EurekaClientConfig;
import com.netflix.discovery.shared.Application; import com.netflix.discovery.shared.Application;
import com.netflix.eureka.EurekaServerConfig; import com.netflix.eureka.EurekaServerConfig;
import com.netflix.eureka.lease.Lease;
import com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl; import com.netflix.eureka.registry.PeerAwareInstanceRegistryImpl;
import com.netflix.eureka.resources.ServerCodecs; import com.netflix.eureka.resources.ServerCodecs;
import lombok.extern.apachecommons.CommonsLog;
/** /**
* @author Spencer Gibb * @author Spencer Gibb
*/ */
@CommonsLog @CommonsLog
public class InstanceRegistry extends PeerAwareInstanceRegistryImpl implements ApplicationContextAware { public class InstanceRegistry extends PeerAwareInstanceRegistryImpl
implements ApplicationContextAware {
private ApplicationContext ctxt; private ApplicationContext ctxt;
private int defaultOpenForTrafficCount; private int defaultOpenForTrafficCount;
public InstanceRegistry(EurekaServerConfig serverConfig, public InstanceRegistry(EurekaServerConfig serverConfig,
EurekaClientConfig clientConfig, ServerCodecs serverCodecs, EurekaClientConfig clientConfig, ServerCodecs serverCodecs,
EurekaClient eurekaClient, int expectedNumberOfRenewsPerMin, int defaultOpenForTrafficCount) { EurekaClient eurekaClient, int expectedNumberOfRenewsPerMin,
int defaultOpenForTrafficCount) {
super(serverConfig, clientConfig, serverCodecs, eurekaClient); super(serverConfig, clientConfig, serverCodecs, eurekaClient);
this.expectedNumberOfRenewsPerMin = expectedNumberOfRenewsPerMin; this.expectedNumberOfRenewsPerMin = expectedNumberOfRenewsPerMin;
...@@ -61,29 +62,26 @@ public class InstanceRegistry extends PeerAwareInstanceRegistryImpl implements A ...@@ -61,29 +62,26 @@ public class InstanceRegistry extends PeerAwareInstanceRegistryImpl implements A
} }
/** /**
* If {@link PeerAwareInstanceRegistryImpl#openForTraffic(ApplicationInfoManager, int)} * If
* is called with a zero * argument, it means that leases are not * {@link PeerAwareInstanceRegistryImpl#openForTraffic(ApplicationInfoManager, int)}
* automatically * cancelled if the instance * hasn't sent any renewals * is called with a zero * argument, it means that leases are not automatically *
* recently. This happens for a standalone server. It seems like a bad * cancelled if the instance * hasn't sent any renewals recently. This happens for a
* default, so we set it to the smallest non-zero value we can, so that any * standalone server. It seems like a bad default, so we set it to the smallest
* instances that subsequently register can bump up the threshold. * non-zero value we can, so that any instances that subsequently register can bump up
* the threshold.
*/ */
@Override @Override
public void openForTraffic(ApplicationInfoManager applicationInfoManager, int count) { public void openForTraffic(ApplicationInfoManager applicationInfoManager, int count) {
super.openForTraffic(applicationInfoManager, count == 0 ? defaultOpenForTrafficCount : count); super.openForTraffic(applicationInfoManager,
} count == 0 ? this.defaultOpenForTrafficCount : count);
@Override
public void register(InstanceInfo info, boolean isReplication) {
register(info, Lease.DEFAULT_DURATION_IN_SECS, isReplication);
} }
@Override @Override
public void register(InstanceInfo info, int leaseDuration, boolean isReplication) { public void register(InstanceInfo info, int leaseDuration, boolean isReplication) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("register " + info.getAppName() + ", vip " + info.getVIPAddress() log.debug("register " + info.getAppName() + ", vip " + info.getVIPAddress()
+ ", leaseDuration " + leaseDuration + ", isReplication " + isReplication); + ", leaseDuration " + leaseDuration + ", isReplication "
+ isReplication);
} }
// TODO: what to publish from info (whole object?) // TODO: what to publish from info (whole object?)
this.ctxt.publishEvent(new EurekaInstanceRegisteredEvent(this, info, this.ctxt.publishEvent(new EurekaInstanceRegisteredEvent(this, info,
...@@ -98,8 +96,8 @@ public class InstanceRegistry extends PeerAwareInstanceRegistryImpl implements A ...@@ -98,8 +96,8 @@ public class InstanceRegistry extends PeerAwareInstanceRegistryImpl implements A
log.debug("cancel " + appName + " serverId " + serverId + ", isReplication {}" log.debug("cancel " + appName + " serverId " + serverId + ", isReplication {}"
+ isReplication); + isReplication);
} }
this.ctxt.publishEvent(new EurekaInstanceCanceledEvent(this, appName, serverId, this.ctxt.publishEvent(
isReplication)); new EurekaInstanceCanceledEvent(this, appName, serverId, isReplication));
return super.cancel(appName, serverId, isReplication); return super.cancel(appName, serverId, isReplication);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment