]> source.dussan.org Git - sonarqube.git/commitdiff
Clean-up ES module in sonar-server
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Sat, 10 Mar 2018 14:33:35 +0000 (15:33 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Mon, 12 Mar 2018 08:24:24 +0000 (09:24 +0100)
server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
server/sonar-server/src/main/java/org/sonar/server/es/EsModule.java [new file with mode: 0644]
server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
server/sonar-server/src/main/java/org/sonar/server/plugins/ServerExtensionInstaller.java
server/sonar-server/src/main/java/org/sonar/server/search/EsSearchModule.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/FacetValue.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/search/package-info.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/es/EsModuleTest.java [new file with mode: 0644]
server/sonar-server/src/test/java/org/sonar/server/search/EsSearchModuleTest.java [deleted file]
server/sonar-server/src/test/java/org/sonar/server/search/FacetValueTest.java [deleted file]

index 80ea989fe53e41c0a8729fae9a6e368f5e80f232..eb3f3c9e3532a7299c98cd8b85294bc73c832189 100644 (file)
@@ -143,7 +143,7 @@ import org.sonar.server.rule.DefaultRuleFinder;
 import org.sonar.server.rule.DeprecatedRulesDefinitionLoader;
 import org.sonar.server.rule.RuleDefinitionsLoader;
 import org.sonar.server.rule.index.RuleIndex;
-import org.sonar.server.search.EsSearchModule;
+import org.sonar.server.es.EsModule;
 import org.sonar.server.setting.DatabaseSettingLoader;
 import org.sonar.server.setting.DatabaseSettingsEnabler;
 import org.sonar.server.setting.ThreadLocalSettings;
@@ -265,7 +265,7 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
       DbClient.class,
 
       // Elasticsearch
-      EsSearchModule.class,
+      EsModule.class,
 
       // rules/qprofiles
       RuleIndex.class,
index bf87bddc6538db7d6684a7f2189536c71377921c..64ed2a4a89b910977bc880a4fd4cc111b22f9401 100644 (file)
@@ -119,7 +119,7 @@ public class ComputeEngineContainerImplTest {
       COMPONENTS_IN_LEVEL_1_AT_CONSTRUCTION
         + 26 // level 1
         + 53 // content of DaoModule
-        + 3 // content of EsSearchModule
+        + 3 // content of EsModule
         + 57 // content of CorePropertyDefinitions
         + 1 // StopFlagContainer
     );
diff --git a/server/sonar-server/src/main/java/org/sonar/server/es/EsModule.java b/server/sonar-server/src/main/java/org/sonar/server/es/EsModule.java
new file mode 100644 (file)
index 0000000..bb306dc
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.es;
+
+import org.sonar.core.platform.Module;
+import org.sonar.server.permission.index.AuthorizationTypeSupport;
+
+public class EsModule extends Module {
+  @Override
+  protected void configureModule() {
+    add(AuthorizationTypeSupport.class);
+    add(new EsClientProvider());
+    add(EsClientStopper.class);
+  }
+}
index f86edc0e288a05fd9b5be9a2e0682b2d61890813..5dc9e5b92f7f186d40f9953523d4df3232a13810 100644 (file)
@@ -43,6 +43,7 @@ import org.sonar.process.logging.LogbackHelper;
 import org.sonar.server.app.ProcessCommandWrapperImpl;
 import org.sonar.server.app.RestartFlagHolderImpl;
 import org.sonar.server.app.WebServerProcessLogging;
+import org.sonar.server.es.EsModule;
 import org.sonar.server.issue.index.IssueIndex;
 import org.sonar.server.platform.LogServerVersion;
 import org.sonar.server.platform.Platform;
@@ -52,7 +53,6 @@ import org.sonar.server.platform.UrlSettings;
 import org.sonar.server.platform.WebServerImpl;
 import org.sonar.server.platform.db.EmbeddedDatabaseFactory;
 import org.sonar.server.rule.index.RuleIndex;
-import org.sonar.server.search.EsSearchModule;
 import org.sonar.server.setting.ThreadLocalSettings;
 import org.sonar.server.user.SystemPasscodeImpl;
 import org.sonar.server.user.ThreadLocalUserSession;
@@ -112,7 +112,7 @@ public class PlatformLevel1 extends PlatformLevel {
       DaoModule.class,
 
       // Elasticsearch
-      EsSearchModule.class,
+      EsModule.class,
 
       // rules/qprofiles
       RuleIndex.class,
index f6fe4d1dadd2dd2092841ed9c1b3a47c27722b0b..ae94ead30eb47724a6261cac870bd29addff4c34 100644 (file)
@@ -23,10 +23,8 @@ import com.google.common.collect.ArrayListMultimap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.ListMultimap;
 import java.lang.annotation.Annotation;
-import java.util.Collection;
 import java.util.Map;
 import java.util.Set;
-import javax.annotation.Nullable;
 import org.sonar.api.ExtensionProvider;
 import org.sonar.api.Plugin;
 import org.sonar.api.SonarRuntime;
@@ -37,7 +35,6 @@ import org.sonar.core.platform.ComponentContainer;
 import org.sonar.core.platform.PluginInfo;
 import org.sonar.core.platform.PluginRepository;
 
-import static com.google.common.base.Preconditions.checkArgument;
 import static java.util.Objects.requireNonNull;
 
 /**
@@ -49,16 +46,6 @@ public abstract class ServerExtensionInstaller {
   private final PluginRepository pluginRepository;
   private final Set<Class<? extends Annotation>> supportedAnnotationTypes;
 
-  protected ServerExtensionInstaller(SonarRuntime sonarRuntime, PluginRepository pluginRepository,
-    @Nullable Collection<Class<? extends Annotation>> supportedAnnotationTypes) {
-    checkArgument(supportedAnnotationTypes != null && !supportedAnnotationTypes.isEmpty(),
-      "At least one supported annotation type must be specified");
-    this.sonarRuntime = sonarRuntime;
-    this.pluginRepository = pluginRepository;
-    this.supportedAnnotationTypes = ImmutableSet.copyOf(supportedAnnotationTypes);
-
-  }
-
   protected ServerExtensionInstaller(SonarRuntime sonarRuntime, PluginRepository pluginRepository,
     Class<? extends Annotation>... supportedAnnotationTypes) {
     requireNonNull(supportedAnnotationTypes, "At least one supported annotation type must be specified");
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/EsSearchModule.java b/server/sonar-server/src/main/java/org/sonar/server/search/EsSearchModule.java
deleted file mode 100644 (file)
index 77db684..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.search;
-
-import org.sonar.core.platform.Module;
-import org.sonar.server.es.EsClientProvider;
-import org.sonar.server.es.EsClientStopper;
-import org.sonar.server.permission.index.AuthorizationTypeSupport;
-
-public class EsSearchModule extends Module {
-  @Override
-  protected void configureModule() {
-    add(AuthorizationTypeSupport.class);
-    add(new EsClientProvider());
-    add(EsClientStopper.class);
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/FacetValue.java b/server/sonar-server/src/main/java/org/sonar/server/search/FacetValue.java
deleted file mode 100644 (file)
index 06c3b72..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.search;
-
-public class FacetValue {
-
-  private final String key;
-  private final long value;
-
-  public FacetValue(String key, long value) {
-    this.key = key;
-    this.value = value;
-  }
-
-  public String getKey() {
-    return key;
-  }
-
-  public long getValue() {
-    return value;
-  }
-
-  @Override
-  public boolean equals(Object o) {
-    if (this == o) {
-      return true;
-    }
-    if (o == null || getClass() != o.getClass()) {
-      return false;
-    }
-
-    FacetValue that = (FacetValue) o;
-    if (key == null) {
-      return that.key == null;
-    } else {
-      return key.equals(that.key);
-    }
-  }
-
-  @Override
-  public int hashCode() {
-    return key != null ? key.hashCode() : 0;
-  }
-
-  @Override
-  public String toString() {
-    return String.format("{%s=%d}", getKey(), getValue());
-  }
-}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/search/package-info.java b/server/sonar-server/src/main/java/org/sonar/server/search/package-info.java
deleted file mode 100644 (file)
index 1ab4678..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.server.search;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-server/src/test/java/org/sonar/server/es/EsModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/es/EsModuleTest.java
new file mode 100644 (file)
index 0000000..972f8ad
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2018 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+package org.sonar.server.es;
+
+import org.junit.Test;
+import org.sonar.core.platform.ComponentContainer;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class EsModuleTest {
+  @Test
+  public void verify_count_of_added_components() {
+    ComponentContainer container = new ComponentContainer();
+    new EsModule().configure(container);
+    assertThat(container.size()).isEqualTo(3 + 2);
+  }
+
+}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/EsSearchModuleTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/EsSearchModuleTest.java
deleted file mode 100644 (file)
index 2bc33e5..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.search;
-
-import org.junit.Test;
-import org.sonar.core.platform.ComponentContainer;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class EsSearchModuleTest {
-  @Test
-  public void verify_count_of_added_components() {
-    ComponentContainer container = new ComponentContainer();
-    new EsSearchModule().configure(container);
-    assertThat(container.size()).isEqualTo(3 + 2);
-  }
-
-}
diff --git a/server/sonar-server/src/test/java/org/sonar/server/search/FacetValueTest.java b/server/sonar-server/src/test/java/org/sonar/server/search/FacetValueTest.java
deleted file mode 100644 (file)
index 4b42d0d..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2018 SonarSource SA
- * mailto:info AT sonarsource DOT com
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
-package org.sonar.server.search;
-
-import org.junit.Test;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class FacetValueTest {
-
-  @Test
-  public void should_check_for_equality_on_key() {
-    FacetValue facetValue = new FacetValue("polop", 42);
-    assertThat(facetValue.equals(facetValue)).isTrue();
-    assertThat(facetValue.equals(null)).isFalse();
-    assertThat(facetValue.equals(new Object())).isFalse();
-
-    assertThat(facetValue.equals(new FacetValue("polop", 666))).isTrue();
-    assertThat(facetValue.equals(new FacetValue("palap", 42))).isFalse();
-
-    FacetValue withNullKey = new FacetValue(null, 42);
-    assertThat(facetValue.equals(withNullKey)).isFalse();
-    assertThat(withNullKey.equals(withNullKey)).isTrue();
-    assertThat(withNullKey.equals(facetValue)).isFalse();
-    assertThat(withNullKey.equals(new FacetValue(null, 666))).isTrue();
-  }
-
-  @Test
-  public void should_use_key_hashcode() {
-    assertThat(new FacetValue(null, 42).hashCode()).isZero();
-    String key = "polop";
-    assertThat(new FacetValue(key, 666).hashCode()).isEqualTo(key.hashCode());
-  }
-
-  @Test
-  public void test_toString() {
-    assertThat(new FacetValue("polop", 42).toString()).isEqualTo("{polop=42}");
-  }
-}