]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9741 move NodeType to sonar-cluster
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Tue, 5 Sep 2017 15:19:17 +0000 (17:19 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Wed, 13 Sep 2017 13:50:54 +0000 (15:50 +0200)
server/sonar-cluster/src/main/java/org/sonar/cluster/ClusterObjectKeys.java
server/sonar-cluster/src/main/java/org/sonar/cluster/NodeType.java [new file with mode: 0644]
server/sonar-cluster/src/test/java/org/sonar/cluster/NodeTypeTest.java [new file with mode: 0644]
server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterProperties.java
server/sonar-main/src/main/java/org/sonar/application/cluster/HazelcastCluster.java
server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java
server/sonar-process/src/main/java/org/sonar/process/NodeType.java [deleted file]
server/sonar-process/src/test/java/org/sonar/process/NodeTypeTest.java [deleted file]
server/sonar-server/src/main/java/org/sonar/server/es/EsClientProvider.java

index ce0a4185850a8d9f2c442f6e3382fea6da3aef84..16464b6c53e00cbf6009757743753ca4b9e29718 100644 (file)
@@ -51,7 +51,7 @@ public final class ClusterObjectKeys {
   public static final String NODE_NAME = "NODE_NAME";
   /**
    * The role of the sonar-application inside the SonarQube cluster
-   * {@link org.sonar.process.NodeType}
+   * {@link org.sonar.cluster.NodeType}
    */
   public static final String NODE_TYPE = "NODE_TYPE";
   /**
diff --git a/server/sonar-cluster/src/main/java/org/sonar/cluster/NodeType.java b/server/sonar-cluster/src/main/java/org/sonar/cluster/NodeType.java
new file mode 100644 (file)
index 0000000..6a2ce53
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.cluster;
+
+import static java.util.Arrays.stream;
+import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
+
+public enum NodeType {
+  APPLICATION("application"), SEARCH("search");
+
+  private final String value;
+
+  NodeType(String value) {
+    this.value = value;
+  }
+
+  public String getValue() {
+    return value;
+  }
+
+  public static NodeType parse(String nodeType) {
+    return stream(values())
+      .filter(t -> nodeType.equals(t.value))
+      .findFirst()
+      .orElseThrow(() -> new IllegalArgumentException("Invalid value for [" + CLUSTER_NODE_TYPE + "]: [" + nodeType + "]"));
+  }
+
+  public static boolean isValid(String nodeType) {
+    return stream(values())
+      .anyMatch(t -> nodeType.equals(t.value));
+  }
+}
diff --git a/server/sonar-cluster/src/test/java/org/sonar/cluster/NodeTypeTest.java b/server/sonar-cluster/src/test/java/org/sonar/cluster/NodeTypeTest.java
new file mode 100644 (file)
index 0000000..12d9e6a
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 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.cluster;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+public class NodeTypeTest {
+
+  @Rule
+  public ExpectedException expectedException = ExpectedException.none();
+
+  @Test
+  public void test_parse() {
+    assertThat(NodeType.parse("application")).isEqualTo(NodeType.APPLICATION);
+    assertThat(NodeType.parse("search")).isEqualTo(NodeType.SEARCH);
+  }
+
+  @Test
+  public void parse_an_unknown_value_must_throw_IAE() {
+    expectedException.expect(IllegalArgumentException.class);
+    expectedException.expectMessage("Invalid value for ");
+
+    NodeType.parse("XYZ");
+  }
+}
index bb25b4f9a0b91df4ffc644b83c6d86fe8352f7d6..4f7dc00e8769ce5639f45340b233a5c21a6b3b61 100644 (file)
@@ -31,7 +31,7 @@ import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.sonar.application.config.AppSettings;
-import org.sonar.process.NodeType;
+import org.sonar.cluster.NodeType;
 
 import static org.sonar.cluster.ClusterProperties.CLUSTER_HOSTS;
 import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_HOST;
index 98f279e6e1ed97b2737acda5426298942ff5e8a7..6625cd2e9265cc26bcfd2aff90d2c2ba0a06b084 100644 (file)
@@ -53,7 +53,7 @@ import org.sonar.application.AppStateListener;
 import org.sonar.cluster.ClusterObjectKeys;
 import org.sonar.cluster.localclient.HazelcastClient;
 import org.sonar.process.MessageException;
-import org.sonar.process.NodeType;
+import org.sonar.cluster.NodeType;
 import org.sonar.process.ProcessId;
 
 import static java.lang.String.format;
index d8ec697ddc7f331f25e0c702b25aa36246f5ac9c..3eb66a2d1b1a88a8c4dadfd9a0917d6445717b7d 100644 (file)
@@ -31,7 +31,7 @@ import java.util.List;
 import java.util.function.Consumer;
 import org.apache.commons.lang.StringUtils;
 import org.sonar.process.MessageException;
-import org.sonar.process.NodeType;
+import org.sonar.cluster.NodeType;
 import org.sonar.process.ProcessId;
 import org.sonar.process.Props;
 
diff --git a/server/sonar-process/src/main/java/org/sonar/process/NodeType.java b/server/sonar-process/src/main/java/org/sonar/process/NodeType.java
deleted file mode 100644 (file)
index ecd8e44..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 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.process;
-
-import static java.util.Arrays.stream;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
-
-public enum NodeType {
-  APPLICATION("application"), SEARCH("search");
-
-  private final String value;
-
-  NodeType(String value) {
-    this.value = value;
-  }
-
-  public String getValue() {
-    return value;
-  }
-
-  public static NodeType parse(String nodeType) {
-    return stream(values())
-      .filter(t -> nodeType.equals(t.value))
-      .findFirst()
-      .orElseThrow(() -> new IllegalArgumentException("Invalid value for [" + CLUSTER_NODE_TYPE + "]: [" + nodeType + "]"));
-  }
-
-  public static boolean isValid(String nodeType) {
-    return stream(values())
-      .anyMatch(t -> nodeType.equals(t.value));
-  }
-}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/NodeTypeTest.java b/server/sonar-process/src/test/java/org/sonar/process/NodeTypeTest.java
deleted file mode 100644 (file)
index 180600a..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * SonarQube
- * Copyright (C) 2009-2017 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.process;
-
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-public class NodeTypeTest {
-
-  @Rule
-  public ExpectedException expectedException = ExpectedException.none();
-
-  @Test
-  public void test_parse() {
-    assertThat(NodeType.parse("application")).isEqualTo(NodeType.APPLICATION);
-    assertThat(NodeType.parse("search")).isEqualTo(NodeType.SEARCH);
-  }
-
-  @Test
-  public void parse_an_unknown_value_must_throw_IAE() {
-    expectedException.expect(IllegalArgumentException.class);
-    expectedException.expectMessage("Invalid value for ");
-
-    NodeType.parse("XYZ");
-  }
-}
index 138ea698fcd2b59622a819e3d18feff4305a6cbf..110ae95f6fa19c077d80c1bde10d373b288c167f 100644 (file)
@@ -34,14 +34,14 @@ import org.sonar.api.config.Configuration;
 import org.sonar.api.server.ServerSide;
 import org.sonar.api.utils.log.Logger;
 import org.sonar.api.utils.log.Loggers;
-import org.sonar.process.NodeType;
+import org.sonar.cluster.NodeType;
 import org.sonar.process.ProcessProperties;
 
 import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
 import static org.sonar.cluster.ClusterProperties.CLUSTER_NAME;
 import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
 import static org.sonar.cluster.ClusterProperties.CLUSTER_SEARCH_HOSTS;
-import static org.sonar.process.NodeType.SEARCH;
+import static org.sonar.cluster.NodeType.SEARCH;
 
 @ComputeEngineSide
 @ServerSide