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);
}
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);
}
}
}
Aggregations