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;
}
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);
}
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());
}
}
}
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));
}
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));
}
Aggregations