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