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