From 8a4d6e1f56fd48b375bd34c73001364e4901aa5d Mon Sep 17 00:00:00 2001 From: "saimu.msm" Date: Tue, 9 Jul 2024 18:40:42 +0800 Subject: [PATCH] rm metric type cache --- .../server/common/service/SuperCache.java | 2 -- .../server/common/service/SuperCacheService.java | 13 ------------- .../custom/AlarmRuleLevelAuthorizationChecker.java | 8 +++----- 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/server/common/common-service/src/main/java/io/holoinsight/server/common/service/SuperCache.java b/server/common/common-service/src/main/java/io/holoinsight/server/common/service/SuperCache.java index 6f6f04d8d..240699f6c 100644 --- a/server/common/common-service/src/main/java/io/holoinsight/server/common/service/SuperCache.java +++ b/server/common/common-service/src/main/java/io/holoinsight/server/common/service/SuperCache.java @@ -26,8 +26,6 @@ public class SuperCache { public List resourceKeys; public List freePrefixes; - public Set metricTypes; - public Set integrationProducts; public String getStringValue(String type, String k) { diff --git a/server/common/common-service/src/main/java/io/holoinsight/server/common/service/SuperCacheService.java b/server/common/common-service/src/main/java/io/holoinsight/server/common/service/SuperCacheService.java index 5055650be..e323bf09c 100644 --- a/server/common/common-service/src/main/java/io/holoinsight/server/common/service/SuperCacheService.java +++ b/server/common/common-service/src/main/java/io/holoinsight/server/common/service/SuperCacheService.java @@ -56,7 +56,6 @@ public void load() throws Exception { sc.getListValue("global_config", "resource_keys", Collections.singletonList("tenant")); sc.freePrefixes = sc.getListValue("global_config", "free_metric_prefix", Collections.emptyList()); - sc.metricTypes = queryMetricTypes(); sc.integrationProducts = queryIntegrationProducts(); this.sc = sc; ProdLog.info("[SuperCache] load end"); @@ -75,18 +74,6 @@ private Set queryIntegrationProducts() { .collect(Collectors.toSet()); } - private Set queryMetricTypes() { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.select("DISTINCT metric_type"); - List metricInfoList = this.metricInfoMapper.selectList(queryWrapper); - if (CollectionUtils.isEmpty(metricInfoList)) { - return Collections.emptySet(); - } - return metricInfoList.stream() // - .map(MetricInfo::getMetricType) // - .collect(Collectors.toSet()); - } - @Override public int periodInSeconds() { return 60; diff --git a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/custom/AlarmRuleLevelAuthorizationChecker.java b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/custom/AlarmRuleLevelAuthorizationChecker.java index 6a5a816b1..527fff341 100644 --- a/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/custom/AlarmRuleLevelAuthorizationChecker.java +++ b/server/home/home-web/src/main/java/io/holoinsight/server/home/web/security/custom/AlarmRuleLevelAuthorizationChecker.java @@ -93,8 +93,9 @@ public class AlarmRuleLevelAuthorizationChecker extends AbstractQueryChecker new HashSet<>(Arrays.asList("default", "gradual", "fixed")); private static final Set aggregators = new HashSet<>(Arrays.asList("sum", "avg", "min", "max", "count", "none", "SUM", "AVG", "MIN", "MAX", "COUNT", "NONE")); - private static final Set defaultMetricTypes = - new HashSet<>(Arrays.asList("message", "loadbalancing")); + private static final Set defaultMetricTypes = new HashSet<>( + Arrays.asList("app", "cache", "log", "oss", "trace", "system", "metric", "service", + "function", "pg", "mongodb", "db", "miniProgram", "mysql", "message", "loadbalancing")); // private static final Set products = new HashSet<>( // Arrays.asList("JVM", "Function", "OceanBase", "Tbase", "PortCheck", "System", "MiniProgram", // "Spanner", "IoT", "APM", "Mysql", "SLB", "SOFAMQX", "Postgres", "Gateway")); @@ -423,12 +424,9 @@ private LevelAuthorizationCheckResult checkRule(Map ruleMap, Str private LevelAuthorizationCheckResult checkDatasources(List datasources, String tenant, String workspace) { - Set metricTypes = this.superCacheService.getSc().metricTypes; Set products = this.superCacheService.getSc().integrationProducts; for (DataSource dataSource : datasources) { if (StringUtils.isNotEmpty(dataSource.getMetricType()) - && !CollectionUtils.isEmpty(metricTypes) - && !metricTypes.contains(dataSource.getMetricType()) && !defaultMetricTypes.contains(dataSource.getMetricType())) { return failCheckResult("invalid metric type %s", dataSource.getMetricType()); }