Search in sources :

Example 21 with ClusterMeta

use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.

the class MetaInfoChange method testChangeClusterKeeper.

@Test
public void testChangeClusterKeeper() throws IOException {
    sleep(2000);
    // change keeper
    try {
        ClusterMeta clusterMeta = getCluster(dc, clusterId);
        changeClusterKeeper(clusterMeta);
        metaServerConsoleService.clusterModified(clusterMeta.getId(), clusterMeta);
    } catch (Exception e) {
        logger.error("[testChangeClusterKeeper]", e);
    }
    waitForAnyKeyToExit();
}
Also used : ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) HttpServerErrorException(org.springframework.web.client.HttpServerErrorException) IOException(java.io.IOException) AbstractMetaServerClusterTest(com.ctrip.xpipe.redis.meta.server.cluster.AbstractMetaServerClusterTest) Test(org.junit.Test)

Example 22 with ClusterMeta

use of com.ctrip.xpipe.redis.core.entity.ClusterMeta 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 23 with ClusterMeta

use of com.ctrip.xpipe.redis.core.entity.ClusterMeta 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)

Example 24 with ClusterMeta

use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.

the class GeneratePlanTest method testGeneratePlan.

@Test
public void testGeneratePlan() {
    List<DcMeta> dcMetas = Lists.newArrayList(new DcMeta("SHAJQ").addCluster(new ClusterMeta("cluster1").setActiveDc("SHAJQ").setBackupDcs("SHAOY").addShard(new ShardMeta("shard1"))), new DcMeta("SHAOY").addCluster(new ClusterMeta("cluster1").setActiveDc("SHAJQ").setBackupDcs("SHAOY").addShard(new ShardMeta("shard1"))));
    Collection result = monitor.generatePlan(dcMetas);
    Assert.assertEquals(0, result.size());
}
Also used : ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) Collection(java.util.Collection) Test(org.junit.Test)

Example 25 with ClusterMeta

use of com.ctrip.xpipe.redis.core.entity.ClusterMeta in project x-pipe by ctripcorp.

the class ClientConfigMonitor method fromXPipe.

private CheckCluster fromXPipe(XpipeMeta xpipeMeta, String checkCluster) {
    XpipeMetaManager xpm = new DefaultXpipeMetaManager(xpipeMeta);
    CheckCluster result = new CheckCluster(checkCluster);
    for (String dc : xpipeMeta.getDcs().keySet()) {
        ClusterMeta clusterMeta = xpm.getClusterMeta(dc, checkCluster);
        if (clusterMeta == null) {
            continue;
        }
        for (ShardMeta shardMeta : clusterMeta.getShards().values()) {
            CheckShard orShard = result.getOrCreate(shardMeta.getId());
            shardMeta.getRedises().forEach(redis -> {
                orShard.addRedis(new CheckRedis(redis.getIp(), redis.getPort(), dc));
            });
        }
    }
    return result;
}
Also used : DefaultXpipeMetaManager(com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager) ClusterMeta(com.ctrip.xpipe.redis.core.entity.ClusterMeta) ShardMeta(com.ctrip.xpipe.redis.core.entity.ShardMeta) XpipeMetaManager(com.ctrip.xpipe.redis.core.meta.XpipeMetaManager) DefaultXpipeMetaManager(com.ctrip.xpipe.redis.core.meta.impl.DefaultXpipeMetaManager)

Aggregations

ClusterMeta (com.ctrip.xpipe.redis.core.entity.ClusterMeta)41 Test (org.junit.Test)25 ShardMeta (com.ctrip.xpipe.redis.core.entity.ShardMeta)13 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)10 DirtiesContext (org.springframework.test.annotation.DirtiesContext)10 MigrationClusterTbl (com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)8 DcMeta (com.ctrip.xpipe.redis.core.entity.DcMeta)5 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)4 RedisMeta (com.ctrip.xpipe.redis.core.entity.RedisMeta)4 ClusterMetaComparator (com.ctrip.xpipe.redis.core.meta.comparator.ClusterMetaComparator)3 AbstractMetaServerTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)3 AbstractMetaServerClusterTest (com.ctrip.xpipe.redis.meta.server.cluster.AbstractMetaServerClusterTest)3 IOException (java.io.IOException)2 HttpServerErrorException (org.springframework.web.client.HttpServerErrorException)2 HostPort (com.ctrip.xpipe.endpoint.HostPort)1 NodeAdded (com.ctrip.xpipe.observer.NodeAdded)1 NodeDeleted (com.ctrip.xpipe.observer.NodeDeleted)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