Search in sources :

Example 6 with MigrationClusterTbl

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

the class ClusterMetaServiceImplTest method testGetClusterMetaCurrentPrimaryDcNotMigrating.

@Test
public void testGetClusterMetaCurrentPrimaryDcNotMigrating() {
    long currentActiveDcId = randomInt();
    long clusterId = randomInt();
    long destinationDcId = currentActiveDcId + 1;
    DcTbl dcTbl = new DcTbl();
    ClusterTbl clusterTbl = new ClusterTbl();
    clusterTbl.setId(clusterId);
    clusterTbl.setActivedcId(currentActiveDcId);
    when(migrationService.findLatestUnfinishedMigrationCluster(clusterId)).thenReturn(new MigrationClusterTbl().setDestinationDcId(destinationDcId));
    dcTbl.setId(destinationDcId);
    for (ClusterStatus clusterStatus : ClusterStatus.values()) {
        if (clusterStatus == ClusterStatus.Migrating) {
            continue;
        }
        clusterTbl.setStatus(clusterStatus.toString());
        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) ClusterStatus(com.ctrip.xpipe.redis.console.migration.status.ClusterStatus) Test(org.junit.Test) AbstractConsoleTest(com.ctrip.xpipe.redis.console.AbstractConsoleTest)

Example 7 with MigrationClusterTbl

use of com.ctrip.xpipe.redis.console.model.MigrationClusterTbl 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 8 with MigrationClusterTbl

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

the class MigrationClusterDao method updatePublishInfoById.

public void updatePublishInfoById(long id, String publishInfo) {
    MigrationClusterTbl migrationClusterTbl = new MigrationClusterTbl();
    migrationClusterTbl.setId(id);
    migrationClusterTbl.setPublishInfo(publishInfo);
    queryHandler.handleUpdate(new DalQuery<Integer>() {

        @Override
        public Integer doQuery() throws DalException {
            return migrationClusterTblDao.updatePublishInfoById(migrationClusterTbl, MigrationClusterTblEntity.UPDATESET_FULL);
        }
    });
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) DalException(org.unidal.dal.jdbc.DalException)

Example 9 with MigrationClusterTbl

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

the class MigrationClusterDao method updateStatusAndEndTimeById.

public void updateStatusAndEndTimeById(long id, MigrationStatus status, Date endTime) {
    MigrationClusterTbl migrationClusterTbl = new MigrationClusterTbl();
    migrationClusterTbl.setId(id);
    migrationClusterTbl.setEndTime(endTime);
    migrationClusterTbl.setStatus(status.toString());
    queryHandler.handleUpdate(new DalQuery<Integer>() {

        @Override
        public Integer doQuery() throws DalException {
            return migrationClusterTblDao.updateStatusAndEndTimeById(migrationClusterTbl, MigrationClusterTblEntity.UPDATESET_FULL);
        }
    });
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) DalException(org.unidal.dal.jdbc.DalException)

Example 10 with MigrationClusterTbl

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

the class MigrationClusterDao method updateStartTime.

public void updateStartTime(long id, Date date) {
    MigrationClusterTbl migrationClusterTbl = new MigrationClusterTbl();
    migrationClusterTbl.setId(id);
    migrationClusterTbl.setStartTime(date);
    queryHandler.handleUpdate(new DalQuery<Integer>() {

        @Override
        public Integer doQuery() throws DalException {
            return migrationClusterTblDao.updateStartTimeById(migrationClusterTbl, MigrationClusterTblEntity.UPDATESET_FULL);
        }
    });
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) DalException(org.unidal.dal.jdbc.DalException)

Aggregations

MigrationClusterTbl (com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)17 Test (org.junit.Test)9 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)6 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)5 DcTbl (com.ctrip.xpipe.redis.console.model.DcTbl)5 DirtiesContext (org.springframework.test.annotation.DirtiesContext)3 DalException (org.unidal.dal.jdbc.DalException)3 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)2 AbstractMigrationTest (com.ctrip.xpipe.redis.console.migration.AbstractMigrationTest)2 DefaultMigrationCluster (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster)2 DefaultMigrationShard (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationShard)2 MigrationStatus (com.ctrip.xpipe.redis.console.migration.status.MigrationStatus)2 Date (java.util.Date)2 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 ClusterStatus (com.ctrip.xpipe.redis.console.migration.status.ClusterStatus)1 MigrationEventTbl (com.ctrip.xpipe.redis.console.model.MigrationEventTbl)1 MigrationShardTbl (com.ctrip.xpipe.redis.console.model.MigrationShardTbl)1 ShardTbl (com.ctrip.xpipe.redis.console.model.ShardTbl)1 LinkedList (java.util.LinkedList)1