Search in sources :

Example 1 with MigrationShardTbl

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

the class MigrationShardDao method updateMigrationShard.

public void updateMigrationShard(MigrationShardTbl migrationShard) {
    MigrationShardTbl proto = migrationShardDao.createLocal();
    proto.setId(migrationShard.getId()).setMigrationClusterId(migrationShard.getMigrationClusterId()).setShardId(migrationShard.getShardId()).setLog(migrationShard.getLog());
    final MigrationShardTbl forUpdate = proto;
    queryHandler.handleUpdate(new DalQuery<Integer>() {

        @Override
        public Integer doQuery() throws DalException {
            migrationShardDao.updateByPK(forUpdate, MigrationShardTblEntity.UPDATESET_FULL);
            return null;
        }
    });
}
Also used : MigrationShardTbl(com.ctrip.xpipe.redis.console.model.MigrationShardTbl) DalException(org.unidal.dal.jdbc.DalException)

Example 2 with MigrationShardTbl

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

the class DefaultMigrationShard method update.

@Override
public void update(Object args, Observable observable) {
    logger.debug("[update][begin]{}", this);
    long begin = System.currentTimeMillis();
    MigrationShardTbl toUpdate = getMigrationShard();
    String log = getShardMigrationResult().encode();
    migrationService.updateMigrationShardLogById(toUpdate.getId(), log);
    logger.debug("[debug][end]{}", this);
    long end = System.currentTimeMillis();
    if ((end - begin) > 3) {
        logger.debug("[update][time long]{}, {}", end - begin, this);
    }
}
Also used : MigrationShardTbl(com.ctrip.xpipe.redis.console.model.MigrationShardTbl)

Example 3 with MigrationShardTbl

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

the class MigrationServiceTest method createTest.

@Test
@DirtiesContext
public void createTest() throws ComponentLookupException {
    long eventId = migrationService.createMigrationEvent(createEventDemo(1, 2));
    MigrationEventTbl result = migrationService.find(eventId);
    MigrationClusterTbl result_cluster = migrationService.findMigrationCluster(eventId, 1);
    ClusterTbl cluster = clusterService.find(1);
    List<MigrationShardTbl> result_shards = migrationService.findMigrationShards(result_cluster.getId());
    Assert.assertEquals(eventId, result.getId());
    Assert.assertEquals("unit test", result.getOperator());
    Assert.assertNotNull(result_cluster);
    Assert.assertEquals(1, result_cluster.getClusterId());
    Assert.assertEquals(2, result_cluster.getDestinationDcId());
    Assert.assertEquals(MigrationStatus.Initiated.toString(), result_cluster.getStatus());
    Assert.assertEquals(ClusterStatus.Lock.toString(), cluster.getStatus());
    Assert.assertEquals(2, result_shards.size());
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) ClusterTbl(com.ctrip.xpipe.redis.console.model.ClusterTbl) MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) MigrationShardTbl(com.ctrip.xpipe.redis.console.model.MigrationShardTbl) MigrationEventTbl(com.ctrip.xpipe.redis.console.model.MigrationEventTbl) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test) DirtiesContext(org.springframework.test.annotation.DirtiesContext)

Aggregations

MigrationShardTbl (com.ctrip.xpipe.redis.console.model.MigrationShardTbl)3 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)1 ClusterTbl (com.ctrip.xpipe.redis.console.model.ClusterTbl)1 MigrationClusterTbl (com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)1 MigrationEventTbl (com.ctrip.xpipe.redis.console.model.MigrationEventTbl)1 Test (org.junit.Test)1 DirtiesContext (org.springframework.test.annotation.DirtiesContext)1 DalException (org.unidal.dal.jdbc.DalException)1