use of com.ctrip.xpipe.redis.console.migration.status.MigrationStatus in project x-pipe by ctripcorp.
the class MigrationClusterDaoTest method testFindUnfinishedByClusterId.
@Test
public void testFindUnfinishedByClusterId() throws SQLException, IOException {
int count = 0;
for (MigrationStatus migrationStatus : MigrationStatus.values()) {
if (!migrationStatus.isTerminated()) {
count++;
}
MigrationClusterTbl tbl = createMigrationClusterTbl(migrationStatus);
tbl.setClusterId(clusterId);
migrationClusterDao.insert(tbl);
}
List<MigrationClusterTbl> unfinished = migrationClusterDao.findUnfinishedByClusterId(clusterId);
logger.debug("{}", unfinished);
Assert.assertEquals(count, unfinished.size());
long previousId = Long.MIN_VALUE;
for (MigrationClusterTbl tbl : unfinished) {
long currentId = tbl.getId();
Assert.assertTrue(currentId > previousId);
previousId = currentId;
}
}
use of com.ctrip.xpipe.redis.console.migration.status.MigrationStatus in project x-pipe by ctripcorp.
the class MigrationClusterDaoTest method randomInsert.
private long randomInsert() {
MigrationStatus migrationStatus = MigrationStatus.Publish;
MigrationClusterTbl tbl = createMigrationClusterTbl(migrationStatus);
tbl.setClusterId(clusterId);
migrationClusterDao.insert(tbl);
return tbl.getId();
}
use of com.ctrip.xpipe.redis.console.migration.status.MigrationStatus in project x-pipe by ctripcorp.
the class MigrationApi method checkStatus.
@RequestMapping(value = "/checkstatus/{ticketId}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_UTF8_VALUE })
public CheckStatusResponse checkStatus(@PathVariable int ticketId) {
logger.info("[checkStatus]{}", ticketId);
CheckStatusResponse response = new CheckStatusResponse();
MigrationEvent migrationEvent = migrationService.getMigrationEvent(ticketId);
if (migrationEvent == null) {
logger.error("[checkStatus][can not find eventId]{}", ticketId);
return response;
}
migrationEvent.getMigrationClusters().forEach(migrationCluster -> {
String clusterName = migrationCluster.clusterName();
MigrationStatus migrationStatus = migrationCluster.getStatus();
CheckStatusClusterResponse checkResponse = new CheckStatusClusterResponse(clusterName, DO_STATUS.fromMigrationStatus(migrationStatus), migrationStatus.getPercent(), migrationStatus.toString());
checkResponse.setFromIdc(migrationCluster.fromDc());
checkResponse.setToIdc(migrationCluster.destDc());
response.addResult(checkResponse);
});
mapResponseIdc(response.getResults());
return response;
}
Aggregations