use of com.ctrip.xpipe.redis.core.entity.ShardMeta in project x-pipe by ctripcorp.
the class CurrentMetaTest method testToString.
@Test
public void testToString() {
List<KeeperMeta> allKeepers = getDcKeepers(getDc(), clusterId, shardId);
currentMeta.setSurviveKeepers(clusterId, shardId, allKeepers, allKeepers.get(0));
currentMeta.addResource(clusterId, shardId, new Releasable() {
@Override
public void release() throws Exception {
}
});
String json = currentMeta.toString();
CurrentMeta de = CurrentMeta.fromJson(json);
Assert.assertEquals(json, de.toString());
Assert.assertTrue(currentMeta.hasCluster(clusterId));
for (ShardMeta shardMeta : clusterMeta.getShards().values()) {
Assert.assertTrue(currentMeta.hasShard(clusterId, shardMeta.getId()));
}
}
use of com.ctrip.xpipe.redis.core.entity.ShardMeta in project x-pipe by ctripcorp.
the class DcMetaBuilderTest method getOrCreateShardMeta.
@Test
public void getOrCreateShardMeta() throws Exception {
DcClusterShardTbl dcClusterShard = dcClusterShards.get(0);
builder.getOrCreateClusterMeta(dcClusterShards.get(0).getClusterInfo());
ClusterMeta clusterMeta = dcMeta.getClusters().get(dcClusterShard.getClusterInfo().getClusterName());
logger.info("{}", dcClusterShard.getShardInfo());
builder.getOrCreateShardMeta(clusterMeta.getId(), dcClusterShard.getShardInfo(), dcClusterShard.getSetinelId());
String clusterId = dcClusterShard.getClusterInfo().getClusterName(), shardId = dcClusterShard.getShardInfo().getShardName();
ShardMeta shardMeta = dcMeta.findCluster(clusterId).findShard(shardId);
Assert.assertNotNull(shardMeta);
logger.info("{}", shardMeta);
}
use of com.ctrip.xpipe.redis.core.entity.ShardMeta in project x-pipe by ctripcorp.
the class ClusterMetaComparator method compare.
@Override
public void compare() {
Triple<Set<String>, Set<String>, Set<String>> result = getDiff(current.getShards().keySet(), future.getShards().keySet());
for (String shardId : result.getFirst()) {
added.add(future.findShard(shardId));
}
for (String shardId : result.getLast()) {
removed.add(current.findShard(shardId));
}
for (String shardId : result.getMiddle()) {
ShardMeta currentMeta = current.findShard(shardId);
ShardMeta futureMeta = future.findShard(shardId);
if (!reflectionEquals(currentMeta, futureMeta)) {
ShardMetaComparator comparator = new ShardMetaComparator(currentMeta, futureMeta);
comparator.compare();
modified.add(comparator);
}
}
}
Aggregations