use of com.ctrip.xpipe.redis.console.migration.model.MigrationCluster in project x-pipe by ctripcorp.
the class AbstractMigrationMigratingState method doMigrateOtherDc.
protected void doMigrateOtherDc() {
logger.debug("[doMigrateOtherDc]{}", this);
MigrationCluster migrationCluster = getHolder();
String clusterName = migrationCluster.clusterName();
for (MigrationShard migrationShard : migrationCluster.getMigrationShards()) {
executors.execute(new AbstractExceptionLogTask() {
@Override
public void doRun() {
String shardName = migrationShard.shardName();
logger.info("[doOtherDcMigrate][start]{},{}", clusterName, shardName);
migrationShard.doMigrateOtherDc();
logger.info("[doOtherDcMigrate][done]{},{}", clusterName, shardName);
}
});
}
}
use of com.ctrip.xpipe.redis.console.migration.model.MigrationCluster in project x-pipe by ctripcorp.
the class DefaultMigrationEvent method isDone.
@Override
public boolean isDone() {
int successCnt = 0;
List<MigrationCluster> migrationClusters = getMigrationClusters();
for (MigrationCluster cluster : migrationClusters) {
if (cluster.getStatus().isTerminated()) {
++successCnt;
}
}
if (successCnt == migrationClusters.size()) {
logger.info("[isDone][true]{}, success:{}", getMigrationEventId(), successCnt);
return true;
}
return false;
}
use of com.ctrip.xpipe.redis.console.migration.model.MigrationCluster in project x-pipe by ctripcorp.
the class DefaultMigrationEvent method rollbackCluster.
@Override
public MigrationCluster rollbackCluster(String clusterName) throws ClusterNotFoundException {
MigrationCluster cluster = getMigrationCluster(clusterName);
if (cluster == null) {
throw new ClusterNotFoundException(clusterName);
}
cluster.rollback();
return cluster;
}
use of com.ctrip.xpipe.redis.console.migration.model.MigrationCluster in project x-pipe by ctripcorp.
the class MigrationApi method rollback.
@RequestMapping(value = "/rollback", method = RequestMethod.POST, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE })
public RollbackResponse rollback(@RequestBody(required = true) RollbackRequest request) {
logger.info("[rollback]{}", request);
long tickedId = request.getTicketId();
if (request.getClusters() == null || request.getClusters().size() == 0) {
return new RollbackResponse();
}
RollbackResponse rollbackResponse = new RollbackResponse();
for (String clusterName : request.getClusters()) {
MigrationCluster migrationCluster = null;
try {
migrationCluster = migrationService.rollbackMigrationCluster(tickedId, clusterName);
rollbackResponse.addResult(new RollbackClusterResponse(true, clusterName, migrationCluster.fromDc(), migrationCluster.destDc(), "success"));
} catch (ClusterNotFoundException e) {
logger.error("[rollback]" + clusterName, e);
rollbackResponse.addResult(new RollbackClusterResponse(false, clusterName, e.getMessage()));
} catch (Exception e) {
logger.error("[rollback]" + clusterName, e);
if (migrationCluster == null) {
rollbackResponse.addResult(new RollbackClusterResponse(false, clusterName, e.getMessage()));
} else {
rollbackResponse.addResult(new RollbackClusterResponse(false, clusterName, migrationCluster.fromDc(), migrationCluster.destDc(), e.getMessage()));
}
}
}
mapResponseIdc(rollbackResponse.getResults());
return rollbackResponse;
}
use of com.ctrip.xpipe.redis.console.migration.model.MigrationCluster in project x-pipe by ctripcorp.
the class MigrationPublishState method updateRedisMaster.
private void updateRedisMaster() throws ResourceNotFoundException {
List<RedisTbl> toUpdate = new LinkedList<>();
MigrationCluster migrationCluster = getHolder();
RedisService redisService = migrationCluster.getRedisService();
String fromDc = migrationCluster.fromDc();
String destDc = migrationCluster.destDc();
String clusterName = migrationCluster.clusterName();
List<RedisTbl> prevDcRedises = redisService.findAllRedisesByDcClusterName(fromDc, clusterName);
for (RedisTbl redis : prevDcRedises) {
if (redis.isMaster()) {
redis.setMaster(false);
toUpdate.add(redis);
}
}
List<RedisTbl> newDcRedises = redisService.findAllRedisesByDcClusterName(destDc, clusterName);
for (InetSocketAddress newMasterAddress : getNewMasters()) {
for (RedisTbl redis : newDcRedises) {
if (redis.getRedisIp().equals(newMasterAddress.getHostString()) && redis.getRedisPort() == newMasterAddress.getPort()) {
redis.setMaster(true);
toUpdate.add(redis);
}
}
}
logger.info("[UpdateMaster]{}", toUpdate);
migrationCluster.getRedisService().updateBatchMaster(toUpdate);
}
Aggregations