@Test public void init() { service.init(); }
@PostConstruct public void init() { LogUtil.defaultLog.warn("DumpService start"); DumpProcessor processor = new DumpProcessor(this); DumpAllProcessor dumpAllProcessor = new DumpAllProcessor(this); DumpAllBetaProcessor dumpAllBetaProcessor = new DumpAllBetaProcessor(this); DumpAllTagProcessor dumpAllTagProcessor = new DumpAllTagProcessor(this); dumpTaskMgr = new TaskManager("com.alibaba.nacos.server.DumpTaskManager"); dumpTaskMgr.setDefaultTaskProcessor(processor); dumpAllTaskMgr = new TaskManager("com.alibaba.nacos.server.DumpAllTaskManager"); dumpAllTaskMgr.setDefaultTaskProcessor(dumpAllProcessor); Runnable dumpAll = () -> dumpAllTaskMgr.addTask(DumpAllTask.TASK_ID, new DumpAllTask()); Runnable dumpAllBeta = () -> dumpAllTaskMgr.addTask(DumpAllBetaTask.TASK_ID, new DumpAllBetaTask()); Runnable clearConfigHistory = () -> { log.warn("clearConfigHistory start"); if (ServerListService.isFirstIp()) { try { Timestamp startTime = getBeforeStamp(TimeUtils.getCurrentTime(), 24 * getRetentionDays()); int totalCount = persistService.findConfigHistoryCountByTime(startTime); if (totalCount > 0) { int pageSize = 1000; int removeTime = (totalCount + pageSize - 1) / pageSize; log.warn("clearConfigHistory, getBeforeStamp:{}, totalCount:{}, pageSize:{}, removeTime:{}", new Object[] {startTime, totalCount, pageSize, removeTime}); while (removeTime > 0) { persistService.removeConfigHistory(startTime, pageSize); removeTime--; } } } catch (Throwable e) { log.error("clearConfigHistory error", e); } } }; try { dumpConfigInfo(dumpAllProcessor); LogUtil.defaultLog.info("start clear all config-info-beta."); DiskUtil.clearAllBeta(); if (persistService.isExistTable(BETA_TABLE_NAME)) { dumpAllBetaProcessor.process(DumpAllBetaTask.TASK_ID, new DumpAllBetaTask()); } LogUtil.defaultLog.info("start clear all config-info-tag."); DiskUtil.clearAllTag(); if (persistService.isExistTable(TAG_TABLE_NAME)) { dumpAllTagProcessor.process(DumpAllTagTask.TASK_ID, new DumpAllTagTask()); } List<ConfigInfoChanged> configList = persistService.findAllAggrGroup(); if (configList != null && !configList.isEmpty()) { total = configList.size(); List<List<ConfigInfoChanged>> splitList = splitList(configList, INIT_THREAD_COUNT); for (List<ConfigInfoChanged> list : splitList) { MergeAllDataWorker work = new MergeAllDataWorker(list); work.start(); } log.info("server start, schedule merge end."); } } catch (Exception e) { LogUtil.fatalLog.error( "Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage(), e.getCause()); throw new RuntimeException( "Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage()); } if (!STANDALONE_MODE) { Runnable heartbeat = () -> { String heartBeatTime = TimeUtils.getCurrentTime().toString(); try { DiskUtil.saveHeartBeatToDisk(heartBeatTime); } catch (IOException e) { LogUtil.fatalLog.error("save heartbeat fail" + e.getMessage()); } }; TimerTaskService.scheduleWithFixedDelay(heartbeat, 0, 10, TimeUnit.SECONDS); long initialDelay = new Random().nextInt(INITIAL_DELAY_IN_MINUTE) + 10; LogUtil.defaultLog.warn("initialDelay:{}", initialDelay); TimerTaskService.scheduleWithFixedDelay(dumpAll, initialDelay, DUMP_ALL_INTERVAL_IN_MINUTE, TimeUnit.MINUTES); TimerTaskService.scheduleWithFixedDelay(dumpAllBeta, initialDelay, DUMP_ALL_INTERVAL_IN_MINUTE, TimeUnit.MINUTES); } TimerTaskService.scheduleWithFixedDelay(clearConfigHistory, 10, 10, TimeUnit.MINUTES); }
DumpService { @PostConstruct public void init() { LogUtil.defaultLog.warn("DumpService start"); DumpProcessor processor = new DumpProcessor(this); DumpAllProcessor dumpAllProcessor = new DumpAllProcessor(this); DumpAllBetaProcessor dumpAllBetaProcessor = new DumpAllBetaProcessor(this); DumpAllTagProcessor dumpAllTagProcessor = new DumpAllTagProcessor(this); dumpTaskMgr = new TaskManager("com.alibaba.nacos.server.DumpTaskManager"); dumpTaskMgr.setDefaultTaskProcessor(processor); dumpAllTaskMgr = new TaskManager("com.alibaba.nacos.server.DumpAllTaskManager"); dumpAllTaskMgr.setDefaultTaskProcessor(dumpAllProcessor); Runnable dumpAll = () -> dumpAllTaskMgr.addTask(DumpAllTask.TASK_ID, new DumpAllTask()); Runnable dumpAllBeta = () -> dumpAllTaskMgr.addTask(DumpAllBetaTask.TASK_ID, new DumpAllBetaTask()); Runnable clearConfigHistory = () -> { log.warn("clearConfigHistory start"); if (ServerListService.isFirstIp()) { try { Timestamp startTime = getBeforeStamp(TimeUtils.getCurrentTime(), 24 * getRetentionDays()); int totalCount = persistService.findConfigHistoryCountByTime(startTime); if (totalCount > 0) { int pageSize = 1000; int removeTime = (totalCount + pageSize - 1) / pageSize; log.warn("clearConfigHistory, getBeforeStamp:{}, totalCount:{}, pageSize:{}, removeTime:{}", new Object[] {startTime, totalCount, pageSize, removeTime}); while (removeTime > 0) { persistService.removeConfigHistory(startTime, pageSize); removeTime--; } } } catch (Throwable e) { log.error("clearConfigHistory error", e); } } }; try { dumpConfigInfo(dumpAllProcessor); LogUtil.defaultLog.info("start clear all config-info-beta."); DiskUtil.clearAllBeta(); if (persistService.isExistTable(BETA_TABLE_NAME)) { dumpAllBetaProcessor.process(DumpAllBetaTask.TASK_ID, new DumpAllBetaTask()); } LogUtil.defaultLog.info("start clear all config-info-tag."); DiskUtil.clearAllTag(); if (persistService.isExistTable(TAG_TABLE_NAME)) { dumpAllTagProcessor.process(DumpAllTagTask.TASK_ID, new DumpAllTagTask()); } List<ConfigInfoChanged> configList = persistService.findAllAggrGroup(); if (configList != null && !configList.isEmpty()) { total = configList.size(); List<List<ConfigInfoChanged>> splitList = splitList(configList, INIT_THREAD_COUNT); for (List<ConfigInfoChanged> list : splitList) { MergeAllDataWorker work = new MergeAllDataWorker(list); work.start(); } log.info("server start, schedule merge end."); } } catch (Exception e) { LogUtil.fatalLog.error( "Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage(), e.getCause()); throw new RuntimeException( "Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage()); } if (!STANDALONE_MODE) { Runnable heartbeat = () -> { String heartBeatTime = TimeUtils.getCurrentTime().toString(); try { DiskUtil.saveHeartBeatToDisk(heartBeatTime); } catch (IOException e) { LogUtil.fatalLog.error("save heartbeat fail" + e.getMessage()); } }; TimerTaskService.scheduleWithFixedDelay(heartbeat, 0, 10, TimeUnit.SECONDS); long initialDelay = new Random().nextInt(INITIAL_DELAY_IN_MINUTE) + 10; LogUtil.defaultLog.warn("initialDelay:{}", initialDelay); TimerTaskService.scheduleWithFixedDelay(dumpAll, initialDelay, DUMP_ALL_INTERVAL_IN_MINUTE, TimeUnit.MINUTES); TimerTaskService.scheduleWithFixedDelay(dumpAllBeta, initialDelay, DUMP_ALL_INTERVAL_IN_MINUTE, TimeUnit.MINUTES); } TimerTaskService.scheduleWithFixedDelay(clearConfigHistory, 10, 10, TimeUnit.MINUTES); } }
DumpService { @PostConstruct public void init() { LogUtil.defaultLog.warn("DumpService start"); DumpProcessor processor = new DumpProcessor(this); DumpAllProcessor dumpAllProcessor = new DumpAllProcessor(this); DumpAllBetaProcessor dumpAllBetaProcessor = new DumpAllBetaProcessor(this); DumpAllTagProcessor dumpAllTagProcessor = new DumpAllTagProcessor(this); dumpTaskMgr = new TaskManager("com.alibaba.nacos.server.DumpTaskManager"); dumpTaskMgr.setDefaultTaskProcessor(processor); dumpAllTaskMgr = new TaskManager("com.alibaba.nacos.server.DumpAllTaskManager"); dumpAllTaskMgr.setDefaultTaskProcessor(dumpAllProcessor); Runnable dumpAll = () -> dumpAllTaskMgr.addTask(DumpAllTask.TASK_ID, new DumpAllTask()); Runnable dumpAllBeta = () -> dumpAllTaskMgr.addTask(DumpAllBetaTask.TASK_ID, new DumpAllBetaTask()); Runnable clearConfigHistory = () -> { log.warn("clearConfigHistory start"); if (ServerListService.isFirstIp()) { try { Timestamp startTime = getBeforeStamp(TimeUtils.getCurrentTime(), 24 * getRetentionDays()); int totalCount = persistService.findConfigHistoryCountByTime(startTime); if (totalCount > 0) { int pageSize = 1000; int removeTime = (totalCount + pageSize - 1) / pageSize; log.warn("clearConfigHistory, getBeforeStamp:{}, totalCount:{}, pageSize:{}, removeTime:{}", new Object[] {startTime, totalCount, pageSize, removeTime}); while (removeTime > 0) { persistService.removeConfigHistory(startTime, pageSize); removeTime--; } } } catch (Throwable e) { log.error("clearConfigHistory error", e); } } }; try { dumpConfigInfo(dumpAllProcessor); LogUtil.defaultLog.info("start clear all config-info-beta."); DiskUtil.clearAllBeta(); if (persistService.isExistTable(BETA_TABLE_NAME)) { dumpAllBetaProcessor.process(DumpAllBetaTask.TASK_ID, new DumpAllBetaTask()); } LogUtil.defaultLog.info("start clear all config-info-tag."); DiskUtil.clearAllTag(); if (persistService.isExistTable(TAG_TABLE_NAME)) { dumpAllTagProcessor.process(DumpAllTagTask.TASK_ID, new DumpAllTagTask()); } List<ConfigInfoChanged> configList = persistService.findAllAggrGroup(); if (configList != null && !configList.isEmpty()) { total = configList.size(); List<List<ConfigInfoChanged>> splitList = splitList(configList, INIT_THREAD_COUNT); for (List<ConfigInfoChanged> list : splitList) { MergeAllDataWorker work = new MergeAllDataWorker(list); work.start(); } log.info("server start, schedule merge end."); } } catch (Exception e) { LogUtil.fatalLog.error( "Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage(), e.getCause()); throw new RuntimeException( "Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage()); } if (!STANDALONE_MODE) { Runnable heartbeat = () -> { String heartBeatTime = TimeUtils.getCurrentTime().toString(); try { DiskUtil.saveHeartBeatToDisk(heartBeatTime); } catch (IOException e) { LogUtil.fatalLog.error("save heartbeat fail" + e.getMessage()); } }; TimerTaskService.scheduleWithFixedDelay(heartbeat, 0, 10, TimeUnit.SECONDS); long initialDelay = new Random().nextInt(INITIAL_DELAY_IN_MINUTE) + 10; LogUtil.defaultLog.warn("initialDelay:{}", initialDelay); TimerTaskService.scheduleWithFixedDelay(dumpAll, initialDelay, DUMP_ALL_INTERVAL_IN_MINUTE, TimeUnit.MINUTES); TimerTaskService.scheduleWithFixedDelay(dumpAllBeta, initialDelay, DUMP_ALL_INTERVAL_IN_MINUTE, TimeUnit.MINUTES); } TimerTaskService.scheduleWithFixedDelay(clearConfigHistory, 10, 10, TimeUnit.MINUTES); }  }
DumpService { @PostConstruct public void init() { LogUtil.defaultLog.warn("DumpService start"); DumpProcessor processor = new DumpProcessor(this); DumpAllProcessor dumpAllProcessor = new DumpAllProcessor(this); DumpAllBetaProcessor dumpAllBetaProcessor = new DumpAllBetaProcessor(this); DumpAllTagProcessor dumpAllTagProcessor = new DumpAllTagProcessor(this); dumpTaskMgr = new TaskManager("com.alibaba.nacos.server.DumpTaskManager"); dumpTaskMgr.setDefaultTaskProcessor(processor); dumpAllTaskMgr = new TaskManager("com.alibaba.nacos.server.DumpAllTaskManager"); dumpAllTaskMgr.setDefaultTaskProcessor(dumpAllProcessor); Runnable dumpAll = () -> dumpAllTaskMgr.addTask(DumpAllTask.TASK_ID, new DumpAllTask()); Runnable dumpAllBeta = () -> dumpAllTaskMgr.addTask(DumpAllBetaTask.TASK_ID, new DumpAllBetaTask()); Runnable clearConfigHistory = () -> { log.warn("clearConfigHistory start"); if (ServerListService.isFirstIp()) { try { Timestamp startTime = getBeforeStamp(TimeUtils.getCurrentTime(), 24 * getRetentionDays()); int totalCount = persistService.findConfigHistoryCountByTime(startTime); if (totalCount > 0) { int pageSize = 1000; int removeTime = (totalCount + pageSize - 1) / pageSize; log.warn("clearConfigHistory, getBeforeStamp:{}, totalCount:{}, pageSize:{}, removeTime:{}", new Object[] {startTime, totalCount, pageSize, removeTime}); while (removeTime > 0) { persistService.removeConfigHistory(startTime, pageSize); removeTime--; } } } catch (Throwable e) { log.error("clearConfigHistory error", e); } } }; try { dumpConfigInfo(dumpAllProcessor); LogUtil.defaultLog.info("start clear all config-info-beta."); DiskUtil.clearAllBeta(); if (persistService.isExistTable(BETA_TABLE_NAME)) { dumpAllBetaProcessor.process(DumpAllBetaTask.TASK_ID, new DumpAllBetaTask()); } LogUtil.defaultLog.info("start clear all config-info-tag."); DiskUtil.clearAllTag(); if (persistService.isExistTable(TAG_TABLE_NAME)) { dumpAllTagProcessor.process(DumpAllTagTask.TASK_ID, new DumpAllTagTask()); } List<ConfigInfoChanged> configList = persistService.findAllAggrGroup(); if (configList != null && !configList.isEmpty()) { total = configList.size(); List<List<ConfigInfoChanged>> splitList = splitList(configList, INIT_THREAD_COUNT); for (List<ConfigInfoChanged> list : splitList) { MergeAllDataWorker work = new MergeAllDataWorker(list); work.start(); } log.info("server start, schedule merge end."); } } catch (Exception e) { LogUtil.fatalLog.error( "Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage(), e.getCause()); throw new RuntimeException( "Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage()); } if (!STANDALONE_MODE) { Runnable heartbeat = () -> { String heartBeatTime = TimeUtils.getCurrentTime().toString(); try { DiskUtil.saveHeartBeatToDisk(heartBeatTime); } catch (IOException e) { LogUtil.fatalLog.error("save heartbeat fail" + e.getMessage()); } }; TimerTaskService.scheduleWithFixedDelay(heartbeat, 0, 10, TimeUnit.SECONDS); long initialDelay = new Random().nextInt(INITIAL_DELAY_IN_MINUTE) + 10; LogUtil.defaultLog.warn("initialDelay:{}", initialDelay); TimerTaskService.scheduleWithFixedDelay(dumpAll, initialDelay, DUMP_ALL_INTERVAL_IN_MINUTE, TimeUnit.MINUTES); TimerTaskService.scheduleWithFixedDelay(dumpAllBeta, initialDelay, DUMP_ALL_INTERVAL_IN_MINUTE, TimeUnit.MINUTES); } TimerTaskService.scheduleWithFixedDelay(clearConfigHistory, 10, 10, TimeUnit.MINUTES); }  @PostConstruct void init(); void dump(String dataId, String group, String tenant, String tag, long lastModified, String handleIp); void dump(String dataId, String group, String tenant, long lastModified, String handleIp); void dump(String dataId, String group, String tenant, long lastModified, String handleIp, boolean isBeta); void dump(String dataId, String group, String tenant, String tag, long lastModified, String handleIp,
                     boolean isBeta); void dumpAll(); }
DumpService { @PostConstruct public void init() { LogUtil.defaultLog.warn("DumpService start"); DumpProcessor processor = new DumpProcessor(this); DumpAllProcessor dumpAllProcessor = new DumpAllProcessor(this); DumpAllBetaProcessor dumpAllBetaProcessor = new DumpAllBetaProcessor(this); DumpAllTagProcessor dumpAllTagProcessor = new DumpAllTagProcessor(this); dumpTaskMgr = new TaskManager("com.alibaba.nacos.server.DumpTaskManager"); dumpTaskMgr.setDefaultTaskProcessor(processor); dumpAllTaskMgr = new TaskManager("com.alibaba.nacos.server.DumpAllTaskManager"); dumpAllTaskMgr.setDefaultTaskProcessor(dumpAllProcessor); Runnable dumpAll = () -> dumpAllTaskMgr.addTask(DumpAllTask.TASK_ID, new DumpAllTask()); Runnable dumpAllBeta = () -> dumpAllTaskMgr.addTask(DumpAllBetaTask.TASK_ID, new DumpAllBetaTask()); Runnable clearConfigHistory = () -> { log.warn("clearConfigHistory start"); if (ServerListService.isFirstIp()) { try { Timestamp startTime = getBeforeStamp(TimeUtils.getCurrentTime(), 24 * getRetentionDays()); int totalCount = persistService.findConfigHistoryCountByTime(startTime); if (totalCount > 0) { int pageSize = 1000; int removeTime = (totalCount + pageSize - 1) / pageSize; log.warn("clearConfigHistory, getBeforeStamp:{}, totalCount:{}, pageSize:{}, removeTime:{}", new Object[] {startTime, totalCount, pageSize, removeTime}); while (removeTime > 0) { persistService.removeConfigHistory(startTime, pageSize); removeTime--; } } } catch (Throwable e) { log.error("clearConfigHistory error", e); } } }; try { dumpConfigInfo(dumpAllProcessor); LogUtil.defaultLog.info("start clear all config-info-beta."); DiskUtil.clearAllBeta(); if (persistService.isExistTable(BETA_TABLE_NAME)) { dumpAllBetaProcessor.process(DumpAllBetaTask.TASK_ID, new DumpAllBetaTask()); } LogUtil.defaultLog.info("start clear all config-info-tag."); DiskUtil.clearAllTag(); if (persistService.isExistTable(TAG_TABLE_NAME)) { dumpAllTagProcessor.process(DumpAllTagTask.TASK_ID, new DumpAllTagTask()); } List<ConfigInfoChanged> configList = persistService.findAllAggrGroup(); if (configList != null && !configList.isEmpty()) { total = configList.size(); List<List<ConfigInfoChanged>> splitList = splitList(configList, INIT_THREAD_COUNT); for (List<ConfigInfoChanged> list : splitList) { MergeAllDataWorker work = new MergeAllDataWorker(list); work.start(); } log.info("server start, schedule merge end."); } } catch (Exception e) { LogUtil.fatalLog.error( "Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage(), e.getCause()); throw new RuntimeException( "Nacos Server did not start because dumpservice bean construction failure :\n" + e.getMessage()); } if (!STANDALONE_MODE) { Runnable heartbeat = () -> { String heartBeatTime = TimeUtils.getCurrentTime().toString(); try { DiskUtil.saveHeartBeatToDisk(heartBeatTime); } catch (IOException e) { LogUtil.fatalLog.error("save heartbeat fail" + e.getMessage()); } }; TimerTaskService.scheduleWithFixedDelay(heartbeat, 0, 10, TimeUnit.SECONDS); long initialDelay = new Random().nextInt(INITIAL_DELAY_IN_MINUTE) + 10; LogUtil.defaultLog.warn("initialDelay:{}", initialDelay); TimerTaskService.scheduleWithFixedDelay(dumpAll, initialDelay, DUMP_ALL_INTERVAL_IN_MINUTE, TimeUnit.MINUTES); TimerTaskService.scheduleWithFixedDelay(dumpAllBeta, initialDelay, DUMP_ALL_INTERVAL_IN_MINUTE, TimeUnit.MINUTES); } TimerTaskService.scheduleWithFixedDelay(clearConfigHistory, 10, 10, TimeUnit.MINUTES); }  @PostConstruct void init(); void dump(String dataId, String group, String tenant, String tag, long lastModified, String handleIp); void dump(String dataId, String group, String tenant, long lastModified, String handleIp); void dump(String dataId, String group, String tenant, long lastModified, String handleIp, boolean isBeta); void dump(String dataId, String group, String tenant, String tag, long lastModified, String handleIp,
                     boolean isBeta); void dumpAll();  }