Search in sources :

Example 1 with SmallRyeHealth

use of io.smallrye.health.SmallRyeHealth in project wildfly by wildfly.

the class MicroProfileHealthReporter method getHealth.

private SmallRyeHealth getHealth(Map<HealthCheck, ClassLoader> serverChecks, Map<HealthCheck, ClassLoader> deploymentChecks, HealthCheckResponse.Status defaultStatus) {
    JsonArrayBuilder results = Json.createArrayBuilder();
    HealthCheckResponse.Status status = defaultStatus;
    status = processChecks(serverChecks, results, status);
    status = processChecks(deploymentChecks, results, status);
    JsonObjectBuilder builder = Json.createObjectBuilder();
    JsonArray checkResults = results.build();
    builder.add("status", status.toString());
    builder.add("checks", checkResults);
    JsonObject build = builder.build();
    if (status.equals(HealthCheckResponse.Status.DOWN)) {
        MicroProfileHealthLogger.LOGGER.healthDownStatus(build.toString());
    }
    return new SmallRyeHealth(build);
}
Also used : JsonArray(javax.json.JsonArray) SmallRyeHealth(io.smallrye.health.SmallRyeHealth) HealthCheckResponse(org.eclipse.microprofile.health.HealthCheckResponse) JsonObject(javax.json.JsonObject) JsonArrayBuilder(javax.json.JsonArrayBuilder) JsonObjectBuilder(javax.json.JsonObjectBuilder)

Example 2 with SmallRyeHealth

use of io.smallrye.health.SmallRyeHealth in project wildfly by wildfly.

the class CheckOperations method executeRuntimeStep.

@Override
protected void executeRuntimeStep(OperationContext context, ModelNode operation) {
    ServiceName serviceName = context.getCapabilityServiceName(MicroProfileHealthSubsystemDefinition.MICROPROFILE_HEALTH_REPORTER_CAPABILITY, MicroProfileHealthReporter.class);
    MicroProfileHealthReporter reporter = (MicroProfileHealthReporter) context.getServiceRegistry(false).getService(serviceName).getValue();
    SmallRyeHealth health = healthOperation.apply(reporter);
    ModelNode result = ModelNode.fromJSONString(health.getPayload().toString());
    context.getResult().set(result);
}
Also used : SmallRyeHealth(io.smallrye.health.SmallRyeHealth) ServiceName(org.jboss.msc.service.ServiceName) ModelNode(org.jboss.dmr.ModelNode)

Aggregations

SmallRyeHealth (io.smallrye.health.SmallRyeHealth)2 JsonArray (javax.json.JsonArray)1 JsonArrayBuilder (javax.json.JsonArrayBuilder)1 JsonObject (javax.json.JsonObject)1 JsonObjectBuilder (javax.json.JsonObjectBuilder)1 HealthCheckResponse (org.eclipse.microprofile.health.HealthCheckResponse)1 ModelNode (org.jboss.dmr.ModelNode)1 ServiceName (org.jboss.msc.service.ServiceName)1