Search in sources :

Example 1 with DefaultMigrationCluster

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.");
}
Also used : DefaultMigrationEvent(com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationEvent) DefaultMigrationCluster(com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster) MigrationCluster(com.ctrip.xpipe.redis.console.migration.model.MigrationCluster) DefaultMigrationCluster(com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster) BadRequestException(com.ctrip.xpipe.redis.console.exception.BadRequestException) DefaultMigrationShard(com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationShard) MigrationEvent(com.ctrip.xpipe.redis.console.migration.model.MigrationEvent) DefaultMigrationEvent(com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationEvent)

Example 2 with DefaultMigrationCluster

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);
    }
}
Also used : DefaultMigrationShard(com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationShard) 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 3 with DefaultMigrationCluster

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);
}
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 4 with DefaultMigrationCluster

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);
}
Also used : DefaultMigrationCluster(com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster) Before(org.junit.Before)

Example 5 with DefaultMigrationCluster

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

Aggregations

DefaultMigrationCluster (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster)6 DefaultMigrationShard (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationShard)4 Before (org.junit.Before)4 HashMap (java.util.HashMap)3 DcTbl (com.ctrip.xpipe.redis.console.model.DcTbl)2 MigrationClusterTbl (com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)2 AbstractOuterClientService (com.ctrip.xpipe.migration.AbstractOuterClientService)1 BadRequestException (com.ctrip.xpipe.redis.console.exception.BadRequestException)1 MigrationCluster (com.ctrip.xpipe.redis.console.migration.model.MigrationCluster)1 MigrationEvent (com.ctrip.xpipe.redis.console.migration.model.MigrationEvent)1 DefaultMigrationEvent (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationEvent)1 TimeoutException (java.util.concurrent.TimeoutException)1 Test (org.junit.Test)1 DirtiesContext (org.springframework.test.annotation.DirtiesContext)1