com.netflix.appinfo.HealthCheckCallback Java Examples

The following examples show how to use com.netflix.appinfo.HealthCheckCallback. 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: InitializeServletListener.java    From s2g-zuul with MIT License 5 votes vote down vote up
private void registerEureka() {
	DynamicBooleanProperty eurekaEnabled = DynamicPropertyFactory.getInstance().getBooleanProperty("eureka.enabled",
			true);
	if (!eurekaEnabled.get())
		return;

	EurekaInstanceConfig eurekaInstanceConfig = new PropertiesInstanceConfig() {
	};
       ConfigurationManager.getConfigInstance().setProperty("eureka.statusPageUrl","http://"+ getTurbineInstance());

	DiscoveryManager.getInstance().initComponent(eurekaInstanceConfig, new DefaultEurekaClientConfig());

	final DynamicStringProperty serverStatus = DynamicPropertyFactory.getInstance()
			.getStringProperty("server." + IPUtil.getLocalIP() + ".status", "up");
	DiscoveryManager.getInstance().getDiscoveryClient().registerHealthCheckCallback(new HealthCheckCallback() {
		@Override
		public boolean isHealthy() {
			return serverStatus.get().toLowerCase().equals("up");
		}
	});

	String version = String.valueOf(System.currentTimeMillis());
	String group = ConfigurationManager.getConfigInstance().getString("server.group", "default");
	String dataCenter = ConfigurationManager.getConfigInstance().getString("server.data-center", "default");

	Map<String, String> metadata = new HashMap<String, String>();
	metadata.put("version", version);
	metadata.put("group", group);
	metadata.put("dataCenter", dataCenter);

	String turbineInstance = getTurbineInstance();
	if (turbineInstance != null) {
		metadata.put("turbine.instance", turbineInstance);
	}

	ApplicationInfoManager.getInstance().registerAppMetadata(metadata);
}
 
Example #2
Source File: ChassisConfiguration.java    From chassis with Apache License 2.0 5 votes vote down vote up
/**
 * Initializes the health check registry
 *
 * @return health check registry bean
 */
@Bean
public HealthCheckRegistry healthCheckRegistry(ApplicationContext context, DiscoveryManager eureka) {
    final HealthCheckRegistry bean = new HealthCheckRegistry();

    // auto-register beans implementing health checks
    Map<String, HealthCheck> healthChecks = context.getBeansOfType(HealthCheck.class);
    for (HealthCheck check : healthChecks.values()) {
        bean.register(check.getClass().getName(), check);
    }

    // connect health checks into Eureka
    if (!disableEureka) {
        eureka.getDiscoveryClient().registerHealthCheckCallback(
                new HealthCheckCallback() {
                    @Override
                    public boolean isHealthy() {
                        for (Entry<String, HealthCheck.Result> entry : bean.runHealthChecks().entrySet()) {
                            if (!entry.getValue().isHealthy()) {
                                return false;
                            }
                        }
                        return true;
                    }
                });
    }

    return bean;
}
 
Example #3
Source File: EurekaServerStub.java    From titus-control-plane with Apache License 2.0 2 votes vote down vote up
@Override
public void registerHealthCheckCallback(HealthCheckCallback callback) {

}