com.netflix.appinfo.HealthCheckHandler Java Examples

The following examples show how to use com.netflix.appinfo.HealthCheckHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DiscoveryClientConfig.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Bean(destroyMethod = "shutdown")
@RefreshScope
public ApimlDiscoveryClient eurekaClient(ApplicationInfoManager manager,
                                         EurekaClientConfig config,
                                         EurekaInstanceConfig instance,
                                         @Autowired(required = false) HealthCheckHandler healthCheckHandler
) {
    ApplicationInfoManager appManager;
    if (AopUtils.isAopProxy(manager)) {
        appManager = ProxyUtils.getTargetObject(manager);
    } else {
        appManager = manager;
    }
    final ApimlDiscoveryClient discoveryClientClient = new ApimlDiscoveryClient(appManager, config, this.optionalArgs, this.context);
    discoveryClientClient.registerHealthCheck(healthCheckHandler);

    discoveryClientClient.registerEventListener(event -> {
        if (event instanceof CacheRefreshedEvent) {
            refreshableRouteLocators.forEach(RefreshableRouteLocator::refresh);
            zuulHandlerMapping.setDirty(true);
        }
    });
    return discoveryClientClient;
}
 
Example #2
Source File: DiscoveryClientTestConfig.java    From api-layer with Eclipse Public License 2.0 6 votes vote down vote up
@Bean(destroyMethod = "shutdown")
@RefreshScope
public ApimlDiscoveryClientStub eurekaClient(ApplicationInfoManager manager,
                                             EurekaClientConfig config,
                                             EurekaInstanceConfig instance,
                                             @Autowired(required = false) HealthCheckHandler healthCheckHandler,
                                             ApplicationRegistry applicationRegistry
) {
    ApplicationInfoManager appManager;
    if (AopUtils.isAopProxy(manager)) {
        appManager = ProxyUtils.getTargetObject(manager);
    } else {
        appManager = manager;
    }

    final ApimlDiscoveryClientStub discoveryClient = new ApimlDiscoveryClientStub(appManager, config, this.optionalArgs, this.context, applicationRegistry);
    discoveryClient.registerHealthCheck(healthCheckHandler);

    discoveryClient.registerEventListener(event -> {
        if (event instanceof CacheRefreshedEvent) {
            refreshableRouteLocators.forEach(RefreshableRouteLocator::refresh);
            zuulHandlerMapping.setDirty(true);
        }
    });
    return discoveryClient;
}
 
Example #3
Source File: EurekaRegistration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
private EurekaRegistration(CloudEurekaInstanceConfig instanceConfig,
		EurekaClient eurekaClient, ApplicationInfoManager applicationInfoManager,
		ObjectProvider<HealthCheckHandler> healthCheckHandler) {
	this.eurekaClient = eurekaClient;
	this.instanceConfig = instanceConfig;
	this.applicationInfoManager = applicationInfoManager;
	this.healthCheckHandler = healthCheckHandler;
}
 
Example #4
Source File: EurekaClientAutoConfigurationTests.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldReregisterHealthCheckHandlerAfterRefresh() throws Exception {
	TestPropertyValues.of("eureka.client.healthcheck.enabled=true")
			.applyTo(this.context);
	setupContext(RefreshAutoConfiguration.class,
			AutoServiceRegistrationConfiguration.class);

	EurekaClient oldEurekaClient = getLazyInitEurekaClient();

	HealthCheckHandler healthCheckHandler = this.context
			.getBean("eurekaHealthCheckHandler", HealthCheckHandler.class);

	assertThat(healthCheckHandler).isInstanceOf(EurekaHealthCheckHandler.class);
	assertThat(oldEurekaClient.getHealthCheckHandler()).isSameAs(healthCheckHandler);

	ContextRefresher refresher = this.context.getBean("contextRefresher",
			ContextRefresher.class);
	refresher.refresh();

	EurekaClient newEurekaClient = getLazyInitEurekaClient();
	HealthCheckHandler newHealthCheckHandler = this.context
			.getBean("eurekaHealthCheckHandler", HealthCheckHandler.class);

	assertThat(healthCheckHandler).isSameAs(newHealthCheckHandler);
	assertThat(oldEurekaClient).isNotSameAs(newEurekaClient);
	assertThat(newEurekaClient.getHealthCheckHandler()).isSameAs(healthCheckHandler);
}
 
Example #5
Source File: EurekaClientAutoConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@org.springframework.cloud.context.config.annotation.RefreshScope
@ConditionalOnBean(AutoServiceRegistrationProperties.class)
@ConditionalOnProperty(
		value = "spring.cloud.service-registry.auto-registration.enabled",
		matchIfMissing = true)
public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient,
		CloudEurekaInstanceConfig instanceConfig,
		ApplicationInfoManager applicationInfoManager, @Autowired(
				required = false) ObjectProvider<HealthCheckHandler> healthCheckHandler) {
	return EurekaRegistration.builder(instanceConfig).with(applicationInfoManager)
			.with(eurekaClient).with(healthCheckHandler).build();
}
 
Example #6
Source File: EurekaClientAutoConfiguration.java    From spring-cloud-netflix with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnBean(AutoServiceRegistrationProperties.class)
@ConditionalOnProperty(
		value = "spring.cloud.service-registry.auto-registration.enabled",
		matchIfMissing = true)
public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient,
		CloudEurekaInstanceConfig instanceConfig,
		ApplicationInfoManager applicationInfoManager, @Autowired(
				required = false) ObjectProvider<HealthCheckHandler> healthCheckHandler) {
	return EurekaRegistration.builder(instanceConfig).with(applicationInfoManager)
			.with(eurekaClient).with(healthCheckHandler).build();
}
 
Example #7
Source File: MultRegisterCenterServerMgmtConfig.java    From Moss with Apache License 2.0 5 votes vote down vote up
public EurekaRegistration eurekaRegistration(EurekaClient eurekaClient,
                                             CloudEurekaInstanceConfig instanceConfig,
                                             ApplicationInfoManager applicationInfoManager,
                                             @Autowired(required = false) ObjectProvider<HealthCheckHandler> healthCheckHandler) {
    return EurekaRegistration.builder(instanceConfig)
            .with(applicationInfoManager)
            .with(eurekaClient)
            .with(healthCheckHandler)
            .build();
}
 
Example #8
Source File: EurekaHealthStatusBridgeModuleTest.java    From runtime-health with Apache License 2.0 5 votes vote down vote up
@Test
public void testHealthCheckHandlerRegistered() {
    InjectorBuilder.fromModules(new EurekaHealthStatusBridgeModule(), new AbstractModule() {
        @Override
        protected void configure() {
            bind(ApplicationInfoManager.class).toInstance(infoManager);
            bind(EurekaClient.class).toInstance(eurekaClient);
            bind(HealthCheckAggregator.class).toInstance(healthCheckAggregator);
        }
    }).createInjector();
    Mockito.verify(eurekaClient, Mockito.times(1)).registerHealthCheck(Mockito.any(HealthCheckHandler.class));
}
 
Example #9
Source File: EurekaRegisterHandler.java    From TarsJava with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public EurekaRegisterHandler(EurekaClient client, TarsEurekaInstance instanceConfig,
                             HealthCheckHandler healthCheckHandler, ApplicationInfoManager applicationInfoManager) {
    this.client = client;
    this.instanceConfig = instanceConfig;
    this.healthCheckHandler = healthCheckHandler;
    this.applicationInfoManager = applicationInfoManager;
}
 
Example #10
Source File: EurekaServerStub.java    From titus-control-plane with Apache License 2.0 4 votes vote down vote up
@Override
public HealthCheckHandler getHealthCheckHandler() {
    return null;
}
 
Example #11
Source File: EurekaRegistration.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
public ObjectProvider<HealthCheckHandler> getHealthCheckHandler() {
	return healthCheckHandler;
}
 
Example #12
Source File: EurekaRegistration.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
public void setHealthCheckHandler(
		ObjectProvider<HealthCheckHandler> healthCheckHandler) {
	this.healthCheckHandler = healthCheckHandler;
}
 
Example #13
Source File: EurekaRegistration.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
public Builder with(ObjectProvider<HealthCheckHandler> healthCheckHandler) {
	this.healthCheckHandler = healthCheckHandler;
	return this;
}
 
Example #14
Source File: TarsEurekaAutoConfiguration.java    From TarsJava with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Bean
public RegisterHandler registryHandler(EurekaClient client, TarsEurekaInstance instanceConfig,
                                       HealthCheckHandler healthCheckHandler,
                                       ApplicationInfoManager applicationInfoManager) {
    return new EurekaRegisterHandler(client, instanceConfig, healthCheckHandler, applicationInfoManager);
}
 
Example #15
Source File: EurekaDiscoveryClientConfiguration.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(HealthCheckHandler.class)
public EurekaHealthCheckHandler eurekaHealthCheckHandler() {
	return new EurekaHealthCheckHandler(this.statusAggregator);
}
 
Example #16
Source File: EurekaSampleApplication.java    From spring-cloud-netflix with Apache License 2.0 4 votes vote down vote up
@Bean
public HealthCheckHandler healthCheckHandler() {
	return currentStatus -> InstanceInfo.InstanceStatus.UP;
}
 
Example #17
Source File: TarsEurekaAutoConfiguration.java    From TarsJava with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = HealthCheckHandler.class, search = SearchStrategy.CURRENT)
public HealthCheckHandler HealthCheckHandler() {
    return new TarsEurekaHealthCheckHandler();
}
 
Example #18
Source File: EurekaServerStub.java    From titus-control-plane with Apache License 2.0 2 votes vote down vote up
@Override
public void registerHealthCheck(HealthCheckHandler healthCheckHandler) {

}