Search in sources :

Example 11 with ShardMeta

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);
}
Also used : ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) RedisMeta(com.ctrip.xpipe.redis.core.entity.RedisMeta) Test(org.junit.Test)

Example 12 with ShardMeta

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));
}
Also used : XpipeMeta(com.ctrip.xpipe.redis.core.entity.XpipeMeta) ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Example 13 with ShardMeta

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();
}
Also used : ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) HttpServerErrorException(org.springframework.web.client.HttpServerErrorException) IOException(java.io.IOException) AbstractMetaServerClusterTest(com.ctrip.xpipe.redis.meta.server.cluster.AbstractMetaServerClusterTest) Test(org.junit.Test)

Example 14 with ShardMeta

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));
}
Also used : ClusterMetaComparator(com.ctrip.xpipe.redis.core.meta.comparator.ClusterMetaComparator) ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) Test(org.junit.Test) AbstractMetaServerTest(com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)

Example 15 with ShardMeta

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);
}
Also used : ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta)

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