Search in sources :

Example 6 with XpipeMeta

use of com.ctrip.xpipe.redis.core.entity.XpipeMeta in project x-pipe by ctripcorp.

the class HealthChecker method warmup.

@VisibleForTesting
protected void warmup() {
    int period = 1000;
    XpipeMeta xpipeMeta = null;
    while (xpipeMeta == null) {
        log.info("[warmup] waiting for metaCache initialized");
        try {
            Thread.sleep(period);
            xpipeMeta = metaCache.getXpipeMeta();
            Thread.sleep(period);
        } catch (Exception e) {
            log.error("[warmup]", e);
        }
    }
    try {
        List<DcMeta> dcsToCheck = new LinkedList<>(xpipeMeta.getDcs().values());
        for (DcMeta dc : dcsToCheck) {
            dc.accept(healthCheckVisitor);
        }
    } catch (Exception e) {
        log.error("[warmup] error: {}", e);
    }
}
Also used : XpipeMeta(com.ctrip.xpipe.redis.core.entity.XpipeMeta) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) LinkedList(java.util.LinkedList) VisibleForTesting(com.ctrip.xpipe.utils.VisibleForTesting)

Example 7 with XpipeMeta

use of com.ctrip.xpipe.redis.core.entity.XpipeMeta in project x-pipe by ctripcorp.

the class ClientConfigMonitor method doCheck.

@Override
protected void doCheck() {
    logger.info("[doCheck]");
    XpipeMeta xpipeMeta = metaCache.getXpipeMeta();
    Set<String> clusters = getClusters(xpipeMeta);
    for (String cluster : clusters) {
        try {
            checkCluster(cluster, xpipeMeta);
        } catch (Exception e) {
            logger.info("[doCheck]" + cluster, e);
        }
    }
}
Also used : XpipeMeta(com.ctrip.xpipe.redis.core.entity.XpipeMeta)

Example 8 with XpipeMeta

use of com.ctrip.xpipe.redis.core.entity.XpipeMeta in project x-pipe by ctripcorp.

the class MetaCloneTest method testCloneMultiTimes.

@Test
public void testCloneMultiTimes() {
    int count = 1 << 1;
    XpipeMeta xpipeMeta = getXpipeMeta();
    DcMeta dcMeta = xpipeMeta.getDcs().values().iterator().next();
    DcMeta clone = null;
    for (int i = 0; i < count; i++) {
        clone = MetaClone.clone(dcMeta);
    }
}
Also used : XpipeMeta(com.ctrip.xpipe.redis.core.entity.XpipeMeta) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) AbstractRedisTest(com.ctrip.xpipe.redis.core.AbstractRedisTest) Test(org.junit.Test)

Example 9 with XpipeMeta

use of com.ctrip.xpipe.redis.core.entity.XpipeMeta in project x-pipe by ctripcorp.

the class ClusterShardCounterTest method testCount.

@Test
public void testCount() {
    XpipeMeta xpipeMeta = getXpipeMeta();
    ClusterShardCounter counter = new ClusterShardCounter();
    xpipeMeta.accept(counter);
    logger.info("{}", counter.getClusters());
    Assert.assertEquals(2, counter.getClusterCount());
    Assert.assertEquals(2, counter.getShardCount());
}
Also used : XpipeMeta(com.ctrip.xpipe.redis.core.entity.XpipeMeta) AbstractRedisTest(com.ctrip.xpipe.redis.core.AbstractRedisTest) Test(org.junit.Test)

Aggregations

XpipeMeta (com.ctrip.xpipe.redis.core.entity.XpipeMeta)9 DcMeta (com.ctrip.xpipe.redis.core.entity.DcMeta)5 Test (org.junit.Test)5 AbstractRedisTest (com.ctrip.xpipe.redis.core.AbstractRedisTest)3 AbstractMetaServerTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)2 ClusterMeta (com.ctrip.xpipe.redis.core.entity.ClusterMeta)1 ShardMeta (com.ctrip.xpipe.redis.core.entity.ShardMeta)1 ClusterShardCounter (com.ctrip.xpipe.redis.core.meta.ClusterShardCounter)1 VisibleForTesting (com.ctrip.xpipe.utils.VisibleForTesting)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 LinkedList (java.util.LinkedList)1 Callable (java.util.concurrent.Callable)1 Before (org.junit.Before)1