use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.
the class DcMetaComparatorTest method testDeleted.
@Test
public void testDeleted() {
ClusterMeta cluster = differentCluster(current);
current.addCluster(cluster);
DcMetaComparator dcMetaComparator = new DcMetaComparator(current, future);
dcMetaComparator.compare();
Assert.assertEquals(1, dcMetaComparator.getRemoved().size());
Assert.assertEquals(cluster, dcMetaComparator.getRemoved().toArray()[0]);
Assert.assertEquals(0, dcMetaComparator.getAdded().size());
Assert.assertEquals(0, dcMetaComparator.getMofified().size());
}
use of com.ctrip.xpipe.redis.core.entity.ClusterMeta 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.ClusterMeta 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.ClusterMeta 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.ClusterMeta in project x-pipe by ctripcorp.
the class MetaInfoChange method testAddCluster.
@Test
public void testAddCluster() throws IOException {
ClusterMeta clusterMeta = differentCluster(dc);
metaServerConsoleService.clusterAdded(clusterId, clusterMeta);
waitForAnyKeyToExit();
}
Aggregations