aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-main
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2017-09-14 17:56:04 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-09-26 23:49:37 +0200
commit880336975d9957008ebb774043430049cdd3a3df (patch)
tree0e1af53ab2fadbd7183344cfdb3c67ffed6860c2 /server/sonar-main
parent87ce833df2754dc1a23d29e56571ba826978b7bd (diff)
downloadsonarqube-880336975d9957008ebb774043430049cdd3a3df.tar.gz
sonarqube-880336975d9957008ebb774043430049cdd3a3df.zip
SONAR-9803 remove bad coupling of processes on sonar-plugin-api
Diffstat (limited to 'server/sonar-main')
-rw-r--r--server/sonar-main/pom.xml13
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/AppLogging.java2
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/AppReloaderImpl.java2
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/AppStateImpl.java2
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java17
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppState.java2
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java8
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterProperties.java12
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/cluster/HazelcastCluster.java26
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/cluster/SearchNodeHealthProvider.java (renamed from server/sonar-main/src/main/java/org/sonar/application/health/SearchNodeHealthProvider.java)33
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java14
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java8
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/health/DelegateHealthStateRefresherExecutorService.java124
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/health/HealthStateSharing.java26
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/health/HealthStateSharingImpl.java88
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/health/package-info.java23
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java4
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/AppReloaderImplTest.java2
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/AppStateFactoryTest.java6
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java20
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/TestAppState.java2
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/TestClusterAppState.java2
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java6
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java12
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java18
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/cluster/HazelcastClusterTestHelper.java6
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/cluster/SearchNodeHealthProviderTest.java (renamed from server/sonar-main/src/test/java/org/sonar/application/health/SearchNodeHealthProviderTest.java)50
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsLoopbackTest.java10
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsTest.java8
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java6
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/health/DelegateHealthStateRefresherExecutorServiceTest.java153
31 files changed, 150 insertions, 555 deletions
diff --git a/server/sonar-main/pom.xml b/server/sonar-main/pom.xml
index 707e0fb6016..27e46c81cfb 100644
--- a/server/sonar-main/pom.xml
+++ b/server/sonar-main/pom.xml
@@ -52,6 +52,14 @@
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.hazelcast</groupId>
+ <artifactId>hazelcast-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.yaml</groupId>
+ <artifactId>snakeyaml</artifactId>
+ </dependency>
<!--
Required by our usage of Guava for clustering : CeWorkerFactoryImpl.getClusteredWorkerUUIDs()
-->
@@ -86,11 +94,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.hazelcast</groupId>
- <artifactId>hazelcast-client</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sonar-testing-harness</artifactId>
<scope>test</scope>
diff --git a/server/sonar-main/src/main/java/org/sonar/application/AppLogging.java b/server/sonar-main/src/main/java/org/sonar/application/AppLogging.java
index f35c78b0bf3..5636ff0a831 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/AppLogging.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/AppLogging.java
@@ -34,7 +34,7 @@ import org.sonar.process.logging.RootLoggerConfig;
import static org.slf4j.Logger.ROOT_LOGGER_NAME;
import static org.sonar.application.process.StreamGobbler.LOGGER_GOBBLER;
-import static org.sonar.cluster.ClusterProperties.HAZELCAST_LOG_LEVEL;
+import static org.sonar.process.cluster.ClusterProperties.HAZELCAST_LOG_LEVEL;
import static org.sonar.process.logging.RootLoggerConfig.newRootLoggerConfigBuilder;
/**
diff --git a/server/sonar-main/src/main/java/org/sonar/application/AppReloaderImpl.java b/server/sonar-main/src/main/java/org/sonar/application/AppReloaderImpl.java
index 06dbec1fe0f..59a40ab9a30 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/AppReloaderImpl.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/AppReloaderImpl.java
@@ -28,7 +28,7 @@ import org.sonar.process.MessageException;
import org.sonar.process.Props;
import static java.lang.String.format;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_ENABLED;
import static org.sonar.process.ProcessProperties.PATH_DATA;
import static org.sonar.process.ProcessProperties.PATH_LOGS;
import static org.sonar.process.ProcessProperties.PATH_TEMP;
diff --git a/server/sonar-main/src/main/java/org/sonar/application/AppStateImpl.java b/server/sonar-main/src/main/java/org/sonar/application/AppStateImpl.java
index 1e9d9cf3580..942abe0bc8a 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/AppStateImpl.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/AppStateImpl.java
@@ -26,7 +26,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nonnull;
-import org.sonar.NetworkUtils;
+import org.sonar.process.NetworkUtils;
import org.sonar.process.ProcessId;
public class AppStateImpl implements AppState {
diff --git a/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java b/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
index 0f9214e20b1..6aa1d8951a1 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/SchedulerImpl.java
@@ -28,24 +28,23 @@ import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Supplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.NetworkUtils;
-import org.sonar.api.utils.System2;
import org.sonar.application.cluster.ClusterAppState;
+import org.sonar.application.cluster.SearchNodeHealthProvider;
+import org.sonar.application.command.CommandFactory;
+import org.sonar.application.command.EsCommand;
+import org.sonar.application.command.JavaCommand;
import org.sonar.application.config.AppSettings;
import org.sonar.application.config.ClusterSettings;
-import org.sonar.application.health.HealthStateSharing;
-import org.sonar.application.health.HealthStateSharingImpl;
-import org.sonar.application.health.SearchNodeHealthProvider;
import org.sonar.application.process.Lifecycle;
import org.sonar.application.process.ProcessEventListener;
import org.sonar.application.process.ProcessLauncher;
import org.sonar.application.process.ProcessLifecycleListener;
import org.sonar.application.process.ProcessMonitor;
import org.sonar.application.process.SQProcess;
+import org.sonar.process.NetworkUtils;
import org.sonar.process.ProcessId;
-import org.sonar.application.command.CommandFactory;
-import org.sonar.application.command.EsCommand;
-import org.sonar.application.command.JavaCommand;
+import org.sonar.process.cluster.health.HealthStateSharing;
+import org.sonar.process.cluster.health.HealthStateSharingImpl;
public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLifecycleListener, AppStateListener {
@@ -152,7 +151,7 @@ public class SchedulerImpl implements Scheduler, ProcessEventListener, ProcessLi
ClusterAppState clusterAppState = (ClusterAppState) appState;
this.healthStateSharing = new HealthStateSharingImpl(
clusterAppState.getHazelcastClient(),
- new SearchNodeHealthProvider(settings.getProps(), System2.INSTANCE, clusterAppState, NetworkUtils.INSTANCE));
+ new SearchNodeHealthProvider(settings.getProps(), clusterAppState, NetworkUtils.INSTANCE));
this.healthStateSharing.start();
}
}
diff --git a/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppState.java b/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppState.java
index 044fcb99fd4..b7ac1511610 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppState.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppState.java
@@ -20,7 +20,7 @@
package org.sonar.application.cluster;
import org.sonar.application.AppState;
-import org.sonar.cluster.localclient.HazelcastClient;
+import org.sonar.process.cluster.HazelcastClient;
public interface ClusterAppState extends AppState {
HazelcastClient getHazelcastClient();
diff --git a/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java b/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java
index 9742941f132..3363538f349 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java
@@ -29,12 +29,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.application.AppStateListener;
import org.sonar.application.config.AppSettings;
-import org.sonar.cluster.localclient.HazelcastClient;
import org.sonar.process.ProcessId;
+import org.sonar.process.cluster.HazelcastClient;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_LOCALENDPOINT;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_MEMBERUUID;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_LOCALENDPOINT;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_MEMBERUUID;
public class ClusterAppStateImpl implements ClusterAppState {
private static Logger LOGGER = LoggerFactory.getLogger(ClusterAppStateImpl.class);
diff --git a/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterProperties.java b/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterProperties.java
index 4f7dc00e876..1845f30ee58 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterProperties.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterProperties.java
@@ -31,13 +31,13 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.application.config.AppSettings;
-import org.sonar.cluster.NodeType;
+import org.sonar.process.cluster.NodeType;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_HOSTS;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_HOST;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_NAME;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_PORT;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_HOSTS;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_HOST;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_NAME;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_PORT;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
/**
* Properties of the cluster configuration
diff --git a/server/sonar-main/src/main/java/org/sonar/application/cluster/HazelcastCluster.java b/server/sonar-main/src/main/java/org/sonar/application/cluster/HazelcastCluster.java
index 6625cd2e926..38f0eb6d007 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/cluster/HazelcastCluster.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/cluster/HazelcastCluster.java
@@ -48,26 +48,26 @@ import java.util.Set;
import java.util.concurrent.locks.Lock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.sonar.NetworkUtils;
import org.sonar.application.AppStateListener;
-import org.sonar.cluster.ClusterObjectKeys;
-import org.sonar.cluster.localclient.HazelcastClient;
import org.sonar.process.MessageException;
-import org.sonar.cluster.NodeType;
+import org.sonar.process.NetworkUtils;
import org.sonar.process.ProcessId;
+import org.sonar.process.cluster.NodeType;
+import org.sonar.process.cluster.ClusterObjectKeys;
+import org.sonar.process.cluster.HazelcastClient;
import static java.lang.String.format;
import static java.util.stream.Collectors.toList;
import static org.sonar.application.cluster.ClusterProperties.HAZELCAST_CLUSTER_NAME;
-import static org.sonar.cluster.ClusterObjectKeys.CLUSTER_NAME;
-import static org.sonar.cluster.ClusterObjectKeys.HOSTNAME;
-import static org.sonar.cluster.ClusterObjectKeys.IP_ADDRESSES;
-import static org.sonar.cluster.ClusterObjectKeys.LEADER;
-import static org.sonar.cluster.ClusterObjectKeys.LOCAL_MEMBER_UUIDS;
-import static org.sonar.cluster.ClusterObjectKeys.NODE_NAME;
-import static org.sonar.cluster.ClusterObjectKeys.NODE_TYPE;
-import static org.sonar.cluster.ClusterObjectKeys.OPERATIONAL_PROCESSES;
-import static org.sonar.cluster.ClusterObjectKeys.SONARQUBE_VERSION;
+import static org.sonar.process.cluster.ClusterObjectKeys.CLUSTER_NAME;
+import static org.sonar.process.cluster.ClusterObjectKeys.HOSTNAME;
+import static org.sonar.process.cluster.ClusterObjectKeys.IP_ADDRESSES;
+import static org.sonar.process.cluster.ClusterObjectKeys.LEADER;
+import static org.sonar.process.cluster.ClusterObjectKeys.LOCAL_MEMBER_UUIDS;
+import static org.sonar.process.cluster.ClusterObjectKeys.NODE_NAME;
+import static org.sonar.process.cluster.ClusterObjectKeys.NODE_TYPE;
+import static org.sonar.process.cluster.ClusterObjectKeys.OPERATIONAL_PROCESSES;
+import static org.sonar.process.cluster.ClusterObjectKeys.SONARQUBE_VERSION;
public class HazelcastCluster implements AutoCloseable {
private static final Logger LOGGER = LoggerFactory.getLogger(HazelcastCluster.class);
diff --git a/server/sonar-main/src/main/java/org/sonar/application/health/SearchNodeHealthProvider.java b/server/sonar-main/src/main/java/org/sonar/application/cluster/SearchNodeHealthProvider.java
index b1f650602fc..ff2461fcc78 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/health/SearchNodeHealthProvider.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/cluster/SearchNodeHealthProvider.java
@@ -17,33 +17,36 @@
* 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.application.health;
+package org.sonar.application.cluster;
-import org.sonar.NetworkUtils;
-import org.sonar.api.utils.System2;
-import org.sonar.application.cluster.ClusterAppState;
-import org.sonar.cluster.health.NodeDetails;
-import org.sonar.cluster.health.NodeHealth;
-import org.sonar.cluster.health.NodeHealthProvider;
+import org.sonar.process.NetworkUtils;
import org.sonar.process.ProcessId;
import org.sonar.process.Props;
+import org.sonar.process.cluster.health.NodeDetails;
+import org.sonar.process.cluster.health.NodeHealth;
+import org.sonar.process.cluster.health.NodeHealthProvider;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_HOST;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_NAME;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_PORT;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_HOST;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_NAME;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_PORT;
public class SearchNodeHealthProvider implements NodeHealthProvider {
+
private final ClusterAppState clusterAppState;
private final NodeDetails nodeDetails;
- public SearchNodeHealthProvider(Props props, System2 system2, ClusterAppState clusterAppState, NetworkUtils networkUtils) {
+ public SearchNodeHealthProvider(Props props, ClusterAppState clusterAppState, NetworkUtils networkUtils) {
+ this(props, clusterAppState, networkUtils, new Clock());
+ }
+
+ SearchNodeHealthProvider(Props props, ClusterAppState clusterAppState, NetworkUtils networkUtils, Clock clock) {
this.clusterAppState = clusterAppState;
this.nodeDetails = NodeDetails.newNodeDetailsBuilder()
.setType(NodeDetails.Type.SEARCH)
.setName(props.nonNullValue(CLUSTER_NODE_NAME))
.setHost(getHost(props, networkUtils))
.setPort(Integer.valueOf(props.nonNullValue(CLUSTER_NODE_PORT)))
- .setStartedAt(system2.now())
+ .setStartedAt(clock.now())
.build();
}
@@ -68,4 +71,10 @@ public class SearchNodeHealthProvider implements NodeHealthProvider {
.setDetails(nodeDetails)
.build();
}
+
+ static class Clock {
+ long now() {
+ return System.currentTimeMillis();
+ }
+ }
}
diff --git a/server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java b/server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java
index 3eb66a2d1b1..de30b62bc3b 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/config/ClusterSettings.java
@@ -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.cluster.NodeType;
+import org.sonar.process.cluster.NodeType;
import org.sonar.process.ProcessId;
import org.sonar.process.Props;
@@ -42,12 +42,12 @@ import static java.util.Arrays.stream;
import static java.util.Collections.singletonList;
import static java.util.stream.Collectors.joining;
import static org.apache.commons.lang.StringUtils.isBlank;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_HOSTS;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_HOST;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_SEARCH_HOSTS;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_WEB_LEADER;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_HOSTS;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_HOST;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_SEARCH_HOSTS;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_WEB_LEADER;
import static org.sonar.process.ProcessProperties.JDBC_URL;
import static org.sonar.process.ProcessProperties.SEARCH_HOST;
diff --git a/server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java b/server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java
index eb69acdbd61..1cd3187ad47 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/es/EsSettings.java
@@ -31,10 +31,10 @@ import org.sonar.process.Props;
import org.sonar.process.System2;
import static java.lang.String.valueOf;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NAME;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_NAME;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_SEARCH_HOSTS;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NAME;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_NAME;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_SEARCH_HOSTS;
public class EsSettings {
diff --git a/server/sonar-main/src/main/java/org/sonar/application/health/DelegateHealthStateRefresherExecutorService.java b/server/sonar-main/src/main/java/org/sonar/application/health/DelegateHealthStateRefresherExecutorService.java
deleted file mode 100644
index f47bce53a3b..00000000000
--- a/server/sonar-main/src/main/java/org/sonar/application/health/DelegateHealthStateRefresherExecutorService.java
+++ /dev/null
@@ -1,124 +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.application.health;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import org.sonar.cluster.health.HealthStateRefresherExecutorService;
-
-class DelegateHealthStateRefresherExecutorService implements HealthStateRefresherExecutorService {
- private final ScheduledExecutorService delegate;
-
- DelegateHealthStateRefresherExecutorService(ScheduledExecutorService delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit) {
- return delegate.schedule(command, delay, unit);
- }
-
- @Override
- public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) {
- return delegate.schedule(callable, delay, unit);
- }
-
- @Override
- public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
- return delegate.scheduleAtFixedRate(command, initialDelay, period, unit);
- }
-
- @Override
- public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit) {
- return delegate.scheduleWithFixedDelay(command, initialDelay, delay, unit);
- }
-
- @Override
- public void shutdown() {
- delegate.shutdown();
- }
-
- @Override
- public List<Runnable> shutdownNow() {
- return delegate.shutdownNow();
- }
-
- @Override
- public boolean isShutdown() {
- return delegate.isShutdown();
- }
-
- @Override
- public boolean isTerminated() {
- return delegate.isTerminated();
- }
-
- @Override
- public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException {
- return delegate.awaitTermination(timeout, unit);
- }
-
- @Override
- public <T> Future<T> submit(Callable<T> task) {
- return delegate.submit(task);
- }
-
- @Override
- public <T> Future<T> submit(Runnable task, T result) {
- return delegate.submit(task, result);
- }
-
- @Override
- public Future<?> submit(Runnable task) {
- return delegate.submit(task);
- }
-
- @Override
- public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks) throws InterruptedException {
- return delegate.invokeAll(tasks);
- }
-
- @Override
- public <T> List<Future<T>> invokeAll(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException {
- return delegate.invokeAll(tasks, timeout, unit);
- }
-
- @Override
- public <T> T invokeAny(Collection<? extends Callable<T>> tasks) throws InterruptedException, ExecutionException {
- return delegate.invokeAny(tasks);
- }
-
- @Override
- public <T> T invokeAny(Collection<? extends Callable<T>> tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
- return delegate.invokeAny(tasks, timeout, unit);
- }
-
- @Override
- public void execute(Runnable command) {
- delegate.execute(command);
- }
-}
diff --git a/server/sonar-main/src/main/java/org/sonar/application/health/HealthStateSharing.java b/server/sonar-main/src/main/java/org/sonar/application/health/HealthStateSharing.java
deleted file mode 100644
index 0297ea8beed..00000000000
--- a/server/sonar-main/src/main/java/org/sonar/application/health/HealthStateSharing.java
+++ /dev/null
@@ -1,26 +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.application.health;
-
-public interface HealthStateSharing {
- void start();
-
- void stop();
-}
diff --git a/server/sonar-main/src/main/java/org/sonar/application/health/HealthStateSharingImpl.java b/server/sonar-main/src/main/java/org/sonar/application/health/HealthStateSharingImpl.java
deleted file mode 100644
index 06a24f59da5..00000000000
--- a/server/sonar-main/src/main/java/org/sonar/application/health/HealthStateSharingImpl.java
+++ /dev/null
@@ -1,88 +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.application.health;
-
-import com.google.common.util.concurrent.ThreadFactoryBuilder;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import org.sonar.api.utils.log.Logger;
-import org.sonar.api.utils.log.Loggers;
-import org.sonar.cluster.health.HealthStateRefresher;
-import org.sonar.cluster.health.HealthStateRefresherExecutorService;
-import org.sonar.cluster.health.NodeHealthProvider;
-import org.sonar.cluster.health.SharedHealthStateImpl;
-import org.sonar.cluster.localclient.HazelcastClient;
-
-import static java.lang.String.format;
-
-public class HealthStateSharingImpl implements HealthStateSharing {
- private static final Logger LOG = Loggers.get(HealthStateSharingImpl.class);
-
- private final HazelcastClient hazelcastClient;
- private final NodeHealthProvider nodeHealthProvider;
- private HealthStateRefresherExecutorService executorService;
- private HealthStateRefresher healthStateRefresher;
-
- public HealthStateSharingImpl(HazelcastClient hazelcastClient, NodeHealthProvider nodeHealthProvider) {
- this.hazelcastClient = hazelcastClient;
- this.nodeHealthProvider = nodeHealthProvider;
- }
-
- @Override
- public void start() {
- executorService = new DelegateHealthStateRefresherExecutorService(
- Executors.newSingleThreadScheduledExecutor(
- new ThreadFactoryBuilder()
- .setDaemon(false)
- .setNameFormat("health_state_refresh-%d")
- .build()));
- healthStateRefresher = new HealthStateRefresher(executorService, nodeHealthProvider, new SharedHealthStateImpl(hazelcastClient));
- healthStateRefresher.start();
- }
-
- @Override
- public void stop() {
- healthStateRefresher.stop();
- stopExecutorService(executorService);
- }
-
- private static void stopExecutorService(ScheduledExecutorService executorService) {
- // Disable new tasks from being submitted
- executorService.shutdown();
- try {
- // Wait a while for existing tasks to terminate
- if (!executorService.awaitTermination(5, TimeUnit.SECONDS)) {
- // Cancel currently executing tasks
- executorService.shutdownNow();
- // Wait a while for tasks to respond to being canceled
- if (!executorService.awaitTermination(5, TimeUnit.SECONDS)) {
- LOG.warn(format("Pool %s did not terminate", HealthStateSharingImpl.class.getSimpleName()));
- }
- }
- } catch (InterruptedException ie) {
- LOG.warn(format("Termination of pool %s failed", HealthStateSharingImpl.class.getSimpleName()), ie);
- // (Re-)Cancel if current thread also interrupted
- executorService.shutdownNow();
- Thread.currentThread().interrupt();
- }
- }
-
-}
diff --git a/server/sonar-main/src/main/java/org/sonar/application/health/package-info.java b/server/sonar-main/src/main/java/org/sonar/application/health/package-info.java
deleted file mode 100644
index 57ff328fbb1..00000000000
--- a/server/sonar-main/src/main/java/org/sonar/application/health/package-info.java
+++ /dev/null
@@ -1,23 +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.
- */
-@ParametersAreNonnullByDefault
-package org.sonar.application.health;
-
-import javax.annotation.ParametersAreNonnullByDefault;
diff --git a/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java b/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java
index d993d930431..f67911a340a 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/AppLoggingTest.java
@@ -48,8 +48,8 @@ import org.sonar.process.logging.LogbackHelper;
import static org.assertj.core.api.Assertions.assertThat;
import static org.slf4j.Logger.ROOT_LOGGER_NAME;
import static org.sonar.application.process.StreamGobbler.LOGGER_GOBBLER;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
-import static org.sonar.cluster.ClusterProperties.HAZELCAST_LOG_LEVEL;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.HAZELCAST_LOG_LEVEL;
public class AppLoggingTest {
diff --git a/server/sonar-main/src/test/java/org/sonar/application/AppReloaderImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/AppReloaderImplTest.java
index c950788e599..0cc9db5b279 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/AppReloaderImplTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/AppReloaderImplTest.java
@@ -35,7 +35,7 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_ENABLED;
public class AppReloaderImplTest {
diff --git a/server/sonar-main/src/test/java/org/sonar/application/AppStateFactoryTest.java b/server/sonar-main/src/test/java/org/sonar/application/AppStateFactoryTest.java
index 10b9d0d6d3c..c4765df820e 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/AppStateFactoryTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/AppStateFactoryTest.java
@@ -24,9 +24,9 @@ import org.sonar.application.cluster.ClusterAppStateImpl;
import org.sonar.application.config.TestAppSettings;
import static org.assertj.core.api.Assertions.assertThat;
-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.process.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NAME;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
public class AppStateFactoryTest {
diff --git a/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java
index a2ada4bb3f8..a2fd049c44a 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/SchedulerImplTest.java
@@ -38,15 +38,15 @@ import org.junit.rules.TemporaryFolder;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.mockito.Mockito;
-import org.sonar.application.config.TestAppSettings;
-import org.sonar.application.process.ProcessLauncher;
-import org.sonar.application.process.ProcessMonitor;
-import org.sonar.cluster.localclient.HazelcastClient;
-import org.sonar.process.ProcessId;
import org.sonar.application.command.AbstractCommand;
import org.sonar.application.command.CommandFactory;
import org.sonar.application.command.EsCommand;
import org.sonar.application.command.JavaCommand;
+import org.sonar.application.config.TestAppSettings;
+import org.sonar.application.process.ProcessLauncher;
+import org.sonar.application.process.ProcessMonitor;
+import org.sonar.process.ProcessId;
+import org.sonar.process.cluster.HazelcastClient;
import static java.util.Collections.synchronizedList;
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
@@ -55,14 +55,14 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_HOST;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_NAME;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_PORT;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
import static org.sonar.process.ProcessId.COMPUTE_ENGINE;
import static org.sonar.process.ProcessId.ELASTICSEARCH;
import static org.sonar.process.ProcessId.WEB_SERVER;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_HOST;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_NAME;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_PORT;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
public class SchedulerImplTest {
diff --git a/server/sonar-main/src/test/java/org/sonar/application/TestAppState.java b/server/sonar-main/src/test/java/org/sonar/application/TestAppState.java
index 27f6c4d5fb0..ee6e3e9cfa1 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/TestAppState.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/TestAppState.java
@@ -26,7 +26,7 @@ import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nonnull;
-import org.sonar.NetworkUtils;
+import org.sonar.process.NetworkUtils;
import org.sonar.process.ProcessId;
public class TestAppState implements AppState {
diff --git a/server/sonar-main/src/test/java/org/sonar/application/TestClusterAppState.java b/server/sonar-main/src/test/java/org/sonar/application/TestClusterAppState.java
index 94d5e664f5c..322a42d3c06 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/TestClusterAppState.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/TestClusterAppState.java
@@ -20,7 +20,7 @@
package org.sonar.application;
import org.sonar.application.cluster.ClusterAppState;
-import org.sonar.cluster.localclient.HazelcastClient;
+import org.sonar.process.cluster.HazelcastClient;
public class TestClusterAppState extends TestAppState implements ClusterAppState {
private final HazelcastClient hazelcastClient;
diff --git a/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java b/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java
index 240db1cbfe0..3ad627e9aab 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java
@@ -42,9 +42,9 @@ import static org.mockito.Mockito.timeout;
import static org.mockito.Mockito.verify;
import static org.sonar.application.cluster.HazelcastClusterTestHelper.createHazelcastClient;
import static org.sonar.application.cluster.HazelcastClusterTestHelper.newApplicationSettings;
-import static org.sonar.cluster.ClusterObjectKeys.CLUSTER_NAME;
-import static org.sonar.cluster.ClusterObjectKeys.SONARQUBE_VERSION;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterObjectKeys.CLUSTER_NAME;
+import static org.sonar.process.cluster.ClusterObjectKeys.SONARQUBE_VERSION;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_ENABLED;
public class ClusterAppStateImplTest {
diff --git a/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java b/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java
index 1b8c4870f14..71c28d44abc 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterPropertiesTest.java
@@ -30,12 +30,12 @@ import org.sonar.application.config.AppSettings;
import org.sonar.application.config.TestAppSettings;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_HOSTS;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NAME;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_HOST;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_PORT;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_HOSTS;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NAME;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_HOST;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_PORT;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
public class ClusterPropertiesTest {
@Rule
diff --git a/server/sonar-main/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java b/server/sonar-main/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java
index 73dfb54f633..812e5cc7e52 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/cluster/HazelcastClusterTest.java
@@ -41,10 +41,10 @@ import org.junit.rules.ExpectedException;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
import org.slf4j.LoggerFactory;
-import org.sonar.NetworkUtils;
+import org.sonar.process.NetworkUtils;
import org.sonar.application.AppStateListener;
import org.sonar.application.config.TestAppSettings;
-import org.sonar.cluster.ClusterObjectKeys;
+import org.sonar.process.cluster.ClusterObjectKeys;
import org.sonar.process.ProcessId;
import static java.lang.String.format;
@@ -59,13 +59,13 @@ import static org.sonar.application.cluster.HazelcastClusterTestHelper.closeAllH
import static org.sonar.application.cluster.HazelcastClusterTestHelper.createHazelcastClient;
import static org.sonar.application.cluster.HazelcastClusterTestHelper.newApplicationSettings;
import static org.sonar.application.cluster.HazelcastClusterTestHelper.newSearchSettings;
-import static org.sonar.cluster.ClusterObjectKeys.LEADER;
-import static org.sonar.cluster.ClusterObjectKeys.OPERATIONAL_PROCESSES;
-import static org.sonar.cluster.ClusterObjectKeys.SONARQUBE_VERSION;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_HOSTS;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NAME;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_HOST;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_PORT;
+import static org.sonar.process.cluster.ClusterObjectKeys.LEADER;
+import static org.sonar.process.cluster.ClusterObjectKeys.OPERATIONAL_PROCESSES;
+import static org.sonar.process.cluster.ClusterObjectKeys.SONARQUBE_VERSION;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_HOSTS;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NAME;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_HOST;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_PORT;
public class HazelcastClusterTest {
@Rule
diff --git a/server/sonar-main/src/test/java/org/sonar/application/cluster/HazelcastClusterTestHelper.java b/server/sonar-main/src/test/java/org/sonar/application/cluster/HazelcastClusterTestHelper.java
index 0345c5bf672..c6980734b0c 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/cluster/HazelcastClusterTestHelper.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/cluster/HazelcastClusterTestHelper.java
@@ -28,9 +28,9 @@ import java.util.ArrayList;
import java.util.List;
import org.sonar.application.config.TestAppSettings;
-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.process.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NAME;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
public class HazelcastClusterTestHelper {
diff --git a/server/sonar-main/src/test/java/org/sonar/application/health/SearchNodeHealthProviderTest.java b/server/sonar-main/src/test/java/org/sonar/application/cluster/SearchNodeHealthProviderTest.java
index ce6fc6ec450..6b676366669 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/health/SearchNodeHealthProviderTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/cluster/SearchNodeHealthProviderTest.java
@@ -17,7 +17,7 @@
* 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.application.health;
+package org.sonar.application.cluster;
import java.util.Properties;
import java.util.Random;
@@ -25,29 +25,27 @@ import javax.annotation.Nullable;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
-import org.sonar.NetworkUtils;
-import org.sonar.api.utils.System2;
-import org.sonar.application.cluster.ClusterAppState;
-import org.sonar.cluster.ClusterProperties;
-import org.sonar.cluster.health.NodeHealth;
+import org.sonar.process.NetworkUtils;
import org.sonar.process.ProcessId;
import org.sonar.process.Props;
+import org.sonar.process.cluster.ClusterProperties;
+import org.sonar.process.cluster.health.NodeHealth;
import static java.lang.String.valueOf;
import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
-import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_HOST;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_NAME;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_PORT;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_HOST;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_NAME;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_PORT;
public class SearchNodeHealthProviderTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
private final Random random = new Random();
- private System2 system2 = mock(System2.class);
+ private SearchNodeHealthProvider.Clock clock = mock(SearchNodeHealthProvider.Clock.class);
private NetworkUtils networkUtils = mock(NetworkUtils.class);
private ClusterAppState clusterAppState = mock(ClusterAppState.class);
@@ -58,7 +56,7 @@ public class SearchNodeHealthProviderTest {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Missing property: sonar.cluster.node.name");
- new SearchNodeHealthProvider(props, system2, clusterAppState, networkUtils);
+ new SearchNodeHealthProvider(props, clusterAppState, networkUtils);
}
@Test
@@ -69,7 +67,7 @@ public class SearchNodeHealthProviderTest {
expectedException.expect(NullPointerException.class);
- new SearchNodeHealthProvider(props, system2, clusterAppState, networkUtils);
+ new SearchNodeHealthProvider(props, clusterAppState, networkUtils, clock);
}
@Test
@@ -82,7 +80,7 @@ public class SearchNodeHealthProviderTest {
expectedException.expect(IllegalArgumentException.class);
expectedException.expectMessage("Missing property: sonar.cluster.node.port");
- new SearchNodeHealthProvider(props, system2, clusterAppState, networkUtils);
+ new SearchNodeHealthProvider(props, clusterAppState, networkUtils, clock);
}
@Test
@@ -97,7 +95,7 @@ public class SearchNodeHealthProviderTest {
expectedException.expect(NumberFormatException.class);
expectedException.expectMessage("For input string: \"" + port + "\"");
- new SearchNodeHealthProvider(props, system2, clusterAppState, networkUtils);
+ new SearchNodeHealthProvider(props, clusterAppState, networkUtils, clock);
}
@Test
@@ -108,8 +106,8 @@ public class SearchNodeHealthProviderTest {
properties.setProperty(CLUSTER_NODE_NAME, name);
properties.setProperty(CLUSTER_NODE_PORT, valueOf(port));
when(networkUtils.getHostname()).thenReturn(randomAlphanumeric(34));
- when(system2.now()).thenReturn(1L + random.nextInt(87));
- SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), system2, clusterAppState, networkUtils);
+ when(clock.now()).thenReturn(1L + random.nextInt(87));
+ SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), clusterAppState, networkUtils, clock);
NodeHealth nodeHealth = underTest.get();
@@ -133,8 +131,8 @@ public class SearchNodeHealthProviderTest {
properties.setProperty(CLUSTER_NODE_NAME, randomAlphanumeric(3));
properties.setProperty(CLUSTER_NODE_PORT, valueOf(1 + random.nextInt(4)));
properties.setProperty(CLUSTER_NODE_HOST, host);
- when(system2.now()).thenReturn(1L + random.nextInt(87));
- SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), system2, clusterAppState, networkUtils);
+ when(clock.now()).thenReturn(1L + random.nextInt(87));
+ SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), clusterAppState, networkUtils, clock);
NodeHealth nodeHealth = underTest.get();
@@ -166,9 +164,9 @@ public class SearchNodeHealthProviderTest {
if (hostPropertyValue != null) {
properties.setProperty(CLUSTER_NODE_HOST, hostPropertyValue);
}
- when(system2.now()).thenReturn(1L + random.nextInt(87));
+ when(clock.now()).thenReturn(1L + random.nextInt(87));
when(networkUtils.getHostname()).thenReturn(host);
- SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), system2, clusterAppState, networkUtils);
+ SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), clusterAppState, networkUtils, clock);
NodeHealth nodeHealth = underTest.get();
@@ -186,14 +184,14 @@ public class SearchNodeHealthProviderTest {
public void get_returns_started_from_System2_now_at_constructor_time() {
Properties properties = new Properties();
long now = setRequiredPropertiesAndMocks(properties);
- SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), system2, clusterAppState, networkUtils);
+ SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), clusterAppState, networkUtils, clock);
NodeHealth nodeHealth = underTest.get();
assertThat(nodeHealth.getDetails().getStartedAt()).isEqualTo(now);
// change now
- when(system2.now()).thenReturn(now);
+ when(clock.now()).thenReturn(now);
NodeHealth newNodeHealth = underTest.get();
@@ -205,7 +203,7 @@ public class SearchNodeHealthProviderTest {
Properties properties = new Properties();
setRequiredPropertiesAndMocks(properties);
when(clusterAppState.isOperational(ProcessId.ELASTICSEARCH, true)).thenReturn(true);
- SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), system2, clusterAppState, networkUtils);
+ SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), clusterAppState, networkUtils, clock);
NodeHealth nodeHealth = underTest.get();
@@ -217,7 +215,7 @@ public class SearchNodeHealthProviderTest {
Properties properties = new Properties();
setRequiredPropertiesAndMocks(properties);
when(clusterAppState.isOperational(ProcessId.ELASTICSEARCH, true)).thenReturn(false);
- SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), system2, clusterAppState, networkUtils);
+ SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), clusterAppState, networkUtils, clock);
NodeHealth nodeHealth = underTest.get();
@@ -229,7 +227,7 @@ public class SearchNodeHealthProviderTest {
properties.setProperty(CLUSTER_NODE_NAME, randomAlphanumeric(3));
properties.setProperty(CLUSTER_NODE_PORT, valueOf(1 + random.nextInt(4)));
long now = 1L + random.nextInt(87);
- when(system2.now()).thenReturn(now);
+ when(clock.now()).thenReturn(now);
when(networkUtils.getHostname()).thenReturn(randomAlphanumeric(34));
return now;
}
diff --git a/server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsLoopbackTest.java b/server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsLoopbackTest.java
index be22b4f8bf2..43c359f8262 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsLoopbackTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsLoopbackTest.java
@@ -34,11 +34,11 @@ import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.sonar.process.MessageException;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_HOSTS;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_HOST;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_SEARCH_HOSTS;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_HOSTS;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_HOST;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_SEARCH_HOSTS;
import static org.sonar.process.ProcessProperties.JDBC_URL;
import static org.sonar.process.ProcessProperties.SEARCH_HOST;
diff --git a/server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsTest.java b/server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsTest.java
index dc35de91b52..e52273b0761 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsTest.java
@@ -32,10 +32,10 @@ import org.sonar.process.MessageException;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_HOSTS;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_SEARCH_HOSTS;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_ENABLED;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_HOSTS;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NODE_TYPE;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_SEARCH_HOSTS;
import static org.sonar.process.ProcessId.COMPUTE_ENGINE;
import static org.sonar.process.ProcessId.ELASTICSEARCH;
import static org.sonar.process.ProcessId.WEB_SERVER;
diff --git a/server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java b/server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java
index 1a09f0ac240..9e823170c78 100644
--- a/server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java
+++ b/server/sonar-main/src/test/java/org/sonar/application/es/EsSettingsTest.java
@@ -31,7 +31,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.rules.TemporaryFolder;
import org.sonar.application.logging.ListAppender;
-import org.sonar.cluster.ClusterProperties;
+import org.sonar.process.cluster.ClusterProperties;
import org.sonar.process.ProcessProperties;
import org.sonar.process.Props;
import org.sonar.process.System2;
@@ -40,8 +40,8 @@ import static org.apache.commons.lang.RandomStringUtils.randomAlphanumeric;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_NAME;
-import static org.sonar.cluster.ClusterProperties.CLUSTER_SEARCH_HOSTS;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_NAME;
+import static org.sonar.process.cluster.ClusterProperties.CLUSTER_SEARCH_HOSTS;
public class EsSettingsTest {
diff --git a/server/sonar-main/src/test/java/org/sonar/application/health/DelegateHealthStateRefresherExecutorServiceTest.java b/server/sonar-main/src/test/java/org/sonar/application/health/DelegateHealthStateRefresherExecutorServiceTest.java
deleted file mode 100644
index 1b3dec9a0db..00000000000
--- a/server/sonar-main/src/test/java/org/sonar/application/health/DelegateHealthStateRefresherExecutorServiceTest.java
+++ /dev/null
@@ -1,153 +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.application.health;
-
-import java.util.Collection;
-import java.util.Random;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-import org.junit.Test;
-
-import static java.util.concurrent.TimeUnit.SECONDS;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-
-public class DelegateHealthStateRefresherExecutorServiceTest {
- private Random random = new Random();
- private Runnable runnable = mock(Runnable.class);
- private Callable callable = mock(Callable.class);
- private Collection<Callable<Object>> callables = IntStream.range(0, random.nextInt(5))
- .mapToObj(i -> (Callable<Object>) mock(Callable.class))
- .collect(Collectors.toList());
- private int initialDelay = random.nextInt(333);
- private int delay = random.nextInt(333);
- private int period = random.nextInt(333);
- private int timeout = random.nextInt(333);
- private Object result = new Object();
- private ScheduledExecutorService executorService = mock(ScheduledExecutorService.class);
- private DelegateHealthStateRefresherExecutorService underTest = new DelegateHealthStateRefresherExecutorService(executorService);
-
- @Test
- public void schedule() {
- underTest.schedule(runnable, delay, SECONDS);
-
- verify(executorService).schedule(runnable, delay, SECONDS);
- }
-
- @Test
- public void schedule1() {
- underTest.schedule(callable, delay, SECONDS);
-
- verify(executorService).schedule(callable, delay, SECONDS);
- }
-
- @Test
- public void scheduleAtFixedRate() {
- underTest.scheduleAtFixedRate(runnable, initialDelay, period, SECONDS);
- verify(executorService).scheduleAtFixedRate(runnable, initialDelay, period, SECONDS);
- }
-
- @Test
- public void scheduleWithFixeddelay() {
- underTest.scheduleWithFixedDelay(runnable, initialDelay, delay, TimeUnit.SECONDS);
- verify(executorService).scheduleWithFixedDelay(runnable, initialDelay, delay, TimeUnit.SECONDS);
- }
-
- @Test
- public void shutdown() {
- underTest.shutdown();
- verify(executorService).shutdown();
- }
-
- @Test
- public void shutdownNow() {
- underTest.shutdownNow();
- verify(executorService).shutdownNow();
- }
-
- @Test
- public void isShutdown() {
- underTest.isShutdown();
- verify(executorService).isShutdown();
- }
-
- @Test
- public void isTerminated() {
- underTest.isTerminated();
- verify(executorService).isTerminated();
- }
-
- @Test
- public void awaitTermination() throws InterruptedException {
- underTest.awaitTermination(timeout, TimeUnit.SECONDS);
-
- verify(executorService).awaitTermination(timeout, TimeUnit.SECONDS);
- }
-
- @Test
- public void submit() {
- underTest.submit(callable);
-
- verify(executorService).submit(callable);
- }
-
- @Test
- public void submit1() {
- underTest.submit(runnable, result);
-
- verify(executorService).submit(runnable, result);
- }
-
- @Test
- public void submit2() {
- underTest.submit(runnable);
- verify(executorService).submit(runnable);
- }
-
- @Test
- public void invokeAll() throws InterruptedException {
- underTest.invokeAll(callables);
- verify(executorService).invokeAll(callables);
- }
-
- @Test
- public void invokeAll1() throws InterruptedException {
- underTest.invokeAll(callables, timeout, SECONDS);
- verify(executorService).invokeAll(callables, timeout, SECONDS);
- }
-
- @Test
- public void invokeAny() throws InterruptedException, ExecutionException {
- underTest.invokeAny(callables);
- verify(executorService).invokeAny(callables);
- }
-
- @Test
- public void invokeAny2() throws InterruptedException, ExecutionException, TimeoutException {
- underTest.invokeAny(callables, timeout, SECONDS);
- verify(executorService).invokeAny(callables, timeout, SECONDS);
- }
-
-}