Commit 6435b73f by Spencer Gibb

remove EurekaHeartbeatEvent

parent 81bc8331
......@@ -20,7 +20,7 @@ import lombok.extern.apachecommons.CommonsLog;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.cloud.client.discovery.DiscoveryHeartbeatEvent;
import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
import org.springframework.context.ApplicationContext;
import com.netflix.appinfo.DataCenterInfo;
......@@ -160,7 +160,7 @@ public class DataCenterAwareMarshallingStrategy implements MarshallingStrategy {
if ("setVersion".equals(invocation.getMethod().getName())) {
Long version = Long.class.cast(invocation.getArguments()[0]);
log.debug("Applications.setVersion() called with version: " + version);
this.context.publishEvent(new DiscoveryHeartbeatEvent(invocation
this.context.publishEvent(new HeartbeatEvent(invocation
.getThis(), version));
}
return ret;
......
......@@ -16,6 +16,9 @@
package org.springframework.cloud.netflix.eureka;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -25,8 +28,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.builder.ParentContextApplicationContextInitializer;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.DiscoveryHeartbeatEvent;
import org.springframework.cloud.client.discovery.NoopDiscoveryClientAutoConfiguration;
import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
import org.springframework.cloud.client.discovery.event.ParentHeartbeatEvent;
import org.springframework.cloud.client.discovery.noop.NoopDiscoveryClientAutoConfiguration;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
......@@ -38,9 +42,6 @@ import com.netflix.discovery.EurekaClientConfig;
import com.netflix.discovery.converters.JsonXStream;
import com.netflix.discovery.converters.XmlXStream;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* @author Dave Syer
*/
......@@ -78,9 +79,9 @@ public class EurekaClientAutoConfiguration implements ApplicationListener<Parent
/**
* propagate DiscoveryHeartbeatEvent from parent to child.
* Do it via a EurekaHeartbeatEvent since events get published to the
* parent context, otherwise results in a stack overflow
* propagate HeartbeatEvent from parent to child. Do it via a
* ParentHeartbeatEvent since events get published to the parent context,
* otherwise results in a stack overflow
* @param event
*/
@Override
......@@ -93,10 +94,11 @@ public class EurekaClientAutoConfiguration implements ApplicationListener<Parent
if (listenerAdded.putIfAbsent(childId, childId) == null) {
@SuppressWarnings("resource")
ConfigurableApplicationContext ctx = (ConfigurableApplicationContext) parent;
ctx.addApplicationListener(new ApplicationListener<DiscoveryHeartbeatEvent>() {
ctx.addApplicationListener(new ApplicationListener<HeartbeatEvent>() {
@Override
public void onApplicationEvent(DiscoveryHeartbeatEvent dhe) {
context.publishEvent(new EurekaHeartbeatEvent(dhe));
public void onApplicationEvent(HeartbeatEvent dhe) {
context.publishEvent(new ParentHeartbeatEvent(dhe
.getSource(), dhe.getValue()));
}
});
}
......
......@@ -33,7 +33,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.InstanceRegisteredEvent;
import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationListener;
import org.springframework.context.SmartLifecycle;
......
......@@ -25,7 +25,7 @@ import org.springframework.boot.actuate.health.Health.Builder;
import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.boot.actuate.metrics.reader.MetricReader;
import org.springframework.cloud.client.discovery.DiscoveryHealthIndicator;
import org.springframework.cloud.client.discovery.health.DiscoveryHealthIndicator;
import com.netflix.appinfo.EurekaInstanceConfig;
import com.netflix.discovery.DiscoveryClient;
......
package org.springframework.cloud.netflix.eureka;
import org.springframework.cloud.client.discovery.DiscoveryHeartbeatEvent;
import org.springframework.context.ApplicationEvent;
/**
* Specifically used when eureka is in the parent bootstrap context to relay the DiscoveryHeartbeatEvent to the child. Avoids stack overflow
* @author Spencer Gibb
*
* TODO: create a ParentDiscoveryHeartbeatEvent in s-c-commons rather than eureka, so eureka doesn't leak into zuul (so zuul can be used with consul for example)
*/
@SuppressWarnings("serial")
public class EurekaHeartbeatEvent extends ApplicationEvent {
private final Object value;
public EurekaHeartbeatEvent(DiscoveryHeartbeatEvent e) {
super(e.getSource());
value = e.getValue();
}
public Object getValue() {
return value;
}
}
......@@ -27,8 +27,8 @@ import org.springframework.context.annotation.Import;
/**
* Sets up a Zuul server endpoint and installs some reverse proxy filters in it, so it can
* forward requests to backend servers. The backends can be registered manually through
* configuration or via Eureka.
* * forward requests to backend servers. The backends can be registered manually through
* * configuration or via DiscoveryClient.
*
* @see EnableZuulServer for how to get a Zuul server without any proxying
*
......@@ -41,5 +41,4 @@ import org.springframework.context.annotation.Import;
@Retention(RetentionPolicy.RUNTIME)
@Import(ZuulProxyConfiguration.class)
public @interface EnableZuulProxy {
}
......@@ -23,10 +23,10 @@ import org.springframework.boot.actuate.endpoint.Endpoint;
import org.springframework.boot.actuate.trace.TraceRepository;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.DiscoveryHeartbeatEvent;
import org.springframework.cloud.client.discovery.InstanceRegisteredEvent;
import org.springframework.cloud.client.discovery.event.HeartbeatEvent;
import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent;
import org.springframework.cloud.client.discovery.event.ParentHeartbeatEvent;
import org.springframework.cloud.context.scope.refresh.RefreshScopeRefreshedEvent;
import org.springframework.cloud.netflix.eureka.EurekaHeartbeatEvent;
import org.springframework.cloud.netflix.ribbon.SpringClientFactory;
import org.springframework.cloud.netflix.zuul.filters.ProxyRequestHelper;
import org.springframework.cloud.netflix.zuul.filters.ProxyRouteLocator;
......@@ -130,12 +130,12 @@ public class ZuulProxyConfiguration extends ZuulConfiguration {
|| event instanceof RoutesRefreshedEvent) {
reset();
}
else if (event instanceof EurekaHeartbeatEvent) {
EurekaHeartbeatEvent e = (EurekaHeartbeatEvent) event;
else if (event instanceof ParentHeartbeatEvent) {
ParentHeartbeatEvent e = (ParentHeartbeatEvent) event;
resetIfNeeded(e.getValue());
}
else if (event instanceof DiscoveryHeartbeatEvent) {
DiscoveryHeartbeatEvent e = (DiscoveryHeartbeatEvent) event;
else if (event instanceof HeartbeatEvent) {
HeartbeatEvent e = (HeartbeatEvent) event;
resetIfNeeded(e.getValue());
}
......
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