Search in sources :

Example 1 with ComponentStatus

use of org.infinispan.lifecycle.ComponentStatus in project wildfly by wildfly.

the class DefaultCacheContainerTestCase method getStatus.

@Test
public void getStatus() {
    ComponentStatus expected = ComponentStatus.INITIALIZING;
    when(this.manager.getStatus()).thenReturn(expected);
    ComponentStatus result = this.subject.getStatus();
    assertSame(expected, result);
}
Also used : ComponentStatus(org.infinispan.lifecycle.ComponentStatus) Test(org.junit.Test)

Example 2 with ComponentStatus

use of org.infinispan.lifecycle.ComponentStatus in project vertx-infinispan by vert-x3.

the class Lifecycle method closeClustered.

public static void closeClustered(List<Vertx> clustered) throws Exception {
    for (Vertx vertx : clustered) {
        VertxInternal vertxInternal = (VertxInternal) vertx;
        InfinispanClusterManager clusterManager = getInfinispanClusterManager(vertxInternal.getClusterManager());
        ComponentStatus status = null;
        if (clusterManager != null) {
            EmbeddedCacheManager cacheManager = (EmbeddedCacheManager) clusterManager.getCacheContainer();
            status = cacheManager.getStatus();
            Health health = cacheManager.getHealth();
            // Make sure rebalancing has been triggered
            SECONDS.sleep(2);
            long start = System.currentTimeMillis();
            try {
                while (health.getClusterHealth().getHealthStatus() != HealthStatus.HEALTHY && System.currentTimeMillis() - start < MILLISECONDS.convert(2, MINUTES)) {
                    MILLISECONDS.sleep(100);
                }
            } catch (Exception ignore) {
            }
        }
        if (status == null || status.compareTo(STOPPING) >= 0) {
            vertxInternal.close();
        } else {
            CountDownLatch latch = new CountDownLatch(1);
            vertxInternal.close(ar -> {
                if (ar.failed()) {
                    log.error("Failed to shutdown vert.x", ar.cause());
                }
                latch.countDown();
            });
            latch.await(2, TimeUnit.MINUTES);
        }
    }
}
Also used : VertxInternal(io.vertx.core.impl.VertxInternal) Health(org.infinispan.health.Health) InfinispanClusterManager(io.vertx.ext.cluster.infinispan.InfinispanClusterManager) ComponentStatus(org.infinispan.lifecycle.ComponentStatus) Vertx(io.vertx.core.Vertx) EmbeddedCacheManager(org.infinispan.manager.EmbeddedCacheManager) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

ComponentStatus (org.infinispan.lifecycle.ComponentStatus)2 Vertx (io.vertx.core.Vertx)1 VertxInternal (io.vertx.core.impl.VertxInternal)1 InfinispanClusterManager (io.vertx.ext.cluster.infinispan.InfinispanClusterManager)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 Health (org.infinispan.health.Health)1 EmbeddedCacheManager (org.infinispan.manager.EmbeddedCacheManager)1 Test (org.junit.Test)1