Search in sources :

Example 6 with MigrationEvent

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

the class DefaultMigrationEventManager method loadAndAdd.

private MigrationEvent loadAndAdd(long eventId) {
    try {
        MigrationEvent migrationEvent = migrationEventDao.buildMigrationEvent(eventId);
        addEvent(migrationEvent);
        return migrationEvent;
    } catch (Throwable th) {
        logger.error("[load][event]" + eventId, th);
    }
    return null;
}
Also used : MigrationEvent(com.ctrip.xpipe.redis.console.migration.model.MigrationEvent)

Example 7 with MigrationEvent

use of com.ctrip.xpipe.redis.console.migration.model.MigrationEvent 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

MigrationEvent (com.ctrip.xpipe.redis.console.migration.model.MigrationEvent)7 CrossDcLeaderAware (com.ctrip.xpipe.api.cluster.CrossDcLeaderAware)1 Observable (com.ctrip.xpipe.api.observer.Observable)1 AbstractExceptionLogTask (com.ctrip.xpipe.concurrent.AbstractExceptionLogTask)1 MigrationEventDao (com.ctrip.xpipe.redis.console.dao.MigrationEventDao)1 BadRequestException (com.ctrip.xpipe.redis.console.exception.BadRequestException)1 MigrationCluster (com.ctrip.xpipe.redis.console.migration.model.MigrationCluster)1 DefaultMigrationCluster (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationCluster)1 DefaultMigrationEvent (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationEvent)1 DefaultMigrationShard (com.ctrip.xpipe.redis.console.migration.model.impl.DefaultMigrationShard)1 MigrationStatus (com.ctrip.xpipe.redis.console.migration.status.MigrationStatus)1 XpipeThreadFactory (com.ctrip.xpipe.utils.XpipeThreadFactory)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Executors (java.util.concurrent.Executors)1 ScheduledExecutorService (java.util.concurrent.ScheduledExecutorService)1 TimeUnit (java.util.concurrent.TimeUnit)1 PostConstruct (javax.annotation.PostConstruct)1