Search in sources :

Example 1 with AppDataMigrateEnum

use of com.sohu.cache.constant.AppDataMigrateEnum in project cachecloud by sohutv.

the class AppDataMigrateCenterTest method testMigrateRDB.

@Test
public void testMigrateRDB() {
    String migrateMachineIp = "127.0.0.1";
    AppDataMigrateEnum sourceRedisMigrateEnum = AppDataMigrateEnum.RDB_FILE;
    String sourceServers = "/opt/soft/redis/data/dump-6379.rdb.back";
    AppDataMigrateEnum targetRedisMigrateEnum = AppDataMigrateEnum.REDIS_NODE;
    String targetServers = "127.0.0.1:6380";
    boolean isMigrate = appDataMigrateCenter.migrate(migrateMachineIp, sourceRedisMigrateEnum, sourceServers, targetRedisMigrateEnum, targetServers, 10000, 20000, REDIS_SOURCE_PASS, REDIS_TARGET_PASS, 30000);
    logger.warn("============testMigrate start=============");
    logger.warn("isMigrate:{}", isMigrate);
    logger.warn("============testMigrate end=============");
}
Also used : AppDataMigrateEnum(com.sohu.cache.constant.AppDataMigrateEnum) BaseTest(com.sohu.test.BaseTest) Test(org.junit.Test)

Example 2 with AppDataMigrateEnum

use of com.sohu.cache.constant.AppDataMigrateEnum in project cachecloud by sohutv.

the class AppDataMigrateCenterTest method testCheckMigrateMachine.

@Test
public void testCheckMigrateMachine() {
    // 1.机器是否在列表里(已测)
    // 2.是否正确安装redis-migrate-tool(已测)
    // 3.是否存在正在执行的redis-migrate-tool(已测)
    String migrateMachineIp = "127.0.0.1";
    AppDataMigrateEnum sourceRedisMigrateEnum = AppDataMigrateEnum.REDIS_NODE;
    String sourceServers = "127.0.0.1:6379";
    AppDataMigrateEnum targetRedisMigrateEnum = AppDataMigrateEnum.REDIS_CLUSTER_NODE;
    String targetServers = "127.0.0.1:6380";
    AppDataMigrateResult redisMigrateResult = appDataMigrateCenter.check(migrateMachineIp, sourceRedisMigrateEnum, sourceServers, targetRedisMigrateEnum, targetServers, REDIS_SOURCE_PASS, REDIS_TARGET_PASS);
    logger.info("===============testCheck start=================");
    logger.info(redisMigrateResult.toString());
    logger.info("===============testCheck end=================");
}
Also used : AppDataMigrateEnum(com.sohu.cache.constant.AppDataMigrateEnum) AppDataMigrateResult(com.sohu.cache.constant.AppDataMigrateResult) BaseTest(com.sohu.test.BaseTest) Test(org.junit.Test)

Example 3 with AppDataMigrateEnum

use of com.sohu.cache.constant.AppDataMigrateEnum in project cachecloud by sohutv.

the class AppDataMigrateCenterTest method testCheckServers.

@Test
public void testCheckServers() {
    // 1. 实例列表格式问题(已测)
    // 2.1 rdb文件是否存在(已测)
    // 2.2 redis节点是否存活
    String migrateMachineIp = "127.0.0.1";
    // RedisMigrateEnum sourceRedisMigrateEnum =
    // RedisMigrateEnum.REDIS_NODE;
    // String sourceServers = "127.0.0.1:6388";
    AppDataMigrateEnum sourceRedisMigrateEnum = AppDataMigrateEnum.RDB_FILE;
    String sourceServers = "/opt/soft/redis/data/dump-6380.rdb";
    AppDataMigrateEnum targetRedisMigrateEnum = AppDataMigrateEnum.REDIS_CLUSTER_NODE;
    String targetServers = "127.0.0.1:6380";
    AppDataMigrateResult redisMigrateResult = appDataMigrateCenter.check(migrateMachineIp, sourceRedisMigrateEnum, sourceServers, targetRedisMigrateEnum, targetServers, REDIS_SOURCE_PASS, REDIS_TARGET_PASS);
    logger.info("===============testCheck start=================");
    logger.info(redisMigrateResult.toString());
    logger.info("===============testCheck end=================");
}
Also used : AppDataMigrateEnum(com.sohu.cache.constant.AppDataMigrateEnum) AppDataMigrateResult(com.sohu.cache.constant.AppDataMigrateResult) BaseTest(com.sohu.test.BaseTest) Test(org.junit.Test)

Example 4 with AppDataMigrateEnum

use of com.sohu.cache.constant.AppDataMigrateEnum in project cachecloud by sohutv.

the class AppDataMigrateController method check.

/**
     * 检查配置
     * @return
     */
@RequestMapping(value = "/check")
public ModelAndView check(HttpServletRequest request, HttpServletResponse response, Model model) {
    //相关参数
    String migrateMachineIp = request.getParameter("migrateMachineIp");
    String sourceRedisMigrateIndex = request.getParameter("sourceRedisMigrateIndex");
    AppDataMigrateEnum sourceRedisMigrateEnum = AppDataMigrateEnum.getByIndex(NumberUtils.toInt(sourceRedisMigrateIndex, -1));
    String sourceServers = request.getParameter("sourceServers");
    String targetRedisMigrateIndex = request.getParameter("targetRedisMigrateIndex");
    AppDataMigrateEnum targetRedisMigrateEnum = AppDataMigrateEnum.getByIndex(NumberUtils.toInt(targetRedisMigrateIndex, -1));
    String targetServers = request.getParameter("targetServers");
    String redisSourcePass = request.getParameter("redisSourcePass");
    String redisTargetPass = request.getParameter("redisTargetPass");
    //检查返回结果
    AppDataMigrateResult redisMigrateResult = appDataMigrateCenter.check(migrateMachineIp, sourceRedisMigrateEnum, sourceServers, targetRedisMigrateEnum, targetServers, redisSourcePass, redisTargetPass);
    model.addAttribute("status", redisMigrateResult.getStatus());
    model.addAttribute("message", redisMigrateResult.getMessage());
    return new ModelAndView("");
}
Also used : AppDataMigrateEnum(com.sohu.cache.constant.AppDataMigrateEnum) AppDataMigrateResult(com.sohu.cache.constant.AppDataMigrateResult) ModelAndView(org.springframework.web.servlet.ModelAndView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with AppDataMigrateEnum

use of com.sohu.cache.constant.AppDataMigrateEnum in project cachecloud by sohutv.

the class AppDataMigrateController method start.

/**
     * 开始迁移
     * @return
     */
@RequestMapping(value = "/start")
public ModelAndView start(HttpServletRequest request, HttpServletResponse response, Model model) {
    //相关参数
    String migrateMachineIp = request.getParameter("migrateMachineIp");
    String sourceRedisMigrateIndex = request.getParameter("sourceRedisMigrateIndex");
    AppDataMigrateEnum sourceRedisMigrateEnum = AppDataMigrateEnum.getByIndex(NumberUtils.toInt(sourceRedisMigrateIndex, -1));
    String sourceServers = request.getParameter("sourceServers");
    String targetRedisMigrateIndex = request.getParameter("targetRedisMigrateIndex");
    AppDataMigrateEnum targetRedisMigrateEnum = AppDataMigrateEnum.getByIndex(NumberUtils.toInt(targetRedisMigrateIndex, -1));
    String targetServers = request.getParameter("targetServers");
    long sourceAppId = NumberUtils.toLong(request.getParameter("sourceAppId"));
    long targetAppId = NumberUtils.toLong(request.getParameter("targetAppId"));
    String redisSourcePass = request.getParameter("redisSourcePass");
    String redisTargetPass = request.getParameter("redisTargetPass");
    AppUser appUser = getUserInfo(request);
    long userId = appUser == null ? 0 : appUser.getId();
    // 不需要对格式进行检验,check已经做过了,开始迁移
    boolean isSuccess = appDataMigrateCenter.migrate(migrateMachineIp, sourceRedisMigrateEnum, sourceServers, targetRedisMigrateEnum, targetServers, sourceAppId, targetAppId, redisSourcePass, redisTargetPass, userId);
    model.addAttribute("status", isSuccess ? 1 : 0);
    return new ModelAndView("");
}
Also used : AppDataMigrateEnum(com.sohu.cache.constant.AppDataMigrateEnum) ModelAndView(org.springframework.web.servlet.ModelAndView) AppUser(com.sohu.cache.entity.AppUser) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

AppDataMigrateEnum (com.sohu.cache.constant.AppDataMigrateEnum)7 BaseTest (com.sohu.test.BaseTest)4 Test (org.junit.Test)4 AppDataMigrateResult (com.sohu.cache.constant.AppDataMigrateResult)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 AppUser (com.sohu.cache.entity.AppUser)1