aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process/src/main
diff options
context:
space:
mode:
authorJacek <jacek.poreda@sonarsource.com>2020-10-27 11:20:27 +0100
committersonartech <sonartech@sonarsource.com>2020-11-05 20:06:21 +0000
commit874973829ca3a7ba8e39709d478695216357cf97 (patch)
tree509b51dedf72342369f23dc768c4983a3ddc69a4 /server/sonar-process/src/main
parenta8820c6601c71a31729372d3db5c77824bbadb85 (diff)
downloadsonarqube-874973829ca3a7ba8e39709d478695216357cf97.tar.gz
sonarqube-874973829ca3a7ba8e39709d478695216357cf97.zip
SONAR-14039 replace 'sonar.search.transportPort' with 'sonar.es.port' on non-DCE
Diffstat (limited to 'server/sonar-process/src/main')
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java16
1 files changed, 12 insertions, 4 deletions
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 a1e7089900f..7038fc4952c 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
@@ -36,6 +36,7 @@ import org.sonar.core.extension.ServiceLoaderWrapper;
import static com.google.common.base.Preconditions.checkState;
import static java.lang.String.format;
import static org.sonar.process.ProcessProperties.Property.CLUSTER_ENABLED;
+import static org.sonar.process.ProcessProperties.Property.ES_PORT;
import static org.sonar.process.ProcessProperties.Property.SEARCH_HOST;
import static org.sonar.process.ProcessProperties.Property.SEARCH_PORT;
@@ -77,8 +78,7 @@ public class ProcessProperties {
SEARCH_HOST("sonar.search.host"),
SEARCH_PORT("sonar.search.port"),
- // FIXME default is 0 until we move out of usage of TransportClient and we can put the expected default: 9002
- SEARCH_TRANSPORT_PORT("sonar.search.transportPort", "0"),
+ ES_PORT("sonar.es.port"),
SEARCH_JAVA_OPTS("sonar.search.javaOpts", "-Xmx512m -Xms512m -XX:MaxDirectMemorySize=256m -XX:+HeapDumpOnOutOfMemoryError"),
SEARCH_JAVA_ADDITIONAL_OPTS("sonar.search.javaAdditionalOpts", ""),
SEARCH_REPLICAS("sonar.search.replicas"),
@@ -239,8 +239,7 @@ public class ProcessProperties {
props.setDefault(SEARCH_HOST.getKey(), InetAddress.getLoopbackAddress().getHostAddress());
props.setDefault(SEARCH_PORT.getKey(), "9001");
fixPortIfZero(props, Property.SEARCH_HOST.getKey(), SEARCH_PORT.getKey());
- // FIXME remove when transport is not used anymore in non-DCE editions: sonar.search.transportPort must not support port 0
- fixPortIfZero(props, Property.SEARCH_HOST.getKey(), Property.SEARCH_TRANSPORT_PORT.getKey());
+ fixEsTransportPortIfNull(props);
}
}
@@ -278,6 +277,15 @@ public class ProcessProperties {
}
}
+ private static void fixEsTransportPortIfNull(Props props) {
+ String port = props.value(ES_PORT.getKey());
+ if (port == null) {
+ int allocatedPort = NetworkUtilsImpl.INSTANCE.getNextAvailablePort(InetAddress.getLoopbackAddress().getHostAddress())
+ .orElseThrow(() -> new IllegalStateException("Cannot resolve address for Elasticsearch TCP transport port"));
+ props.set(ES_PORT.getKey(), String.valueOf(allocatedPort));
+ }
+ }
+
public static long parseTimeoutMs(Property property, String value) {
long l = Long.parseLong(value);
checkState(l >= 1, "value of %s must be >= 1", property);