// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/commands/UpdateApplicationInstanceHealth.java
// public final class UpdateApplicationInstanceHealth {
// 
// 	private final String id;
// 	private final Status healthStatus;
// 
// 	public UpdateApplicationInstanceHealth(String id, Status healthStatus) {
// 		Assert.notNull(id, "id must not be null!");
// 		Assert.notNull(healthStatus, "healthStatus must not be null!");
// 
// 		this.id = id;
// 		this.healthStatus = healthStatus;
// 	}
// 
// 	public String getId() {
// 		return this.id;
// 	}
// 
// 	public Status getHealthStatus() {
// 		return this.healthStatus;
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ActuatorEndpointsUpdated.java
// public class ActuatorEndpointsUpdated extends ApplicationEvent {
// 
// 	public ActuatorEndpointsUpdated(ApplicationInstance instance) {
// 		super(instance);
// 	}
// 
// 	public ApplicationInstance getApplicationInstance() {
// 		return (ApplicationInstance) this.source;
// 	}
// 
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ApplicationInstanceHealthDataRetrievalFailed.java
// public class ApplicationInstanceHealthDataRetrievalFailed extends ApplicationEvent {
// 
// 	public ApplicationInstanceHealthDataRetrievalFailed(ApplicationInstance instance) {
// 		super(instance);
// 	}
// 
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ApplicationInstanceHealthDataRetrieved.java
// public class ApplicationInstanceHealthDataRetrieved extends ApplicationEvent {
// 
// 	private Health health;
// 
// 	public ApplicationInstanceHealthDataRetrieved(ApplicationInstance instance, Health health) {
// 		super(instance);
// 		this.health = health;
// 	}
// 
// 	public ApplicationInstance getApplicationInstance() {
// 		return (ApplicationInstance) this.source;
// 	}
// 
// 	public Health getHealth() {
// 		return this.health;
// 	}
// 
// }


import org.springframework.boot.actuate.health.Status;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.reactive.function.client.WebClient;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.ordina.msdashboard.applicationinstance.commands.UpdateApplicationInstanceHealth;
import be.ordina.msdashboard.applicationinstance.events.ActuatorEndpointsUpdated;
import be.ordina.msdashboard.applicationinstance.events.ApplicationInstanceHealthDataRetrievalFailed;
import be.ordina.msdashboard.applicationinstance.events.ApplicationInstanceHealthDataRetrieved;
import org.springframework.boot.actuate.health.Health;
/*
 * Copyright 2015-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package be.ordina.msdashboard.applicationinstance;





/**
 * Watcher that will check an application instance its health endpoint.
 *
 * @author Dieter Hubau
 * @author Tim Ysewyn
 */
public class ApplicationInstanceHealthWatcher {

	private static final Logger logger = LoggerFactory.getLogger(ApplicationInstanceHealthWatcher.class);

	private final WebClient webClient;
	private final ApplicationInstanceService applicationInstanceService;
	private final ApplicationEventPublisher publisher;

	ApplicationInstanceHealthWatcher(ApplicationInstanceService applicationInstanceService,
			WebClient webClient, ApplicationEventPublisher publisher) {
		this.applicationInstanceService = applicationInstanceService;
		this.webClient = webClient;
		this.publisher = publisher;
	}

// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/commands/UpdateApplicationInstanceHealth.java
// public final class UpdateApplicationInstanceHealth {
// 
// 	private final String id;
// 	private final Status healthStatus;
// 
// 	public UpdateApplicationInstanceHealth(String id, Status healthStatus) {
// 		Assert.notNull(id, "id must not be null!");
// 		Assert.notNull(healthStatus, "healthStatus must not be null!");
// 
// 		this.id = id;
// 		this.healthStatus = healthStatus;
// 	}
// 
// 	public String getId() {
// 		return this.id;
// 	}
// 
// 	public Status getHealthStatus() {
// 		return this.healthStatus;
// 	}
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ActuatorEndpointsUpdated.java
// public class ActuatorEndpointsUpdated extends ApplicationEvent {
// 
// 	public ActuatorEndpointsUpdated(ApplicationInstance instance) {
// 		super(instance);
// 	}
// 
// 	public ApplicationInstance getApplicationInstance() {
// 		return (ApplicationInstance) this.source;
// 	}
// 
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ApplicationInstanceHealthDataRetrievalFailed.java
// public class ApplicationInstanceHealthDataRetrievalFailed extends ApplicationEvent {
// 
// 	public ApplicationInstanceHealthDataRetrievalFailed(ApplicationInstance instance) {
// 		super(instance);
// 	}
// 
// }
// 
// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/events/ApplicationInstanceHealthDataRetrieved.java
// public class ApplicationInstanceHealthDataRetrieved extends ApplicationEvent {
// 
// 	private Health health;
// 
// 	public ApplicationInstanceHealthDataRetrieved(ApplicationInstance instance, Health health) {
// 		super(instance);
// 		this.health = health;
// 	}
// 
// 	public ApplicationInstance getApplicationInstance() {
// 		return (ApplicationInstance) this.source;
// 	}
// 
// 	public Health getHealth() {
// 		return this.health;
// 	}
// 
// }


// Path: microservices-dashboard-server-core/src/main/java/be/ordina/msdashboard/applicationinstance/ApplicationInstanceHealthWatcher.java
import org.springframework.boot.actuate.health.Status;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.reactive.function.client.WebClient;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import be.ordina.msdashboard.applicationinstance.commands.UpdateApplicationInstanceHealth;
import be.ordina.msdashboard.applicationinstance.events.ActuatorEndpointsUpdated;
import be.ordina.msdashboard.applicationinstance.events.ApplicationInstanceHealthDataRetrievalFailed;
import be.ordina.msdashboard.applicationinstance.events.ApplicationInstanceHealthDataRetrieved;
import org.springframework.boot.actuate.health.Health;

/*
 * Copyright 2015-2019 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package be.ordina.msdashboard.applicationinstance;





/**
 * Watcher that will check an application instance its health endpoint.
 *
 * @author Dieter Hubau
 * @author Tim Ysewyn
 */
public class ApplicationInstanceHealthWatcher {

	private static final Logger logger = LoggerFactory.getLogger(ApplicationInstanceHealthWatcher.class);

	private final WebClient webClient;
	private final ApplicationInstanceService applicationInstanceService;
	private final ApplicationEventPublisher publisher;

	ApplicationInstanceHealthWatcher(ApplicationInstanceService applicationInstanceService,
			WebClient webClient, ApplicationEventPublisher publisher) {
		this.applicationInstanceService = applicationInstanceService;
		this.webClient = webClient;
		this.publisher = publisher;
	}

	@EventListener({ ActuatorEndpointsUpdated.class })