Search in sources :

Example 1 with MigrationStatus

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;
    }
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) MigrationStatus(com.ctrip.xpipe.redis.console.migration.status.MigrationStatus) AbstractConsoleIntegrationTest(com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest) Test(org.junit.Test)

Example 2 with MigrationStatus

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();
}
Also used : MigrationClusterTbl(com.ctrip.xpipe.redis.console.model.MigrationClusterTbl) MigrationStatus(com.ctrip.xpipe.redis.console.migration.status.MigrationStatus)

Example 3 with MigrationStatus

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;
}
Also used : MigrationStatus(com.ctrip.xpipe.redis.console.migration.status.MigrationStatus) MigrationEvent(com.ctrip.xpipe.redis.console.migration.model.MigrationEvent)

Aggregations

MigrationStatus (com.ctrip.xpipe.redis.console.migration.status.MigrationStatus)3 MigrationClusterTbl (com.ctrip.xpipe.redis.console.model.MigrationClusterTbl)2 AbstractConsoleIntegrationTest (com.ctrip.xpipe.redis.console.AbstractConsoleIntegrationTest)1 MigrationEvent (com.ctrip.xpipe.redis.console.migration.model.MigrationEvent)1 Test (org.junit.Test)1