Search in sources :

Example 1 with JsonCodec

use of com.ctrip.xpipe.codec.JsonCodec in project x-pipe by ctripcorp.

the class SentinelUpdateControllerTest method testJsonShow.

@Test
public void testJsonShow() {
    SentinelUsageModel usageModel1 = new SentinelUsageModel("SHAJQ", 2).addSentinelUsage("127.0.0.1:6379,127.0.0.1:6380", 100).addSentinelUsage("192.168.0.1:6379,192.168.0.1:6380", 200);
    SentinelUsageModel usageModel2 = new SentinelUsageModel("SHAOY", 2).addSentinelUsage("127.0.0.2:6381,127.0.0.1:6382", 150).addSentinelUsage("192.168.0.2:6381,192.168.0.1:6382", 150);
    Map<String, SentinelUsageModel> map = Maps.newHashMapWithExpectedSize(2);
    map.put("SHAJQ", usageModel1);
    map.put("SHAOY", usageModel2);
    JsonCodec jsonTool = new JsonCodec(true, true);
    System.out.println(jsonTool.encode(map));
}
Also used : JsonCodec(com.ctrip.xpipe.codec.JsonCodec) SentinelUsageModel(com.ctrip.xpipe.redis.console.model.SentinelUsageModel) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 2 with JsonCodec

use of com.ctrip.xpipe.codec.JsonCodec in project x-pipe by ctripcorp.

the class DcMetaTest method test.

@Test
public void test() {
    DcMeta dcMeta = getDcMeta("jq");
    Codec codec = new JsonCodec(true);
    String dcMetaStr = codec.encode(dcMeta);
    logger.info("{}", dcMetaStr);
    DcMeta dcMetaDe = codec.decode(dcMetaStr, DcMeta.class);
    logger.info("[test]{}", dcMeta.getClusters().get("cluster1").parent());
    logger.info("[test]{}", dcMetaDe.getClusters().get("cluster1").parent());
}
Also used : Codec(com.ctrip.xpipe.api.codec.Codec) JsonCodec(com.ctrip.xpipe.codec.JsonCodec) JsonCodec(com.ctrip.xpipe.codec.JsonCodec) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) AbstractRedisTest(com.ctrip.xpipe.redis.core.AbstractRedisTest) Test(org.junit.Test)

Example 3 with JsonCodec

use of com.ctrip.xpipe.codec.JsonCodec in project x-pipe by ctripcorp.

the class DcMetaTest method testKeeper.

@Test
public void testKeeper() {
    KeeperMeta keeperMeta = new KeeperMeta().setIp("127.0.0.1").setPort(6379);
    Codec codec = new JsonCodec(true);
    String keeperMetaDesc = codec.encode(keeperMeta);
    logger.info("{}", keeperMetaDesc);
    KeeperMeta keeperMetaDec = codec.decode(keeperMetaDesc, KeeperMeta.class);
    logger.info("{}", keeperMetaDec);
}
Also used : Codec(com.ctrip.xpipe.api.codec.Codec) JsonCodec(com.ctrip.xpipe.codec.JsonCodec) JsonCodec(com.ctrip.xpipe.codec.JsonCodec) KeeperMeta(com.ctrip.xpipe.redis.core.entity.KeeperMeta) AbstractRedisTest(com.ctrip.xpipe.redis.core.AbstractRedisTest) Test(org.junit.Test)

Example 4 with JsonCodec

use of com.ctrip.xpipe.codec.JsonCodec in project x-pipe by ctripcorp.

the class CRedisServiceTest method testGetClusterInfo.

@Test
public void testGetClusterInfo() throws Exception {
    JsonCodec jsonCodec = new JsonCodec(true);
    logger.info("{}", outerClientService.getClusterInfo("Members.OfflineLogin"));
    logger.info("{}", jsonCodec.encode(outerClientService.getClusterInfo("cluster_shyin")));
    logger.info("{}", outerClientService.getClusterInfo("Members.OfflineLogin"));
    logger.info("{}", jsonCodec.encode(outerClientService.getClusterInfo("cluster_shyin_1")));
}
Also used : JsonCodec(com.ctrip.xpipe.codec.JsonCodec) Test(org.junit.Test) AbstractServiceTest(com.ctrip.xpipe.AbstractServiceTest)

Example 5 with JsonCodec

use of com.ctrip.xpipe.codec.JsonCodec in project x-pipe by ctripcorp.

the class DefaultCurrentMetaManager method getCurrentMetaDesc.

@Override
public String getCurrentMetaDesc() {
    Map<String, Object> desc = new HashMap<>();
    desc.put("meta", currentMeta);
    desc.put("currentSlots", currentSlots);
    JsonCodec codec = new JsonCodec(true, true);
    return codec.encode(desc);
}
Also used : JsonCodec(com.ctrip.xpipe.codec.JsonCodec)

Aggregations

JsonCodec (com.ctrip.xpipe.codec.JsonCodec)5 Test (org.junit.Test)4 Codec (com.ctrip.xpipe.api.codec.Codec)2 AbstractRedisTest (com.ctrip.xpipe.redis.core.AbstractRedisTest)2 AbstractServiceTest (com.ctrip.xpipe.AbstractServiceTest)1 SentinelUsageModel (com.ctrip.xpipe.redis.console.model.SentinelUsageModel)1 DcMeta (com.ctrip.xpipe.redis.core.entity.DcMeta)1 KeeperMeta (com.ctrip.xpipe.redis.core.entity.KeeperMeta)1 Matchers.anyString (org.mockito.Matchers.anyString)1