diff --git a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/impl/TenantAppServerUpdateTask.java b/server/home/home-task/src/main/java/io/holoinsight/server/home/task/impl/TenantAppServerUpdateTask.java deleted file mode 100644 index e0e81b38d..000000000 --- a/server/home/home-task/src/main/java/io/holoinsight/server/home/task/impl/TenantAppServerUpdateTask.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 2022 Holoinsight Project Authors. Licensed under Apache-2.0. - */ -package io.holoinsight.server.home.task.impl; - -import io.holoinsight.server.home.biz.service.MetaTableService; -import io.holoinsight.server.home.common.util.Debugger; -import io.holoinsight.server.home.dal.model.dto.MetaTableDTO; -import io.holoinsight.server.home.task.AbstractMonitorTask; -import io.holoinsight.server.home.task.MonitorTaskJob; -import io.holoinsight.server.home.common.model.TaskEnum; -import io.holoinsight.server.home.task.TaskHandler; -import io.holoinsight.server.meta.facade.service.DataClientService; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; - -/** - * - * @author jsy1001de - * @version 1.0: TenantAppServerUpdateTask.java, v 0.1 2022年08月24日 5:14 下午 jinsong.yjs Exp $ - */ -@Slf4j -@Service -@TaskHandler(TaskEnum.TENANT_APP_SERVER_UPDATE) -public class TenantAppServerUpdateTask extends AbstractMonitorTask { - - public static long EXPIRED = 60 * 60000; - - @Autowired - private MetaTableService metaTableService; - - @Autowired - private DataClientService dataClientService; - - public TenantAppServerUpdateTask() { - super(1, 2, TaskEnum.TENANT_APP_SERVER_UPDATE); - } - - @Override - public boolean needRun() { - return true; - } - - @Override - public List buildJobs(long period) throws Throwable { - List jobs = new ArrayList<>(); - - jobs.add(new MonitorTaskJob() { - @Override - public boolean run() throws Throwable { - - syncAoAction(); - return true; - } - - @Override - public String id() { - return "TENANT_APP_SERVER_UPDATE"; - } - }); - return jobs; - } - - private void syncAoAction() { - List all = metaTableService.findAll(); - - if (CollectionUtils.isEmpty(all)) - return; - - for (MetaTableDTO metaTableDTO : all) { - List> mapList = dataClientService.queryAll(metaTableDTO.getName()); - Debugger.print("TenantAppServerUpdateTask", "qurey meta list from table={} size={}", - metaTableDTO.name, mapList.size()); - if (CollectionUtils.isEmpty(mapList)) { - continue; - } - - Set serverUkSets = new HashSet<>(); - - for (Map map : mapList) { - if (!map.containsKey("_modified")) { - continue; - } - - Double modified = (Double) map.get("_modified"); - - if ((System.currentTimeMillis() - modified) > EXPIRED) { - serverUkSets.add((String) map.get("_uk")); - } - } - Debugger.print("TenantAppServerUpdateTask", "need delete expried list from table={} size={}", - metaTableDTO.name, serverUkSets.size()); - - // 熔断 - if ((serverUkSets.size() * 1.0 / mapList.size()) > 0.8) { - log.warn("need delete expired list from table={} size={} mapList={}, is fusing", - metaTableDTO.name, serverUkSets.size(), mapList.size()); - continue; - } - - dataClientService.delete(metaTableDTO.name, new ArrayList<>(serverUkSets)); - } - } -} diff --git a/server/registry/registry-core/src/main/java/io/holoinsight/server/registry/core/meta/MetaSyncService.java b/server/registry/registry-core/src/main/java/io/holoinsight/server/registry/core/meta/MetaSyncService.java index b7abc8108..f352be831 100644 --- a/server/registry/registry-core/src/main/java/io/holoinsight/server/registry/core/meta/MetaSyncService.java +++ b/server/registry/registry-core/src/main/java/io/holoinsight/server/registry/core/meta/MetaSyncService.java @@ -9,6 +9,7 @@ import java.util.Map; import java.util.Set; +import io.holoinsight.server.common.J; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -273,6 +274,7 @@ private Map> getFromDB(String tableName, String type return new HashMap<>(); } + LOGGER.info("curd detail, [getFromDB], size: {}, {}", mapList.size(), J.toJson(example)); Map> uks = new HashMap<>(); mapList.forEach(row -> { if (row.get("_uk") == null) {