Skip to content

Commit

Permalink
rm metric type cache
Browse files Browse the repository at this point in the history
  • Loading branch information
saimu.msm committed Jul 9, 2024
1 parent 73fba08 commit 8a4d6e1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ public class SuperCache {
public List<String> resourceKeys;
public List<String> freePrefixes;

public Set<String> metricTypes;

public Set<String> integrationProducts;

public String getStringValue(String type, String k) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -75,18 +74,6 @@ private Set<String> queryIntegrationProducts() {
.collect(Collectors.toSet());
}

private Set<String> queryMetricTypes() {
QueryWrapper<MetricInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.select("DISTINCT metric_type");
List<MetricInfo> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ public class AlarmRuleLevelAuthorizationChecker extends AbstractQueryChecker
new HashSet<>(Arrays.asList("default", "gradual", "fixed"));
private static final Set<String> aggregators = new HashSet<>(Arrays.asList("sum", "avg", "min",
"max", "count", "none", "SUM", "AVG", "MIN", "MAX", "COUNT", "NONE"));
private static final Set<String> defaultMetricTypes =
new HashSet<>(Arrays.asList("message", "loadbalancing"));
private static final Set<String> 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<String> products = new HashSet<>(
// Arrays.asList("JVM", "Function", "OceanBase", "Tbase", "PortCheck", "System", "MiniProgram",
// "Spanner", "IoT", "APM", "Mysql", "SLB", "SOFAMQX", "Postgres", "Gateway"));
Expand Down Expand Up @@ -423,12 +424,9 @@ private LevelAuthorizationCheckResult checkRule(Map<String, Object> ruleMap, Str

private LevelAuthorizationCheckResult checkDatasources(List<DataSource> datasources,
String tenant, String workspace) {
Set<String> metricTypes = this.superCacheService.getSc().metricTypes;
Set<String> 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());
}
Expand Down

0 comments on commit 8a4d6e1

Please sign in to comment.