zoukankan      html  css  js  c++  java
  • 百万数据迁移的线程分组

    comtroller层开启线程:
        new Thread(() -> oracleQueryService.findOfficeList(oracleListRequestModel)).start();
    service执行查询和插入操作
    public ResultModel findOfficeList(OracleListRequestModel oracleListRequestModel) { ResultModel resultModel = new ResultModel(); try { int subSize = migrationConfig.getSubsize();// 引配置文件 临时10个测试 resultModel.setSuccess(true); List<OfficeCustomerEntity> officeList = oracleQueryRepository.findOfficeList(oracleListRequestModel); int size = officeList.size(); logger.info("本次官网帐号迁移数量:" + size + " 起始时间:" + oracleListRequestModel.getStartDate() + " 截止时间:" + oracleListRequestModel.getEndDate()); int length; if (size % subSize == 0) { length = size / subSize; } else { length = size / subSize + 1; } int start = 0; int end = 0; for (int i = 0; i < length; i++) { List<OfficeCustomerEntity> newOfficeList; if (i * subSize + subSize <= size) { newOfficeList = officeList.subList(i * subSize, i * subSize + subSize); start = i * subSize; end = i * subSize + subSize; } else { newOfficeList = officeList.subList(i * subSize, size); start = i * subSize; end = size; } migExecutorPool.officeMigBatch(newOfficeList, start, end, oracleListRequestModel.getStartDate(), oracleListRequestModel.getEndDate()); } } catch (Exception e) { logger.error("迁移出错:" + e.getMessage(), e); resultModel.setMessage("迁移出错:" + e + " " + e.getMessage()); return resultModel; }
  • 相关阅读:
    RestTemplate proxy 设置方式
    一道关于主键,闭包的软考题------关系代数复习-码,范式,闭包求解
    MyBatis的XML中使用内部类的方式
    MyBatis SpringBoot 杂记
    服务器安装笔记
    UML符号
    npm 设置代理
    国外一家代码网站
    设计模式复习
    docker 列出每个容器的IP
  • 原文地址:https://www.cnblogs.com/otways/p/11169603.html
Copyright © 2011-2022 走看看