Search in sources :

Example 6 with ShardMeta

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

the class ShardMetaServiceImpl method loadShardMeta.

@Override
public ShardMeta loadShardMeta(ClusterMeta clusterMeta, ClusterTbl clusterTbl, ShardTbl shardTbl, DcMetaQueryVO dcMetaQueryVO) {
    ShardMeta shardMeta = new ShardMeta();
    if (null == clusterTbl || null == shardTbl)
        return shardMeta;
    shardMeta.setId(shardTbl.getShardName());
    shardMeta.setSentinelId(dcMetaQueryVO.getDcClusterShardMap().get(Pair.of(clusterTbl.getClusterName(), shardTbl.getShardName())).getSetinelId());
    shardMeta.setSentinelMonitorName(shardTbl.getSetinelMonitorName());
    for (RedisTbl redis : dcMetaQueryVO.getRedisMap().get(clusterTbl.getClusterName()).get(shardTbl.getShardName())) {
        if (redis.getRedisRole().equals("keeper")) {
            shardMeta.addKeeper(redisMetaService.getKeeperMeta(shardMeta, redis));
        } else {
            shardMeta.addRedis(redisMetaService.getRedisMeta(shardMeta, redis));
        }
    }
    shardMeta.setParent(clusterMeta);
    return shardMeta;
}
Also used : ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta)

Example 7 with ShardMeta

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

the class ShardMetaServiceImpl method getShardMeta.

private ShardMeta getShardMeta(DcTbl dcInfo, ClusterTbl clusterInfo, ShardTbl shardInfo, DcClusterTbl dcClusterInfo, DcClusterShardTbl dcClusterShardInfo) {
    ShardMeta shardMeta = new ShardMeta();
    if (null == dcInfo || null == clusterInfo || null == shardInfo || null == dcClusterInfo || null == dcClusterShardInfo) {
        return shardMeta;
    }
    shardMeta.setId(shardInfo.getShardName());
    shardMeta.setSentinelId(dcClusterShardInfo.getSetinelId());
    shardMeta.setSentinelMonitorName(shardInfo.getSetinelMonitorName());
    List<RedisTbl> shard_redises = redisService.findAllByDcClusterShard(dcClusterShardInfo.getDcClusterShardId());
    if (null != shard_redises) {
        for (RedisTbl redis : shard_redises) {
            if (redis.getRedisRole().equals("keeper")) {
                addKeeperMeta(shardMeta, redis);
            } else {
                addRedisMeta(shardMeta, redis);
            }
        }
    }
    return shardMeta;
}
Also used : ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta)

Example 8 with ShardMeta

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

the class EncodeTest method testEncode.

@Test
public void testEncode() {
    ClusterMeta clusterMeta = new ClusterMeta();
    // clusterMeta.addShard();
    clusterMeta.addShard(new ShardMeta());
    JsonCodec.INSTANCE.encode(clusterMeta);
    logger.info("{}", clusterMeta);
}
Also used : ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) Test(org.junit.Test) AbstractConsoleTest(com.ctrip.xpipe.redis.console.AbstractConsoleTest)

Example 9 with ShardMeta

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

the class ClusterMetaComparatorTest method testRemoved.

@Test
public void testRemoved() {
    ShardMeta shard = differentShard(current);
    current.addShard(shard);
    ClusterMetaComparator clusterMetaComparator = new ClusterMetaComparator(current, future);
    clusterMetaComparator.compare();
    Assert.assertEquals(0, clusterMetaComparator.getAdded().size());
    Assert.assertEquals(1, clusterMetaComparator.getRemoved().size());
    Assert.assertEquals(shard, clusterMetaComparator.getRemoved().toArray()[0]);
    Assert.assertEquals(0, clusterMetaComparator.getMofified().size());
}
Also used : ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) Test(org.junit.Test)

Example 10 with ShardMeta

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

the class ClusterMetaComparatorTest method testModified.

@Test
public void testModified() {
    ShardMeta shardMeta = (ShardMeta) future.getShards().values().toArray()[0];
    shardMeta.addKeeper(differentKeeper(shardMeta));
    ClusterMetaComparator clusterMetaComparator = new ClusterMetaComparator(current, future);
    clusterMetaComparator.compare();
    Assert.assertEquals(0, clusterMetaComparator.getAdded().size());
    Assert.assertEquals(0, clusterMetaComparator.getRemoved().size());
    Assert.assertEquals(1, clusterMetaComparator.getMofified().size());
    ShardMetaComparator comparator = (ShardMetaComparator) clusterMetaComparator.getMofified().toArray()[0];
    Assert.assertEquals(shardMeta.getId(), comparator.getCurrent().getId());
}
Also used : ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) Test(org.junit.Test)

Aggregations

ShardMeta (com.ctrip.xpipe.redis.core.entity.ShardMeta)23 ClusterMeta (com.ctrip.xpipe.redis.core.entity.ClusterMeta)13 Test (org.junit.Test)11 DcMeta (com.ctrip.xpipe.redis.core.entity.DcMeta)4 RedisMeta (com.ctrip.xpipe.redis.core.entity.RedisMeta)4 KeeperMeta (com.ctrip.xpipe.redis.core.entity.KeeperMeta)3 AbstractMetaServerTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)3 Releasable (com.ctrip.xpipe.api.lifecycle.Releasable)1 HostPort (com.ctrip.xpipe.endpoint.HostPort)1 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)1 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)1 DataNotFoundException (com.ctrip.xpipe.redis.console.exception.DataNotFoundException)1 ServerException (com.ctrip.xpipe.redis.console.exception.ServerException)1 DcClusterShardTbl (com.ctrip.xpipe.redis.console.model.DcClusterShardTbl)1 XpipeMeta (com.ctrip.xpipe.redis.core.entity.XpipeMeta)1 XpipeMetaManager (com.ctrip.xpipe.redis.core.meta.XpipeMetaManager)1 ClusterMetaComparator (com.ctrip.xpipe.redis.core.meta.comparator.ClusterMetaComparator)1 DefaultXpipeMetaManager (com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager)1 AbstractMetaServerClusterTest (com.ctrip.xpipe.redis.meta.server.cluster.AbstractMetaServerClusterTest)1 DefaultSlaveOfJob (com.ctrip.xpipe.redis.meta.server.job.DefaultSlaveOfJob)1