use of com.ctrip.xpipe.redis.core.entity.ShardMeta in project x-pipe by ctripcorp.
the class DcMetaComparatorTest method testModifyRedisConfig.
@Test
public void testModifyRedisConfig() {
ClusterMeta clusterMeta = (ClusterMeta) future.getClusters().values().toArray()[0];
ShardMeta shardMeta = (ShardMeta) clusterMeta.getShards().values().toArray()[0];
RedisMeta redisMeta = shardMeta.getRedises().get(0);
redisMeta.setPort(redisMeta.getPort() + 10000);
DcMetaComparator dcMetaComparator = new DcMetaComparator(current, future);
dcMetaComparator.compare();
Assert.assertEquals(0, dcMetaComparator.getRemoved().size());
Assert.assertEquals(0, dcMetaComparator.getAdded().size());
Assert.assertEquals(1, dcMetaComparator.getMofified().size());
ClusterMetaComparator comparator = (ClusterMetaComparator) dcMetaComparator.getMofified().toArray()[0];
Assert.assertEquals(clusterMeta.getId(), comparator.getCurrent().getId());
Assert.assertEquals(0, comparator.getAdded().size());
Assert.assertEquals(0, comparator.getRemoved().size());
Assert.assertEquals(1, comparator.getMofified().size());
ShardMetaComparator shardMetaComparator = (ShardMetaComparator) comparator.getMofified().toArray()[0];
Assert.assertEquals(1, shardMetaComparator.getAdded().size());
Assert.assertEquals(1, shardMetaComparator.getRemoved().size());
Assert.assertEquals(0, shardMetaComparator.getMofified().size());
logger.debug("{}", dcMetaComparator);
}
use of com.ctrip.xpipe.redis.core.entity.ShardMeta 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));
}
use of com.ctrip.xpipe.redis.core.entity.ShardMeta in project x-pipe by ctripcorp.
the class MetaInfoChange method testChangeClusterShard.
@Test
public void testChangeClusterShard() throws IOException {
// change keeper
try {
ClusterMeta clusterMeta = getCluster(dc, clusterId);
ShardMeta shardMeta = clusterMeta.getShards().get(shardId);
shardMeta.setId(randomString(10));
changeClusterKeeper(clusterMeta);
clusterMeta.removeShard(shardId);
clusterMeta.addShard(shardMeta);
metaServerConsoleService.clusterModified(clusterMeta.getId(), clusterMeta);
} catch (Exception e) {
logger.error("[testChangeClusterKeeper]", e);
}
waitForAnyKeyToExit();
}
use of com.ctrip.xpipe.redis.core.entity.ShardMeta in project x-pipe by ctripcorp.
the class CurrentMetaTest method testChange.
@Test
public void testChange() {
ClusterMeta future = MetaClone.clone(clusterMeta);
String newShardId = randomString(100);
ShardMeta shardMeta = future.getShards().remove(shardId);
shardMeta.setId(newShardId);
future.addShard(shardMeta);
ClusterMetaComparator comparator = new ClusterMetaComparator(clusterMeta, future);
comparator.compare();
currentMeta.changeCluster(comparator);
Assert.assertFalse(currentMeta.hasShard(clusterId, shardId));
Assert.assertTrue(currentMeta.hasShard(clusterId, newShardId));
}
use of com.ctrip.xpipe.redis.core.entity.ShardMeta in project x-pipe by ctripcorp.
the class KeeperContainerService method enrichKeeperMetaFromKeeperTransMeta.
private void enrichKeeperMetaFromKeeperTransMeta(KeeperMeta keeperMeta, KeeperTransMeta keeperTransMeta) {
ClusterMeta clusterMeta = new ClusterMeta(keeperTransMeta.getClusterId());
ShardMeta shardMeta = new ShardMeta(keeperTransMeta.getShardId());
shardMeta.setParent(clusterMeta);
keeperMeta.setParent(shardMeta);
}
Aggregations