Search in sources :

Example 1 with ShardMigrationResult

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

the class MigrationPartialSuccessState method doAction.

@Override
public void doAction() {
    for (final MigrationShard shard : getHolder().getMigrationShards()) {
        ShardMigrationResult shardMigrationResult = shard.getShardMigrationResult();
        if (!shardMigrationResult.stepSuccess(ShardMigrationStep.MIGRATE_NEW_PRIMARY_DC)) {
            shardMigrationResult.stepRetry(ShardMigrationStep.MIGRATE_NEW_PRIMARY_DC);
            String clusterName = getHolder().clusterName();
            String shardName = shard.shardName();
            logger.info("[doAction][execute]{}, {}", clusterName, shardName);
            executors.execute(new AbstractExceptionLogTask() {

                @Override
                public void doRun() {
                    logger.info("[doMigrate][start]{},{}", clusterName, shardName);
                    shard.doMigrate();
                    logger.info("[doMigrate][done]{},{}", clusterName, shardName);
                }
            });
        }
    }
}
Also used : MigrationShard(com.ctrip.xpipe.redis.console.migration.model.MigrationShard) AbstractExceptionLogTask(com.ctrip.xpipe.concurrent.AbstractExceptionLogTask) ShardMigrationResult(com.ctrip.xpipe.redis.console.migration.model.ShardMigrationResult)

Example 2 with ShardMigrationResult

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

the class DefaultShardMigrationResultTest method testEncodeDecode.

@Test
public void testEncodeDecode() {
    DefaultShardMigrationResult result = new DefaultShardMigrationResult();
    for (ShardMigrationStep step : ShardMigrationStep.values()) {
        result.updateStepResult(step, true, randomString(10));
    }
    result.setNewMaster(new HostPort("127.0.0.1", randomPort()));
    String encode = result.encode();
    ShardMigrationResult decode = DefaultShardMigrationResult.fromEncodeStr(encode);
    logger.info("{}", decode);
    Assert.assertEquals(result, decode);
}
Also used : ShardMigrationStep(com.ctrip.xpipe.redis.console.migration.model.ShardMigrationStep) HostPort(com.ctrip.xpipe.endpoint.HostPort) ShardMigrationResult(com.ctrip.xpipe.redis.console.migration.model.ShardMigrationResult) Test(org.junit.Test) AbstractConsoleTest(com.ctrip.xpipe.redis.console.AbstractConsoleTest)

Aggregations

ShardMigrationResult (com.ctrip.xpipe.redis.console.migration.model.ShardMigrationResult)2 AbstractExceptionLogTask (com.ctrip.xpipe.concurrent.AbstractExceptionLogTask)1 HostPort (com.ctrip.xpipe.endpoint.HostPort)1 AbstractConsoleTest (com.ctrip.xpipe.redis.console.AbstractConsoleTest)1 MigrationShard (com.ctrip.xpipe.redis.console.migration.model.MigrationShard)1 ShardMigrationStep (com.ctrip.xpipe.redis.console.migration.model.ShardMigrationStep)1 Test (org.junit.Test)1