Search in sources :

Example 1 with Health

use of org.infinispan.health.Health in project vertx-openshift-it by cescoffier.

the class EventBusSenderVerticle method setupRouter.

private Router setupRouter() {
    Router router = Router.router(vertx);
    router.get("/health").handler(rc -> rc.response().putHeader(HttpHeaders.CONTENT_TYPE, "text/plain").end("OK"));
    router.get("/ready").handler(HealthCheckHandler.createWithHealthChecks(createHealthChecks()));
    router.route("/api/*").handler(ResponseContentTypeHandler.create());
    router.route("/api/*").handler(TimeoutHandler.create(API_TIMEOUT));
    router.get("/api/start_sending").produces("application/json").handler(rc -> {
        timerId = vertx.setPeriodic(10, l -> {
            sent.incrementAndGet();
            inFlight.incrementAndGet();
            sendRequest(2);
        });
        rc.response().end();
    });
    router.get("/api/stop_sending").produces("application/json").handler(rc -> {
        vertx.cancelTimer(timerId);
        waitForAllResponses(ar -> {
            JsonObject result = new JsonObject().put("sent", sent.get()).put("failures", failures.get());
            rc.response().end(result.toBuffer());
        });
    });
    return router;
}
Also used : DeliveryOptions(io.vertx.core.eventbus.DeliveryOptions) VertxInternal(io.vertx.core.impl.VertxInternal) HttpServer(io.vertx.core.http.HttpServer) Vertx(io.vertx.core.Vertx) HealthChecks(io.vertx.ext.healthchecks.HealthChecks) VertxOptions(io.vertx.core.VertxOptions) HttpHeaders(io.vertx.core.http.HttpHeaders) Router(io.vertx.ext.web.Router) Future(io.vertx.core.Future) TimeUnit(java.util.concurrent.TimeUnit) Status(io.vertx.ext.healthchecks.Status) AtomicLong(java.util.concurrent.atomic.AtomicLong) HealthCheckHandler(io.vertx.ext.healthchecks.HealthCheckHandler) TimeoutHandler(io.vertx.ext.web.handler.TimeoutHandler) HealthStatus(org.infinispan.health.HealthStatus) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) InfinispanClusterManager(io.vertx.ext.cluster.infinispan.InfinispanClusterManager) AbstractVerticle(io.vertx.core.AbstractVerticle) JsonObject(io.vertx.core.json.JsonObject) ResponseContentTypeHandler(io.vertx.ext.web.handler.ResponseContentTypeHandler) AsyncResult(io.vertx.core.AsyncResult) Handler(io.vertx.core.Handler) Health(org.infinispan.health.Health) Router(io.vertx.ext.web.Router) JsonObject(io.vertx.core.json.JsonObject)

Example 2 with Health

use of org.infinispan.health.Health 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 3 with Health

use of org.infinispan.health.Health 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 4 with Health

use of org.infinispan.health.Health 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)

Aggregations

VertxInternal (io.vertx.core.impl.VertxInternal)4 InfinispanClusterManager (io.vertx.ext.cluster.infinispan.InfinispanClusterManager)4 Status (io.vertx.ext.healthchecks.Status)4 Health (org.infinispan.health.Health)4 HealthStatus (org.infinispan.health.HealthStatus)4 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)4 AbstractVerticle (io.vertx.core.AbstractVerticle)1 AsyncResult (io.vertx.core.AsyncResult)1 Future (io.vertx.core.Future)1 Handler (io.vertx.core.Handler)1 Vertx (io.vertx.core.Vertx)1 VertxOptions (io.vertx.core.VertxOptions)1 DeliveryOptions (io.vertx.core.eventbus.DeliveryOptions)1 HttpHeaders (io.vertx.core.http.HttpHeaders)1 HttpServer (io.vertx.core.http.HttpServer)1 JsonObject (io.vertx.core.json.JsonObject)1 HealthCheckHandler (io.vertx.ext.healthchecks.HealthCheckHandler)1 HealthChecks (io.vertx.ext.healthchecks.HealthChecks)1 Router (io.vertx.ext.web.Router)1 ResponseContentTypeHandler (io.vertx.ext.web.handler.ResponseContentTypeHandler)1