use of com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster in project x-pipe by ctripcorp.
the class MigrationEventDao method loadMigrationEvent.
private MigrationEvent loadMigrationEvent(List<MigrationEventTbl> details) {
if (!CollectionUtils.isEmpty(details)) {
MigrationEvent event = new DefaultMigrationEvent(details.get(0));
for (MigrationEventTbl detail : details) {
MigrationClusterTbl cluster = detail.getRedundantClusters();
MigrationShardTbl shard = detail.getRedundantShards();
if (null == event.getMigrationCluster(cluster.getClusterId())) {
event.addMigrationCluster(new DefaultMigrationCluster(executors, scheduled, event, detail.getRedundantClusters(), dcService, clusterService, shardService, redisService, migrationService));
}
MigrationCluster migrationCluster = event.getMigrationCluster(cluster.getClusterId());
migrationCluster.addNewMigrationShard(new DefaultMigrationShard(migrationCluster, shard, migrationCluster.getClusterShards().get(shard.getShardId()), migrationCluster.getClusterDcs(), migrationService));
}
return event;
}
throw new BadRequestException("Cannot load migration event from null.");
}
use of com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster in project x-pipe by ctripcorp.
the class MultiShardMigrationTest method prepare.
@Before
public void prepare() {
MockitoAnnotations.initMocks(this);
Map<Long, DcTbl> dcs = new HashMap<>();
for (DcTbl dc : dcService.findClusterRelatedDc(clusterName)) {
dcs.put(dc.getId(), dc);
}
createShards();
MigrationClusterTbl migrationClusterTbl = migrationService.findMigrationCluster(1L, clusterId);
migrationCluster = new DefaultMigrationCluster(executors, scheduled, migrationEvent, migrationClusterTbl, dcService, clusterService, shardService, redisService, migrationService);
for (int cnt = 1; cnt != TEST_SHARD_CNT + 1; ++cnt) {
MigrationShardTbl migrationShardTbl = new MigrationShardTbl();
migrationShardTbl.setId(cnt).setMigrationClusterId(1).setShardId(cnt).setLog("");
ShardTbl shardTbl = new ShardTbl();
shardTbl.setId(cnt).setClusterId(clusterId).setShardName(getShardName(cnt)).setSetinelMonitorName("cluster1-" + getShardName(cnt));
MigrationShard migrationShard = new DefaultMigrationShard(migrationCluster, migrationShardTbl, shardTbl, dcs, migrationService, migrationCommandBuilder);
migrationCluster.addNewMigrationShard(migrationShard);
}
}
use of com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster in project x-pipe by ctripcorp.
the class DefaultMigrationClusterTest method prepare.
@Before
public void prepare() {
MockitoAnnotations.initMocks(this);
dcA = dcNames[0];
dcB = dcNames[1];
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.migration.model.impl.DefaultMigrationCluster in project x-pipe by ctripcorp.
the class MigrationStatTest method setUp.
@Before
public void setUp() {
prepareData();
migrationCluster = new DefaultMigrationCluster(executors, scheduled, migrationEvent, mockedMigrationCluster, mockedDcService, mockedClusterService, mockedShardService, mockedRedisService, mockedMigrationService);
migrationCluster.addNewMigrationShard(mockedMigrationShard);
}
use of com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster 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);
}
Aggregations