Search in sources :

Example 1 with Status

use of io.vertx.ext.healthchecks.Status in project vertx-openshift-it by cescoffier.

the class EventBusSenderVerticle method createHealthChecks.

private HealthChecks createHealthChecks() {
    return HealthChecks.create(vertx).register("ispn-cluster-status", future -> {
        VertxInternal vertxInternal = (VertxInternal) vertx;
        InfinispanClusterManager clusterManager = (InfinispanClusterManager) vertxInternal.getClusterManager();
        EmbeddedCacheManager cacheManager = (EmbeddedCacheManager) clusterManager.getCacheContainer();
        Health health = cacheManager.getHealth();
        HealthStatus healthStatus = health.getClusterHealth().getHealthStatus();
        Status status = new Status().setOk(healthStatus == HealthStatus.HEALTHY).setData(JsonObject.mapFrom(health));
        future.complete(status);
    });
}
Also used : Status(io.vertx.ext.healthchecks.Status) HealthStatus(org.infinispan.health.HealthStatus) VertxInternal(io.vertx.core.impl.VertxInternal) Health(org.infinispan.health.Health) InfinispanClusterManager(io.vertx.ext.cluster.infinispan.InfinispanClusterManager) HealthStatus(org.infinispan.health.HealthStatus) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 2 with Status

use of io.vertx.ext.healthchecks.Status in project vertx-openshift-it by cescoffier.

the class AsyncMapVerticle method createHealthChecks.

private HealthChecks createHealthChecks() {
    return HealthChecks.create(vertx).register("ispn-cluster-status", future -> {
        VertxInternal vertxInternal = (VertxInternal) vertx;
        InfinispanClusterManager clusterManager = (InfinispanClusterManager) vertxInternal.getClusterManager();
        EmbeddedCacheManager cacheManager = (EmbeddedCacheManager) clusterManager.getCacheContainer();
        Health health = cacheManager.getHealth();
        HealthStatus healthStatus = health.getClusterHealth().getHealthStatus();
        Status status = new Status().setOk(healthStatus == HealthStatus.HEALTHY).setData(JsonObject.mapFrom(health));
        future.complete(status);
    });
}
Also used : Status(io.vertx.ext.healthchecks.Status) HealthStatus(org.infinispan.health.HealthStatus) VertxInternal(io.vertx.core.impl.VertxInternal) Health(org.infinispan.health.Health) InfinispanClusterManager(io.vertx.ext.cluster.infinispan.InfinispanClusterManager) HealthStatus(org.infinispan.health.HealthStatus) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 3 with Status

use of io.vertx.ext.healthchecks.Status in project vertx-openshift-it by cescoffier.

the class EventBusReceiverVerticle method createHealthChecks.

private HealthChecks createHealthChecks() {
    return HealthChecks.create(vertx).register("ispn-cluster-status", future -> {
        VertxInternal vertxInternal = (VertxInternal) vertx;
        InfinispanClusterManager clusterManager = (InfinispanClusterManager) vertxInternal.getClusterManager();
        EmbeddedCacheManager cacheManager = (EmbeddedCacheManager) clusterManager.getCacheContainer();
        Health health = cacheManager.getHealth();
        HealthStatus healthStatus = health.getClusterHealth().getHealthStatus();
        Status status = new Status().setOk(healthStatus == HealthStatus.HEALTHY).setData(JsonObject.mapFrom(health));
        future.complete(status);
    });
}
Also used : Status(io.vertx.ext.healthchecks.Status) HealthStatus(org.infinispan.health.HealthStatus) VertxInternal(io.vertx.core.impl.VertxInternal) Health(org.infinispan.health.Health) InfinispanClusterManager(io.vertx.ext.cluster.infinispan.InfinispanClusterManager) HealthStatus(org.infinispan.health.HealthStatus) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager)

Example 4 with Status

use of io.vertx.ext.healthchecks.Status in project hono by eclipse.

the class CacheBasedDeviceConnectionInfo method checkAdapterInstanceId.

private String checkAdapterInstanceId(final String adapterInstanceId, final String tenantId, final String deviceId, final Span span) {
    if (adapterInstanceId != null) {
        final AdapterInstanceStatus status = adapterInstanceStatusProvider.getStatus(adapterInstanceId);
        if (status == AdapterInstanceStatus.DEAD) {
            LOG.debug("ignoring found adapter instance id, belongs to already terminated container [tenant: {}, device-id: {}, adapter-instance-id: {}]", tenantId, deviceId, adapterInstanceId);
            span.log("ignoring found adapter instance id [" + adapterInstanceId + "], belongs to already terminated container");
            cache.remove(getAdapterInstanceEntryKey(tenantId, deviceId), adapterInstanceId).onSuccess(removed -> {
                if (removed) {
                    LOG.debug("removed entry with obsolete adapter instance id '{}' [tenant: {}, device-id: {}]", adapterInstanceId, tenantId, deviceId);
                }
            }).onFailure(thr -> LOG.debug("error removing entry with obsolete adapter instance id '{}' [tenant: {}, device-id: {}]", adapterInstanceId, tenantId, deviceId, thr));
            return null;
        } else if (status == AdapterInstanceStatus.SUSPECTED_DEAD) {
            LOG.debug("ignoring found adapter instance id, belongs to container with state 'SUSPECTED_DEAD' [tenant: {}, device-id: {}, adapter-instance-id: {}]", tenantId, deviceId, adapterInstanceId);
            span.log("ignoring found adapter instance id [" + adapterInstanceId + "], belongs to container with state 'SUSPECTED_DEAD'");
            return null;
        }
    }
    return adapterInstanceId;
}
Also used : HttpURLConnection(java.net.HttpURLConnection) Lifecycle(org.eclipse.hono.util.Lifecycle) LoggerFactory(org.slf4j.LoggerFactory) AdapterInstanceStatus(org.eclipse.hono.util.AdapterInstanceStatus) ClientErrorException(org.eclipse.hono.client.ClientErrorException) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Status(io.vertx.ext.healthchecks.Status) HealthCheckHandler(io.vertx.ext.healthchecks.HealthCheckHandler) Duration(java.time.Duration) Map(java.util.Map) JsonObject(io.vertx.core.json.JsonObject) TracingHelper(org.eclipse.hono.tracing.TracingHelper) Logger(org.slf4j.Logger) Tracer(io.opentracing.Tracer) DeviceConnectionConstants(org.eclipse.hono.util.DeviceConnectionConstants) Promise(io.vertx.core.Promise) Set(java.util.Set) ServerErrorException(org.eclipse.hono.client.ServerErrorException) MessageHelper(org.eclipse.hono.util.MessageHelper) Collectors(java.util.stream.Collectors) Future(io.vertx.core.Future) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) JsonArray(io.vertx.core.json.JsonArray) ServiceClient(org.eclipse.hono.client.util.ServiceClient) Optional(java.util.Optional) Span(io.opentracing.Span) AdapterInstanceStatus(org.eclipse.hono.util.AdapterInstanceStatus)

Aggregations

Status (io.vertx.ext.healthchecks.Status)4 VertxInternal (io.vertx.core.impl.VertxInternal)3 InfinispanClusterManager (io.vertx.ext.cluster.infinispan.InfinispanClusterManager)3 Health (org.infinispan.health.Health)3 HealthStatus (org.infinispan.health.HealthStatus)3 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)3 Span (io.opentracing.Span)1 Tracer (io.opentracing.Tracer)1 Future (io.vertx.core.Future)1 Promise (io.vertx.core.Promise)1 JsonArray (io.vertx.core.json.JsonArray)1 JsonObject (io.vertx.core.json.JsonObject)1 HealthCheckHandler (io.vertx.ext.healthchecks.HealthCheckHandler)1 HttpURLConnection (java.net.HttpURLConnection)1 Duration (java.time.Duration)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1