Search in sources :

Example 1 with XpipeMeta

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

the class RemoveUnusedRedisTest method beforeRemoveUnusedRedisTest.

@Before
public void beforeRemoveUnusedRedisTest() throws Exception {
    MockitoAnnotations.initMocks(this);
    // mock datas
    XpipeMeta xpipeMeta = new XpipeMeta().addDc(new DcMeta());
    when(metaCache.getXpipeMeta()).thenReturn(xpipeMeta);
    manager.executors = Executors.newFixedThreadPool(OsUtils.getCpuCount());
    manager.pingAndDelayExecutor = Executors.newFixedThreadPool(OsUtils.getCpuCount());
    // random port to avoid port conflict
    port = randomPort();
    server = startServer(port, new Callable<String>() {

        @Override
        public String call() throws Exception {
            return "+OK\r\n";
        }
    });
}
Also used : XpipeMeta(com.ctrip.xpipe.redis.core.entity.XpipeMeta) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) Callable(java.util.concurrent.Callable) Before(org.junit.Before)

Example 2 with XpipeMeta

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

the class MetaUpdate method getStats.

@RequestMapping(value = "/stats", method = RequestMethod.GET)
public Map<String, Integer> getStats() {
    XpipeMeta xpipeMeta = metaCache.getXpipeMeta();
    ClusterShardCounter counter = new ClusterShardCounter();
    xpipeMeta.accept(counter);
    HashMap<String, Integer> counts = new HashMap<>();
    counts.put("clusterCount", counter.getClusterCount());
    counts.put("shardCount", counter.getShardCount());
    return counts;
}
Also used : XpipeMeta(com.ctrip.xpipe.redis.core.entity.XpipeMeta) ClusterShardCounter(com.ctrip.xpipe.redis.core.meta.ClusterShardCounter)

Example 3 with XpipeMeta

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

the class MetaCloneTest method testClone.

@Test
public void testClone() {
    XpipeMeta xpipeMeta = getXpipeMeta();
    DcMeta dcMeta = xpipeMeta.getDcs().values().iterator().next();
    DcMeta clone = MetaClone.clone(dcMeta);
    Assert.assertEquals(dcMeta, clone);
    clone.setId(randomString());
    Assert.assertNotEquals(dcMeta, clone);
}
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 4 with XpipeMeta

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

the class MetaJacksonTest method testJackson.

@Test
public void testJackson() throws IOException {
    // for get config from console, use raw ObjectMapper
    ObjectMapper objectMapper = new ObjectMapper();
    XpipeMeta rawMeta = getXpipeMeta();
    String metaString = objectMapper.writeValueAsString(rawMeta);
    XpipeMeta metaBack = objectMapper.readValue(metaString, XpipeMeta.class);
    Assert.assertEquals(metaBack, rawMeta);
}
Also used : XpipeMeta(com.ctrip.xpipe.redis.core.entity.XpipeMeta) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Example 5 with XpipeMeta

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

the class DefaultDcMetaCacheTest method testChangeDcMetaLog.

@Test
public void testChangeDcMetaLog() {
    // just check exception
    EventMonitor.DEFAULT.logEvent("type", getTestName());
    XpipeMeta xpipeMeta = getXpipeMeta();
    DcMeta dcMeta = (DcMeta) xpipeMeta.getDcs().values().toArray()[0];
    DcMeta future = MetaClone.clone(dcMeta);
    ClusterMeta futureCluster = (ClusterMeta) future.getClusters().values().toArray()[0];
    futureCluster.addShard(new ShardMeta().setId(randomString(5)));
    future.addCluster(new ClusterMeta().setId(randomString(10)));
    dcMetaCache.changeDcMeta(dcMeta, future);
    dcMetaCache.clusterAdded(new ClusterMeta().setId("add_" + randomString(5)));
    dcMetaCache.clusterDeleted("del_" + randomString(5));
}
Also used : XpipeMeta(com.ctrip.xpipe.redis.core.entity.XpipeMeta) ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

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