瀏覽代碼

SONAR-6315 add debug logs in RegisterRules for active rules ops

tags/6.4-RC1
Sébastien Lesaint 7 年之前
父節點
當前提交
701d8fad28
共有 1 個文件被更改,包括 11 次插入2 次删除
  1. 11
    2
      server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java

+ 11
- 2
server/sonar-server/src/main/java/org/sonar/server/rule/RegisterRules.java 查看文件

@@ -60,6 +60,7 @@ import org.sonar.server.rule.index.RuleIndexer;

import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.Lists.newArrayList;
import static java.lang.String.format;

/**
* Register rules at server startup
@@ -190,7 +191,7 @@ public class RegisterRules implements Startable {
}
for (RulesDefinition.ExtendedRepository extendedRepoDef : context.extendedRepositories()) {
if (context.repository(extendedRepoDef.key()) == null) {
LOG.warn(String.format("Extension is ignored, repository %s does not exist", extendedRepoDef.key()));
LOG.warn(format("Extension is ignored, repository %s does not exist", extendedRepoDef.key()));
} else {
repositories.add(extendedRepoDef);
}
@@ -318,10 +319,13 @@ public class RegisterRules implements Startable {
List<RuleParamDto> paramDtos = dbClient.ruleDao().selectRuleParamsByRuleKey(session, rule.getKey());
Map<String, RuleParamDto> existingParamsByName = Maps.newHashMap();

Profiler profiler = Profiler.create(Loggers.get(getClass()));
for (RuleParamDto paramDto : paramDtos) {
RulesDefinition.Param paramDef = ruleDef.param(paramDto.getName());
if (paramDef == null) {
profiler.start();
dbClient.activeRuleDao().deleteParamsByRuleParamOfAllOrganizations(session, rule.getId(), paramDto.getName());
profiler.stopDebug(format("Propagate deleted param with name %s to active rules of rule %s", paramDto.getName(), rule.getKey()));
dbClient.ruleDao().deleteRuleParam(session, paramDto.getId());
} else {
if (mergeParam(paramDto, paramDef)) {
@@ -347,10 +351,12 @@ public class RegisterRules implements Startable {
continue;
}
// Propagate the default value to existing active rule parameters
profiler.start();
for (ActiveRuleDto activeRule : dbClient.activeRuleDao().selectByRuleIdOfAllOrganizations(session, rule.getId())) {
ActiveRuleParamDto activeParam = ActiveRuleParamDto.createFor(paramDto).setValue(param.defaultValue());
dbClient.activeRuleDao().insertParam(session, activeRule, activeParam);
}
profiler.stopDebug(format("Propagate new param with name %s to active rules of rule %s", paramDto.getName(), rule.getKey()));
}
}

@@ -418,7 +424,7 @@ public class RegisterRules implements Startable {
}

private void removeRule(DbSession session, List<RuleDefinitionDto> removedRules, RuleDefinitionDto rule) {
LOG.info(String.format("Disable rule %s", rule.getKey()));
LOG.info(format("Disable rule %s", rule.getKey()));
rule.setStatus(RuleStatus.REMOVED);
rule.setSystemTags(Collections.emptySet());
update(session, rule);
@@ -483,10 +489,13 @@ public class RegisterRules implements Startable {
List<String> repositoryKeys = newArrayList(Iterables.transform(context.repositories(), RulesDefinition.Repository::key));

List<ActiveRuleChange> changes = new ArrayList<>();
Profiler profiler = Profiler.create(Loggers.get(getClass()));
for (RuleDefinitionDto rule : removedRules) {
// SONAR-4642 Remove active rules only when repository still exists
if (repositoryKeys.contains(rule.getRepositoryKey())) {
profiler.start();
changes.addAll(ruleActivator.deactivateOfAllOrganizations(session, rule));
profiler.stopDebug(format("Remove active rule for rule %s", rule.getKey()));
}
}
return changes;

Loading…
取消
儲存