aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process/src
diff options
context:
space:
mode:
authorEric Hartmann <hartmann.eric@gmail.com>2017-08-14 16:44:35 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-09-05 14:24:12 +0200
commitd95bc1cd4454a7bd1e16ffc15fba14546c698909 (patch)
treeaf426ea88d83793f541e858fcf5f49d19ccb563b /server/sonar-process/src
parent6180e8d4cd207f716a6729bd32ef6694629a0811 (diff)
downloadsonarqube-d95bc1cd4454a7bd1e16ffc15fba14546c698909.tar.gz
sonarqube-d95bc1cd4454a7bd1e16ffc15fba14546c698909.zip
SONAR-9712 reduce types of cluster nodes to only: application OR search
Diffstat (limited to 'server/sonar-process/src')
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/NodeType.java53
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java7
2 files changed, 54 insertions, 6 deletions
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
new file mode 100644
index 00000000000..55f6e5ef86f
--- /dev/null
+++ b/server/sonar-process/src/main/java/org/sonar/process/NodeType.java
@@ -0,0 +1,53 @@
+/*
+ * 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 javax.annotation.Nullable;
+
+import static java.util.Arrays.stream;
+
+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(@Nullable String nodeType) {
+ if (nodeType == null) {
+ throw new IllegalStateException("Setting [" + ProcessProperties.CLUSTER_NODE_TYPE + "] is mandatory");
+ }
+ return stream(values())
+ .filter(t -> nodeType.equals(t.value))
+ .findFirst()
+ .orElseThrow(() -> new IllegalStateException("Invalid value for [" + ProcessProperties.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/main/java/org/sonar/process/ProcessProperties.java b/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java
index e9f6d46c0f6..802c4bf27a6 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java
@@ -30,10 +30,8 @@ import java.util.Properties;
*/
public class ProcessProperties {
public static final String CLUSTER_ENABLED = "sonar.cluster.enabled";
- public static final String CLUSTER_CE_DISABLED = "sonar.cluster.ce.disabled";
- public static final String CLUSTER_SEARCH_DISABLED = "sonar.cluster.search.disabled";
+ public static final String CLUSTER_NODE_TYPE = "sonar.cluster.node.type";
public static final String CLUSTER_SEARCH_HOSTS = "sonar.cluster.search.hosts";
- public static final String CLUSTER_WEB_DISABLED = "sonar.cluster.web.disabled";
public static final String CLUSTER_HOSTS = "sonar.cluster.hosts";
public static final String CLUSTER_PORT = "sonar.cluster.port";
public static final String CLUSTER_NETWORK_INTERFACES = "sonar.cluster.networkInterfaces";
@@ -138,9 +136,6 @@ public class ProcessProperties {
defaults.put(JDBC_TIME_BETWEEN_EVICTION_RUNS_MILLIS, "30000");
defaults.put(CLUSTER_ENABLED, "false");
- defaults.put(CLUSTER_CE_DISABLED, "false");
- defaults.put(CLUSTER_WEB_DISABLED, "false");
- defaults.put(CLUSTER_SEARCH_DISABLED, "false");
defaults.put(CLUSTER_NAME, "sonarqube");
defaults.put(CLUSTER_NETWORK_INTERFACES, "");
defaults.put(CLUSTER_HOSTS, "");