]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-7330 Remove last usage of old RuleIndex
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 24 Feb 2016 20:11:32 +0000 (21:11 +0100)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Mon, 29 Feb 2016 12:26:54 +0000 (13:26 +0100)
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
server/sonar-server/src/main/java/org/sonar/server/qualityprofile/QProfileBackuper.java
server/sonar-server/src/main/java/org/sonar/server/rule/RuleService.java
server/sonar-server/src/main/java/org/sonar/server/search/EsSearchModule.java
server/sonar-server/src/test/java/org/sonar/server/platform/BackendCleanupMediumTest.java
server/sonar-server/src/test/java/org/sonar/server/search/EsSearchModuleTest.java
sonar-db/src/main/java/org/sonar/db/DbSession.java

index 52c7f87c18f12da194b8c4154f0d88d68a0fa5f9..cfbf3199350845b5502143718dc61de8f90d5a3a 100644 (file)
@@ -43,12 +43,10 @@ import org.sonar.server.platform.ServerImpl;
 import org.sonar.server.platform.ServerSettings;
 import org.sonar.server.platform.TempFolderProvider;
 import org.sonar.server.qualityprofile.db.ActiveRuleDao;
-import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
 import org.sonar.server.qualityprofile.index.ActiveRuleIndex2;
 import org.sonar.server.qualityprofile.index.ActiveRuleNormalizer;
 import org.sonar.server.ruby.PlatformRackBridge;
 import org.sonar.server.rule.db.RuleDao;
-import org.sonar.server.rule.index.RuleIndex;
 import org.sonar.server.rule.index.RuleIndex2;
 import org.sonar.server.rule.index.RuleNormalizer;
 import org.sonar.server.search.EsSearchModule;
@@ -114,8 +112,6 @@ public class PlatformLevel1 extends PlatformLevel {
       ActiveRuleIndex2.class,
       RuleNormalizer.class,
       ActiveRuleNormalizer.class,
-      RuleIndex.class,
-      ActiveRuleIndex.class,
 
       // issues
       IssueIndex.class,
index bcab0c84a7898c3ee9f3717ff785569cb48e2fa9..86174d38ac3f933180ef1f28833f0cbf516a7d04 100644 (file)
@@ -43,25 +43,25 @@ import org.codehaus.staxmate.in.SMInputCursor;
 import org.sonar.api.rule.RuleKey;
 import org.sonar.api.server.ServerSide;
 import org.sonar.api.utils.text.XmlWriter;
+import org.sonar.db.DbClient;
 import org.sonar.db.DbSession;
 import org.sonar.db.qualityprofile.QualityProfileDto;
-import org.sonar.db.DbClient;
-import org.sonar.server.qualityprofile.index.ActiveRuleIndex;
-import org.sonar.server.search.IndexClient;
+import org.sonar.server.qualityprofile.index.ActiveRuleDoc;
+import org.sonar.server.qualityprofile.index.ActiveRuleIndex2;
 
 @ServerSide
 public class QProfileBackuper {
 
   private final QProfileReset reset;
   private final DbClient db;
-  private final IndexClient index;
+  private final ActiveRuleIndex2 activeRuleIndex;
 
   private static final Joiner RULEKEY_JOINER = Joiner.on(", ").skipNulls();
 
-  public QProfileBackuper(QProfileReset reset, DbClient db, IndexClient index) {
+  public QProfileBackuper(QProfileReset reset, DbClient db, ActiveRuleIndex2 activeRuleIndex) {
     this.reset = reset;
     this.db = db;
-    this.index = index;
+    this.activeRuleIndex = activeRuleIndex;
   }
 
   public void backup(String key, Writer writer) {
@@ -72,12 +72,12 @@ public class QProfileBackuper {
     } finally {
       dbSession.close();
     }
-    List<ActiveRule> activeRules = Lists.newArrayList(index.get(ActiveRuleIndex.class).findByProfile(profile.getKey()));
+    List<ActiveRuleDoc> activeRules = Lists.newArrayList(activeRuleIndex.findByProfile(profile.getKey()));
     Collections.sort(activeRules, BackupActiveRuleComparator.INSTANCE);
     writeXml(writer, profile, activeRules.iterator());
   }
 
-  private static void writeXml(Writer writer, QualityProfileDto profile, Iterator<ActiveRule> activeRules) {
+  private static void writeXml(Writer writer, QualityProfileDto profile, Iterator<ActiveRuleDoc> activeRules) {
     XmlWriter xml = XmlWriter.of(writer).declaration();
     xml.begin("profile");
     xml.prop("name", profile.getName());
index 8d8f45d6194ae763262f1a4d87011f8f4f9f20c1..a409042a7e91ed2f6c6e9c576618d17b79e34989 100644 (file)
@@ -75,7 +75,9 @@ public class RuleService {
   }
 
   public Result<Rule> search(RuleQuery query, QueryContext options) {
-    return index.search(query, options);
+    // TODO replace QueryContext by SearchOptions
+    // return index.search(query, options);
+    throw new UnsupportedOperationException("Wait for replacement of QueryContext by SearchOptions ");
   }
 
   /**
index 258d31b0c63d0b4ed6ddaf88ce8ccec1865be261..59dc77ee2c134320c99c3a7514faa495c0be501b 100644 (file)
@@ -27,7 +27,6 @@ public class EsSearchModule extends Module {
   protected void configureModule() {
     add(
       SearchClient.class,
-      IndexClient.class,
       EsClient.class);
   }
 }
index f15c7025e746d035110ae1069ffd48c76b31f544..b48c0bbc64dc91659994dce5fbc3db7d486bfd80 100644 (file)
@@ -25,6 +25,7 @@ import org.junit.ClassRule;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
+import org.sonar.api.config.Settings;
 import org.sonar.api.utils.System2;
 import org.sonar.db.DbTester;
 import org.sonar.db.rule.RuleTesting;
@@ -32,6 +33,7 @@ import org.sonar.server.es.EsTester;
 import org.sonar.server.issue.IssueTesting;
 import org.sonar.server.issue.index.IssueIndexDefinition;
 import org.sonar.server.rule.index.RuleDoc;
+import org.sonar.server.rule.index.RuleIndexDefinition;
 import org.sonar.server.rule.index.RuleNormalizer;
 import org.sonar.server.search.IndexDefinition;
 import org.sonar.server.view.index.ViewDoc;
@@ -45,7 +47,11 @@ import static org.assertj.core.api.Assertions.assertThat;
 public class BackendCleanupMediumTest {
 
   @ClassRule
-  public static EsTester esTester = new EsTester();
+  public static EsTester esTester = new EsTester().addDefinitions(
+    new RuleIndexDefinition(new Settings()),
+    new IssueIndexDefinition(new Settings()),
+    new ViewIndexDefinition(new Settings())
+  );
 
   @Rule
   public DbTester dbTester = DbTester.create(System2.INSTANCE);
index 2f4a0835bbb73fda8fb8b8c6f9b0f76617a1ea71..abf95a396c8265d393ddfdf3966506dc0d5b550b 100644 (file)
@@ -29,7 +29,7 @@ public class EsSearchModuleTest {
   public void verify_count_of_added_components() {
     ComponentContainer container = new ComponentContainer();
     new EsSearchModule().configure(container);
-    assertThat(container.size()).isEqualTo(5);
+    assertThat(container.size()).isEqualTo(4);
   }
 
 }
index a2d97d2a5f1f00e9ab13b19da738c32a63919a97..08e2b4ba04dbb621f508d32df1fd5661b7f265b6 100644 (file)
@@ -35,22 +35,28 @@ public class DbSession implements SqlSession {
 
   private List<ClusterAction> actions;
 
-  private WorkQueue queue;
   private SqlSession session;
   private int actionCount;
 
   public DbSession(WorkQueue queue, SqlSession session) {
     this.actionCount = 0;
     this.session = session;
-    this.queue = queue;
     this.actions = new ArrayList<>();
   }
 
+  /**
+   * @deprecated since 5.5, not used anymore
+   */
+  @Deprecated
   public void enqueue(ClusterAction action) {
     actionCount++;
     this.actions.add(action);
   }
 
+  /**
+   * @deprecated since 5.5, not used anymore
+   */
+  @Deprecated
   public int getActionCount() {
     return actionCount;
   }
@@ -58,14 +64,12 @@ public class DbSession implements SqlSession {
   @Override
   public void commit() {
     session.commit();
-    queue.enqueue(actions);
     actions.clear();
   }
 
   @Override
   public void commit(boolean force) {
     session.commit(force);
-    queue.enqueue(actions);
     actions.clear();
   }