All Downloads are FREE. Search and download functionalities are using the official Maven repository.

zed.deployer.health.SpringBootJolokiaHealthResolver Maven / Gradle / Ivy

Go to download

A application used as an example on how to set up pushing its components to the Central Repository.

The newest version!
package zed.deployer.health;

import com.fasterxml.jackson.databind.ObjectMapper;
import zed.deployer.manager.DeployableDescriptor;
import zed.deployer.manager.DeployablesManager;

import java.io.IOException;
import java.net.URL;
import java.util.Map;

public class SpringBootJolokiaHealthResolver implements HealthResolver {

    private final DeployablesManager deployablesManager;

    public SpringBootJolokiaHealthResolver(DeployablesManager deployablesManager) {
        this.deployablesManager = deployablesManager;
    }

    @Override
    public Health resolveHealth(String deployableId) {
        try {
            DeployableDescriptor descriptor = deployablesManager.deployment(deployableId);
            String baseJolokiaUrl = discoverDeployableJolokiaEndpoint(descriptor);
            String healthEndpoint = baseJolokiaUrl + "exec/org.springframework.boot:type=Endpoint,name=healthEndpoint/getData";
            Map jolokiaHealthResponse = new ObjectMapper().readValue(new URL(healthEndpoint), Map.class);
            Map rawHealthResponse = (Map) jolokiaHealthResponse.get("value");
            return new Health((String) rawHealthResponse.get("status"), rawHealthResponse);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    private String discoverDeployableJolokiaEndpoint(DeployableDescriptor descriptor) {
        return null;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy