Commit 7423decc by Spencer Gibb

updated EurekaHealthIndicator to implement the new DiscoveryHealthIndicator

fixes gh-98
parent 70648b0e
...@@ -20,6 +20,8 @@ import static com.google.common.collect.Iterables.*; ...@@ -20,6 +20,8 @@ import static com.google.common.collect.Iterables.*;
*/ */
public class EurekaDiscoveryClient implements DiscoveryClient { public class EurekaDiscoveryClient implements DiscoveryClient {
public static final String DESCRIPTION = "Spring Cloud Eureka Discovery Client";
@Autowired @Autowired
private EurekaInstanceConfigBean config; private EurekaInstanceConfigBean config;
...@@ -27,6 +29,11 @@ public class EurekaDiscoveryClient implements DiscoveryClient { ...@@ -27,6 +29,11 @@ public class EurekaDiscoveryClient implements DiscoveryClient {
private com.netflix.discovery.DiscoveryClient discovery; private com.netflix.discovery.DiscoveryClient discovery;
@Override @Override
public String description() {
return DESCRIPTION;
}
@Override
public ServiceInstance getLocalServiceInstance() { public ServiceInstance getLocalServiceInstance() {
return new ServiceInstance() { return new ServiceInstance() {
@Override @Override
......
...@@ -21,7 +21,6 @@ import java.util.Map; ...@@ -21,7 +21,6 @@ import java.util.Map;
import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.Health.Builder; import org.springframework.boot.actuate.health.Health.Builder;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.boot.actuate.health.Status; import org.springframework.boot.actuate.health.Status;
import org.springframework.boot.actuate.metrics.Metric; import org.springframework.boot.actuate.metrics.Metric;
import org.springframework.boot.actuate.metrics.reader.MetricReader; import org.springframework.boot.actuate.metrics.reader.MetricReader;
...@@ -30,12 +29,13 @@ import com.netflix.appinfo.EurekaInstanceConfig; ...@@ -30,12 +29,13 @@ import com.netflix.appinfo.EurekaInstanceConfig;
import com.netflix.discovery.DiscoveryClient; import com.netflix.discovery.DiscoveryClient;
import com.netflix.discovery.shared.Application; import com.netflix.discovery.shared.Application;
import com.netflix.discovery.shared.Applications; import com.netflix.discovery.shared.Applications;
import org.springframework.cloud.client.discovery.DiscoveryHealthIndicator;
/** /**
* @author Dave Syer * @author Dave Syer
* *
*/ */
public class EurekaHealthIndicator implements HealthIndicator { public class EurekaHealthIndicator implements DiscoveryHealthIndicator {
private EurekaInstanceConfig instanceConfig; private EurekaInstanceConfig instanceConfig;
...@@ -54,6 +54,11 @@ public class EurekaHealthIndicator implements HealthIndicator { ...@@ -54,6 +54,11 @@ public class EurekaHealthIndicator implements HealthIndicator {
} }
@Override @Override
public String getName() {
return "eureka";
}
@Override
public Health health() { public Health health() {
Builder builder = Health.unknown(); Builder builder = Health.unknown();
Status status = getStatus(builder); Status status = getStatus(builder);
......
...@@ -9,7 +9,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; ...@@ -9,7 +9,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringJUnit4ClassRunner.class) @RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class) @SpringApplicationConfiguration(classes = EurekaSampleApplication.class)
@WebAppConfiguration @WebAppConfiguration
@IntegrationTest("server.port=0") @IntegrationTest("server.port=0")
@DirtiesContext @DirtiesContext
......
...@@ -2,6 +2,7 @@ package org.springframework.cloud.netflix.eureka.sample; ...@@ -2,6 +2,7 @@ package org.springframework.cloud.netflix.eureka.sample;
import com.netflix.appinfo.HealthCheckHandler; import com.netflix.appinfo.HealthCheckHandler;
import com.netflix.appinfo.InstanceInfo; import com.netflix.appinfo.InstanceInfo;
import org.springframework.boot.actuate.metrics.repository.InMemoryMetricRepository;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
...@@ -16,7 +17,12 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -16,7 +17,12 @@ import org.springframework.web.bind.annotation.RestController;
@EnableAutoConfiguration @EnableAutoConfiguration
@RestController @RestController
@EnableDiscoveryClient @EnableDiscoveryClient
public class Application { public class EurekaSampleApplication {
@Bean
public InMemoryMetricRepository inMemoryMetricRepository() {
return new InMemoryMetricRepository();
}
@Bean @Bean
public HealthCheckHandler healthCheckHandler() { public HealthCheckHandler healthCheckHandler() {
...@@ -34,7 +40,7 @@ public class Application { ...@@ -34,7 +40,7 @@ public class Application {
} }
public static void main(String[] args) { public static void main(String[] args) {
new SpringApplicationBuilder(Application.class).web(true).run(args); new SpringApplicationBuilder(EurekaSampleApplication.class).web(true).run(args);
} }
} }
package org.springframework.cloud.netflix.sidecar; package org.springframework.cloud.netflix.sidecar;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.actuate.metrics.repository.InMemoryMetricRepository;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication @SpringBootApplication
@EnableSidecar @EnableSidecar
@RestController @RestController
public class SidecarApplication { public class SidecarApplication {
@Bean
public InMemoryMetricRepository inMemoryMetricRepository() {
return new InMemoryMetricRepository();
}
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(SidecarApplication.class, args); SpringApplication.run(SidecarApplication.class, args);
} }
......
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