use of com.sohu.cache.entity.AppDataMigrateStatus in project cachecloud by sohutv.
the class AppDataMigrateCenterImpl method sampleCheckData.
@Override
public CommandResult sampleCheckData(long id, int nums) {
AppDataMigrateStatus appDataMigrateStatus = appDataMigrateStatusDao.get(id);
if (appDataMigrateStatus == null) {
return null;
}
String ip = appDataMigrateStatus.getMigrateMachineIp();
String configPath = appDataMigrateStatus.getConfigPath();
String sampleCheckDataCmd = ConstUtils.getRedisMigrateToolCmd() + " -c " + configPath + " -C" + " 'redis_check " + nums + "'";
logger.warn("sampleCheckDataCmd: {}", sampleCheckDataCmd);
try {
return new CommandResult(sampleCheckDataCmd, SSHUtil.execute(ip, sampleCheckDataCmd));
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new CommandResult(sampleCheckDataCmd, ErrorMessageEnum.INNER_ERROR_MSG.getMessage());
}
}
use of com.sohu.cache.entity.AppDataMigrateStatus in project cachecloud by sohutv.
the class AppDataMigrateCenterImpl method stopMigrate.
@Override
public AppDataMigrateResult stopMigrate(long id) {
// 获取基本信息
AppDataMigrateStatus appDataMigrateStatus = appDataMigrateStatusDao.get(id);
if (appDataMigrateStatus == null) {
return AppDataMigrateResult.fail("id=" + id + "迁移记录不存在!");
}
// 获取进程号
String migrateMachineIp = appDataMigrateStatus.getMigrateMachineIp();
String migrateMachineHostPort = migrateMachineIp + ":" + appDataMigrateStatus.getMigrateMachinePort();
Map<RedisMigrateToolConstant, Map<String, Object>> redisMigrateToolStatMap = showMiragteToolProcess(id);
if (MapUtils.isEmpty(redisMigrateToolStatMap)) {
return AppDataMigrateResult.fail("获取" + migrateMachineHostPort + "相关信息失败,可能是进程不存在或者客户端超时,请查找原因或重试!");
}
Map<String, Object> serverMap = redisMigrateToolStatMap.get(RedisMigrateToolConstant.Server);
int pid = MapUtils.getInteger(serverMap, "process_id", -1);
if (pid <= 0) {
return AppDataMigrateResult.fail("获取" + migrateMachineHostPort + "的进程号" + pid + "异常");
}
// 确认进程号是redis-migrate-tool进程
Boolean exist = checkPidWhetherIsRmt(migrateMachineIp, pid);
if (exist == null) {
return AppDataMigrateResult.fail("执行过程中发生异常,请查看系统日志!");
} else if (exist.equals(false)) {
return AppDataMigrateResult.fail(migrateMachineIp + "进程号" + pid + "不存在,请确认!");
}
// kill掉进程
try {
String cmd = "kill " + pid;
SSHUtil.execute(migrateMachineIp, cmd);
exist = checkPidWhetherIsRmt(migrateMachineIp, pid);
if (exist == null) {
return AppDataMigrateResult.fail(ErrorMessageEnum.INNER_ERROR_MSG.getMessage());
} else if (exist.equals(false)) {
// 更新记录完成更新
appDataMigrateStatusDao.updateStatus(id, AppDataMigrateStatusEnum.END.getStatus());
return AppDataMigrateResult.success("已经成功停止了id=" + id + "的迁移任务");
} else {
return AppDataMigrateResult.fail(migrateMachineIp + "进程号" + pid + "仍然存在,没有kill掉,请确认!");
}
} catch (Exception e) {
logger.error(e.getMessage());
return AppDataMigrateResult.fail(ErrorMessageEnum.INNER_ERROR_MSG.getMessage());
}
}
use of com.sohu.cache.entity.AppDataMigrateStatus in project cachecloud by sohutv.
the class AppDataMigrateCenterImpl method showDataMigrateConf.
@Override
public String showDataMigrateConf(long id) {
AppDataMigrateStatus appDataMigrateStatus = appDataMigrateStatusDao.get(id);
if (appDataMigrateStatus == null) {
return "";
}
String configPath = appDataMigrateStatus.getConfigPath();
String host = appDataMigrateStatus.getMigrateMachineIp();
String command = "cat " + configPath;
try {
return SSHUtil.execute(host, command);
} catch (SSHException e) {
logger.error(e.getMessage(), e);
return "";
}
}
use of com.sohu.cache.entity.AppDataMigrateStatus in project cachecloud by sohutv.
the class AppDataMigrateStatusDaoTest method testSave.
@Test
public void testSave() {
AppDataMigrateStatus appDataMigrateStatus = new AppDataMigrateStatus();
appDataMigrateStatus.setEndTime(new Date());
appDataMigrateStatus.setMigrateMachineIp("10.10.53.159");
appDataMigrateStatus.setMigrateMachinePort(8888);
appDataMigrateStatus.setStartTime(new Date());
appDataMigrateStatus.setStatus(1);
appDataMigrateStatus.setUserId(10244);
appDataMigrateStatus.setSourceAppId(10023);
appDataMigrateStatus.setSourceMigrateType(1);
appDataMigrateStatus.setSourceServers("10.10.53.159:6379");
appDataMigrateStatus.setTargetAppId(0);
appDataMigrateStatus.setTargetMigrateType(2);
appDataMigrateStatus.setTargetServers("10.10.52.136:6385");
appDataMigrateStatus.setLogPath("/opt/redis-migrate-tool/rmt-20160609144601.log");
appDataMigrateStatus.setConfigPath("/opt/redis-migrate-tool/rmt-20160609144601.conf");
appDataMigrateStatusDao.save(appDataMigrateStatus);
}
use of com.sohu.cache.entity.AppDataMigrateStatus in project cachecloud by sohutv.
the class AppDataMigrateStatusDaoTest method testUpdate.
@Test
public void testUpdate() {
long id = 1;
int status = AppDataMigrateStatusEnum.END.getStatus();
appDataMigrateStatusDao.updateStatus(id, status);
AppDataMigrateStatus appDataMigrateStatus = appDataMigrateStatusDao.get(id);
logger.info("==============testGet start==============");
logger.info(appDataMigrateStatus.toString());
logger.info("==============testGet end==============");
}
Aggregations