use of com.ctrip.xpipe.redis.console.migration.model.MigrationEvent in project x-pipe by ctripcorp.
the class MigrationEventDao method loadMigrationEvent.
private MigrationEvent loadMigrationEvent(List<MigrationEventTbl> details) {
if (!CollectionUtils.isEmpty(details)) {
MigrationEvent event = new DefaultMigrationEvent(details.get(0));
for (MigrationEventTbl detail : details) {
MigrationClusterTbl cluster = detail.getRedundantClusters();
MigrationShardTbl shard = detail.getRedundantShards();
if (null == event.getMigrationCluster(cluster.getClusterId())) {
event.addMigrationCluster(new DefaultMigrationCluster(executors, scheduled, event, detail.getRedundantClusters(), dcService, clusterService, shardService, redisService, migrationService));
}
MigrationCluster migrationCluster = event.getMigrationCluster(cluster.getClusterId());
migrationCluster.addNewMigrationShard(new DefaultMigrationShard(migrationCluster, shard, migrationCluster.getClusterShards().get(shard.getShardId()), migrationCluster.getClusterDcs(), migrationService));
}
return event;
}
throw new BadRequestException("Cannot load migration event from null.");
}
use of com.ctrip.xpipe.redis.console.migration.model.MigrationEvent in project x-pipe by ctripcorp.
the class MigrationServiceImpl method continueMigrationEvent.
@Override
public void continueMigrationEvent(long id) {
logger.info("[continueMigrationEvent]{}", id);
MigrationEvent event = getEvent(id);
if (event == null) {
throw new IllegalArgumentException("event not found:" + id);
}
event.process();
}
use of com.ctrip.xpipe.redis.console.migration.model.MigrationEvent in project x-pipe by ctripcorp.
the class DefaultMigrationEventManager method getEvent.
@Override
public MigrationEvent getEvent(long eventId) {
MigrationEvent migrationEvent = currentWorkingEvents.get(eventId);
if (migrationEvent == null) {
// load it from db
logger.info("[getEvent][load from db]{}", eventId);
migrationEvent = loadAndAdd(eventId);
}
return migrationEvent;
}
use of com.ctrip.xpipe.redis.console.migration.model.MigrationEvent in project x-pipe by ctripcorp.
the class DefaultMigrationEventManager method defaultMigrationEventManager.
@PostConstruct
public void defaultMigrationEventManager() {
scheduled = Executors.newScheduledThreadPool(1, XpipeThreadFactory.create("EventManagerCleaner"));
scheduled.scheduleWithFixedDelay(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
List<Long> finished = new LinkedList<>();
currentWorkingEvents.forEach((id, migrationEvent) -> {
if (migrationEvent.isDone()) {
finished.add(id);
}
});
finished.forEach((id) -> removeEvent(id));
}
}, 60, 60, TimeUnit.SECONDS);
}
use of com.ctrip.xpipe.redis.console.migration.model.MigrationEvent in project x-pipe by ctripcorp.
the class MigrationServiceImpl method createMigrationEvent.
@Override
public Long createMigrationEvent(MigrationRequest request) {
MigrationEvent event = migrationEventDao.createMigrationEvent(request);
migrationEventManager.addEvent(event);
return event.getEvent().getId();
}
Aggregations