Search in sources :

Example 6 with DcTbl

use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.

the class AdvancedDcMetaService method getDcMeta.

@Override
public DcMeta getDcMeta(String dcName) {
    DcTbl dcTbl = dcService.find(dcName);
    DcMeta dcMeta = new DcMeta().setId(dcName).setLastModifiedTime(dcTbl.getDcLastModifiedTime());
    ParallelCommandChain chain = new ParallelCommandChain(executors);
    chain.add(retry3TimesUntilSuccess(new GetAllSentinelCommand(dcMeta)));
    chain.add(retry3TimesUntilSuccess(new GetAllKeeperContainerCommand(dcMeta)));
    DcMetaBuilder builder = new DcMetaBuilder(dcMeta, dcTbl.getId(), executors, redisMetaService, dcClusterService, clusterMetaService, dcClusterShardService, dcService, factory);
    chain.add(retry3TimesUntilSuccess(builder));
    try {
        chain.execute().get();
    } catch (Exception e) {
        logger.error("[queryDcMeta] ", e);
    }
    return dcMeta;
}
Also used : ParallelCommandChain(com.ctrip.xpipe.command.ParallelCommandChain) DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) DcMetaBuilder(com.ctrip.xpipe.redis.console.service.vo.DcMetaBuilder) DcMeta(com.ctrip.xpipe.redis.core.entity.DcMeta)

Example 7 with DcTbl

use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.

the class SingleShardMigrationTest method prepare.

@Before
public void prepare() {
    MockitoAnnotations.initMocks(this);
    MigrationClusterTbl migrationClusterTbl = migrationService.findMigrationCluster(1L, 1L);
    migrationCluster = new DefaultMigrationCluster(executors, scheduled, migrationEvent, migrationClusterTbl, dcService, clusterService, shardService, redisService, migrationService);
    Map<Long, DcTbl> dcs = new HashMap<>();
    for (DcTbl dc : dcService.findClusterRelatedDc("cluster1")) {
        dcs.put(dc.getId(), dc);
    }
    migrationShard = new DefaultMigrationShard(migrationCluster, migrationService.findMigrationShards(1).get(0), shardService.find(1), dcs, migrationService, migrationCommandBuilder);
    migrationCluster.addNewMigrationShard(migrationShard);
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) HashMap(java.util.HashMap) DefaultMigrationCluster(com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster) DefaultMigrationShard(com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationShard) Before(org.junit.Before)

Example 8 with DcTbl

use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.

the class DataObjectAssemblyTest method testGetDataNotNull.

@Test
public void testGetDataNotNull() throws InterruptedException, ExecutionException {
    CyclicBarrier barrier = new CyclicBarrier(N);
    List<Future<List<DcTbl>>> futures = new LinkedList<>();
    for (int i = 0; i < N; i++) {
        futures.add(getDCDetails(barrier));
    }
    for (Future<List<DcTbl>> future : futures) {
        List<DcTbl> details = future.get();
        for (DcTbl dc : details) {
            Assert.assertNotNull(dc);
            Assert.assertNotNull(dc.getClusterInfo());
            Assert.assertNotNull(dc.getClusterInfo().getClusterName());
            Assert.assertNotNull(dc.getClusterInfo().getStatus());
            Assert.assertNotNull(dc.getClusterInfo().getDataChangeLastTime());
            Assert.assertNotNull(dc.getDcClusterShardInfo());
            Assert.assertNotNull(dc.getDcClusterInfo());
            Assert.assertNotNull(dc.getDcClusterInfo().getDataChangeLastTime());
            Assert.assertNotNull(dc.getRedisInfo());
            Assert.assertNotNull(dc.getRedisInfo().getRunId());
            Assert.assertNotNull(dc.getRedisInfo().getRedisRole());
            Assert.assertNotNull(dc.getRedisInfo().getRedisIp());
            Assert.assertNotNull(dc.getShardInfo());
            Assert.assertNotNull(dc.getShardInfo().getShardName());
        }
    }
}
Also used : DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 9 with DcTbl

use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.

the class ClusterMetaServiceImplTest method testGetClusterMetaCurrentPrimaryDcMigrating.

@Test
public void testGetClusterMetaCurrentPrimaryDcMigrating() {
    long currentActiveDcId = randomInt();
    long clusterId = randomInt();
    long destinationDcId = currentActiveDcId + 1;
    DcTbl dcTbl = new DcTbl();
    ClusterTbl clusterTbl = new ClusterTbl();
    clusterTbl.setId(clusterId);
    clusterTbl.setActivedcId(currentActiveDcId);
    clusterTbl.setStatus(ClusterStatus.Migrating.toString());
    when(migrationService.findLatestUnfinishedMigrationCluster(clusterId)).thenReturn(new MigrationClusterTbl().setDestinationDcId(destinationDcId));
    dcTbl.setId(destinationDcId);
    Assert.assertEquals(destinationDcId, clusterMetaServiceImpl.getClusterMetaCurrentPrimaryDc(dcTbl, clusterTbl));
    dcTbl.setId(destinationDcId + 1);
    Assert.assertEquals(currentActiveDcId, clusterMetaServiceImpl.getClusterMetaCurrentPrimaryDc(dcTbl, clusterTbl));
    dcTbl.setId(currentActiveDcId);
    Assert.assertEquals(currentActiveDcId, clusterMetaServiceImpl.getClusterMetaCurrentPrimaryDc(dcTbl, clusterTbl));
}
Also used : ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl) Test(org.junit.Test) AbstractConsoleTest(com.ctrip.xpipe.redis.console.AbstractConsoleTest)

Example 10 with DcTbl

use of com.ctrip.xpipe.redis.console.model.DcTbl in project x-pipe by ctripcorp.

the class DefaultMigrationShard method doMigrateOtherDc.

@Override
public void doMigrateOtherDc() {
    logger.info("[doMigrateOtherDc]{}-{}, {}->{}", cluster, shard, prevPrimaryDc, newPrimaryDc);
    if (shardMigrationResult.stepSuccess(ShardMigrationStep.MIGRATE_NEW_PRIMARY_DC)) {
        for (DcTbl dc : dcs.values()) {
            if (!(dc.getDcName().equals(newPrimaryDc))) {
                doOtherDcMigrate(cluster, shard, dc.getDcName(), newPrimaryDc);
            }
        }
    }
    if (shardMigrationResult.stepSuccess(ShardMigrationStep.MIGRATE_NEW_PRIMARY_DC)) {
        shardMigrationResult.updateStepResult(ShardMigrationStep.MIGRATE, true, LogUtils.info("Success"));
        shardMigrationResult.setStatus(ShardMigrationResultStatus.SUCCESS);
    } else {
        shardMigrationResult.updateStepResult(ShardMigrationStep.MIGRATE, false, LogUtils.error("Failed"));
    }
    notifyObservers(new ShardObserverEvent(shardName(), ShardMigrationStep.MIGRATE));
}
Also used : DcTbl(com.ctrip.xpipe.redis.console.model.DcTbl)

Aggregations

DcTbl (com.ctrip.xpipe.redis.console.model.DcTbl)13 MigrationClusterTbl (com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)5 Test (org.junit.Test)5 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)4 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)3 Before (org.junit.Before)3 DefaultMigrationCluster (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster)2 DefaultMigrationShard (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationShard)2 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)2 ParallelCommandChain (com.ctrip.xpipe.command.ParallelCommandChain)1 HostPort (com.ctrip.xpipe.endpoint.HostPort)1 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)1 ClusterStatus (com.ctrip.xpipe.redis.console.migration.status.ClusterStatus)1 DcClusterTbl (com.ctrip.xpipe.redis.console.model.DcClusterTbl)1 OrganizationTbl (com.ctrip.xpipe.redis.console.model.OrganizationTbl)1 SentinelModel (com.ctrip.xpipe.redis.console.model.SentinelModel)1 SetinelTbl (com.ctrip.xpipe.redis.console.model.SetinelTbl)1 ShardTbl (com.ctrip.xpipe.redis.console.model.ShardTbl)1 DcMetaBuilder (com.ctrip.xpipe.redis.console.service.vo.DcMetaBuilder)1