aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorDaniel Schwarz <daniel.schwarz@sonarsource.com>2017-09-21 09:53:43 +0200
committerSimon Brandhof <simon.brandhof@sonarsource.com>2017-09-26 23:49:38 +0200
commit0d049321178a98f46a1739f1c2817098064f1475 (patch)
treee9a6283fd41eae24ccd65d2a660281c8c6ac4e99 /server
parent231d183396ca7187b2b45c50927aa8a3bc8dac56 (diff)
downloadsonarqube-0d049321178a98f46a1739f1c2817098064f1475.tar.gz
sonarqube-0d049321178a98f46a1739f1c2817098064f1475.zip
SONAR-9802 Fix quality flaws
Diffstat (limited to 'server')
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java6
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java6
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/AppStateImpl.java4
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java11
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/config/AppSettingsLoaderImpl.java4
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/AppStateFactoryTest.java4
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/TestAppState.java4
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/cluster/ClusterAppStateImplTest.java4
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsLoopbackTest.java3
-rw-r--r--server/sonar-main/src/test/java/org/sonar/application/config/ClusterSettingsTest.java3
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/NetworkUtils.java1
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/NetworkUtilsImpl.java1
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/ProcessProperties.java2
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/cluster/hz/DistributedAnswer.java6
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java22
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java12
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberSelectors.java3
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastObjects.java3
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/cluster/hz/DistributedAnswerTest.java3
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberBuilderTest.java4
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java8
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberSelectorsTest.java12
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/ServerLogging.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/OfficialDistribution.java10
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/cluster/AppNodesInfoLoaderImpl.java7
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/cluster/ProcessInfoProvider.java8
-rw-r--r--server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/app/EmbeddedTomcatTest.java4
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/cluster/StartableHazelcastMemberTest.java3
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java8
-rw-r--r--server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/OfficialDistributionTest.java10
31 files changed, 104 insertions, 84 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
index b62dca5b430..c5e45edfa25 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java
@@ -73,7 +73,7 @@ import org.sonar.db.DatabaseChecker;
import org.sonar.db.DbClient;
import org.sonar.db.DefaultDatabase;
import org.sonar.db.purge.PurgeProfiler;
-import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessProperties;
import org.sonar.process.Props;
import org.sonar.process.logging.LogbackHelper;
@@ -127,8 +127,8 @@ import org.sonar.server.platform.WebServerImpl;
import org.sonar.server.platform.db.migration.MigrationConfigurationModule;
import org.sonar.server.platform.db.migration.version.DatabaseVersion;
import org.sonar.server.platform.monitoring.DatabaseSection;
-import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider;
import org.sonar.server.platform.monitoring.cluster.LoggingSection;
+import org.sonar.server.platform.monitoring.cluster.ProcessInfoProvider;
import org.sonar.server.plugins.InstalledPluginReferentialFactory;
import org.sonar.server.plugins.ServerExtensionInstaller;
import org.sonar.server.plugins.privileged.PrivilegedPluginsBootstraper;
@@ -238,7 +238,7 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
SonarRuntimeImpl.forSonarQube(ApiVersion.load(System2.INSTANCE), SonarQubeSide.COMPUTE_ENGINE),
CeProcessLogging.class,
UuidFactoryImpl.INSTANCE,
- NetworkUtils.INSTANCE,
+ NetworkUtilsImpl.INSTANCE,
WebServerImpl.class,
LogbackHelper.class,
DefaultDatabase.class,
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
index 4cf1cac4434..c10b6f94c6d 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java
@@ -42,7 +42,7 @@ import org.sonar.ce.CeDistributedInformationImpl;
import org.sonar.ce.StandaloneCeDistributedInformation;
import org.sonar.db.DbTester;
import org.sonar.db.property.PropertyDto;
-import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
import org.sonar.process.ProcessProperties;
import org.sonar.process.Props;
@@ -87,7 +87,7 @@ public class ComputeEngineContainerImplTest {
@Test
public void real_start_with_cluster() throws IOException {
- Optional<InetAddress> localhost = NetworkUtils.INSTANCE.getLocalNonLoopbackIpv4Address();
+ Optional<InetAddress> localhost = NetworkUtilsImpl.INSTANCE.getLocalNonLoopbackIpv4Address();
// test is ignored if offline
assumeThat(localhost.isPresent(), CoreMatchers.is(true));
@@ -96,7 +96,7 @@ public class ComputeEngineContainerImplTest {
properties.setProperty(CLUSTER_ENABLED, "true");
properties.setProperty(CLUSTER_NODE_TYPE, "application");
properties.setProperty(CLUSTER_NODE_HOST, localhost.get().getHostAddress());
- properties.setProperty(CLUSTER_NODE_PORT, "" + NetworkUtils.INSTANCE.getNextAvailablePort(localhost.get()));
+ properties.setProperty(CLUSTER_NODE_PORT, "" + NetworkUtilsImpl.INSTANCE.getNextAvailablePort(localhost.get()));
// required persisted properties
insertProperty(CoreProperties.SERVER_ID, "a_startup_id");
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 942abe0bc8a..d1f3936a6da 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.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
public class AppStateImpl implements AppState {
@@ -74,7 +74,7 @@ public class AppStateImpl implements AppState {
@Override
public Optional<String> getLeaderHostName() {
- return Optional.of(NetworkUtils.INSTANCE.getHostname());
+ return Optional.of(NetworkUtilsImpl.INSTANCE.getHostname());
}
@Override
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 3c23a5501eb..2876b2eccbc 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
@@ -45,12 +45,15 @@ import org.sonar.application.cluster.health.SearchNodeHealthProvider;
import org.sonar.application.config.AppSettings;
import org.sonar.application.config.ClusterSettings;
import org.sonar.process.MessageException;
-import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
import org.sonar.process.cluster.NodeType;
import org.sonar.process.cluster.hz.HazelcastMember;
import static java.lang.String.format;
+import static org.sonar.process.cluster.hz.HazelcastMember.Attribute.HOSTNAME;
+import static org.sonar.process.cluster.hz.HazelcastMember.Attribute.IP_ADDRESSES;
+import static org.sonar.process.cluster.hz.HazelcastMember.Attribute.NODE_TYPE;
import static org.sonar.process.cluster.hz.HazelcastObjects.CLUSTER_NAME;
import static org.sonar.process.cluster.hz.HazelcastObjects.LEADER;
import static org.sonar.process.cluster.hz.HazelcastObjects.OPERATIONAL_PROCESSES;
@@ -77,7 +80,7 @@ public class ClusterAppStateImpl implements ClusterAppState {
nodeDisconnectedListenerUUID = hzMember.getCluster().addMembershipListener(new NodeDisconnectedListener());
if (ClusterSettings.isLocalElasticsearchEnabled(settings)) {
- this.healthStateSharing = new HealthStateSharingImpl(hzMember, new SearchNodeHealthProvider(settings.getProps(), this, NetworkUtils.INSTANCE));
+ this.healthStateSharing = new HealthStateSharingImpl(hzMember, new SearchNodeHealthProvider(settings.getProps(), this, NetworkUtilsImpl.INSTANCE));
this.healthStateSharing.start();
}
}
@@ -187,7 +190,7 @@ public class ClusterAppStateImpl implements ClusterAppState {
Optional<Member> leader = hzMember.getCluster().getMembers().stream().filter(m -> m.getUuid().equals(leaderId)).findFirst();
if (leader.isPresent()) {
return Optional.of(
- format("%s (%s)", leader.get().getStringAttribute(HazelcastMember.Attribute.HOSTNAME), leader.get().getStringAttribute(HazelcastMember.Attribute.IP_ADDRESSES)));
+ format("%s (%s)", leader.get().getStringAttribute(HOSTNAME.getKey()), leader.get().getStringAttribute(IP_ADDRESSES.getKey())));
}
}
return Optional.empty();
@@ -278,7 +281,7 @@ public class ClusterAppStateImpl implements ClusterAppState {
}
private boolean isAppNode(Member member) {
- return NodeType.APPLICATION.getValue().equals(member.getStringAttribute(HazelcastMember.Attribute.NODE_TYPE));
+ return NodeType.APPLICATION.getValue().equals(member.getStringAttribute(NODE_TYPE.getKey()));
}
private void removeOperationalProcess(String uuid) {
diff --git a/server/sonar-main/src/main/java/org/sonar/application/config/AppSettingsLoaderImpl.java b/server/sonar-main/src/main/java/org/sonar/application/config/AppSettingsLoaderImpl.java
index 801e61410ac..006c512b7bc 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/config/AppSettingsLoaderImpl.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/config/AppSettingsLoaderImpl.java
@@ -30,7 +30,7 @@ import java.util.Properties;
import java.util.function.Consumer;
import org.slf4j.LoggerFactory;
import org.sonar.process.ConfigurationUtils;
-import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessProperties;
import org.sonar.process.Props;
@@ -44,7 +44,7 @@ public class AppSettingsLoaderImpl implements AppSettingsLoader {
public AppSettingsLoaderImpl(String[] cliArguments) {
this(cliArguments, detectHomeDir(),
- new FileSystemSettings(), new JdbcSettings(), new ClusterSettings(NetworkUtils.INSTANCE));
+ new FileSystemSettings(), new JdbcSettings(), new ClusterSettings(NetworkUtilsImpl.INSTANCE));
}
AppSettingsLoaderImpl(String[] cliArguments, File homeDir, Consumer<Props>... consumers) {
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 8919ed84c75..86080ff87da 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
@@ -25,7 +25,7 @@ import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.sonar.application.cluster.ClusterAppStateImpl;
import org.sonar.application.config.TestAppSettings;
-import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assume.assumeThat;
@@ -42,7 +42,7 @@ public class AppStateFactoryTest {
@Test
public void create_cluster_implementation_if_cluster_is_enabled() {
- Optional<InetAddress> ip = NetworkUtils.INSTANCE.getLocalNonLoopbackIpv4Address();
+ Optional<InetAddress> ip = NetworkUtilsImpl.INSTANCE.getLocalNonLoopbackIpv4Address();
assumeThat(ip.isPresent(), CoreMatchers.is(true));
settings.set(CLUSTER_ENABLED, "true");
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 ee6e3e9cfa1..b0b94642619 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.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
public class TestAppState implements AppState {
@@ -84,7 +84,7 @@ public class TestAppState implements AppState {
@Override
public Optional<String> getLeaderHostName() {
- return Optional.of(NetworkUtils.INSTANCE.getHostname());
+ return Optional.of(NetworkUtilsImpl.INSTANCE.getHostname());
}
@Override
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 bf93a7b88c5..ba85353df39 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
@@ -29,7 +29,7 @@ import org.junit.rules.Timeout;
import org.sonar.application.AppStateListener;
import org.sonar.application.config.TestAppSettings;
import org.sonar.process.MessageException;
-import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
import org.sonar.process.cluster.NodeType;
import org.sonar.process.cluster.hz.HazelcastMember;
@@ -143,7 +143,7 @@ public class ClusterAppStateImplTest {
.setProcessId(ProcessId.COMPUTE_ENGINE)
.setClusterName("foo")
.setNodeName("bar")
- .setPort(NetworkUtils.INSTANCE.getNextAvailablePort(loopback))
+ .setPort(NetworkUtilsImpl.INSTANCE.getNextAvailablePort(loopback))
.setNetworkInterface(loopback.getHostAddress())
.build();
}
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 245b935d5a8..4895083944c 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
@@ -30,6 +30,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.process.MessageException;
import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessProperties;
import static org.junit.Assume.assumeThat;
@@ -49,7 +50,7 @@ public class ClusterSettingsLoopbackTest {
private InetAddress loopback = InetAddress.getLoopbackAddress();
private InetAddress nonLoopbackLocal;
- private NetworkUtils network = spy(NetworkUtils.INSTANCE);
+ private NetworkUtils network = spy(NetworkUtilsImpl.INSTANCE);
@Before
public void setUp() throws Exception {
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 f3f528da701..c7088c507ec 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
@@ -27,6 +27,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.process.MessageException;
import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
@@ -49,7 +50,7 @@ public class ClusterSettingsTest {
public ExpectedException expectedException = ExpectedException.none();
private InetAddress nonLoopbackLocal = InetAddress.getLoopbackAddress();
- private NetworkUtils network = spy(NetworkUtils.INSTANCE);
+ private NetworkUtils network = spy(NetworkUtilsImpl.INSTANCE);
@Before
public void setUp() throws Exception {
diff --git a/server/sonar-process/src/main/java/org/sonar/process/NetworkUtils.java b/server/sonar-process/src/main/java/org/sonar/process/NetworkUtils.java
index 7d4fc4d51f3..234b930d241 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/NetworkUtils.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/NetworkUtils.java
@@ -27,7 +27,6 @@ import java.util.Optional;
import java.util.function.Predicate;
public interface NetworkUtils {
- NetworkUtils INSTANCE = new NetworkUtilsImpl();
int getNextAvailablePort(InetAddress address);
diff --git a/server/sonar-process/src/main/java/org/sonar/process/NetworkUtilsImpl.java b/server/sonar-process/src/main/java/org/sonar/process/NetworkUtilsImpl.java
index 9da928a7c9d..3f7d6892f35 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/NetworkUtilsImpl.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/NetworkUtilsImpl.java
@@ -40,6 +40,7 @@ import static org.apache.commons.lang.StringUtils.isBlank;
public class NetworkUtilsImpl implements NetworkUtils {
+ public static final NetworkUtils INSTANCE = new NetworkUtilsImpl();
private static final Set<Integer> PORTS_ALREADY_ALLOCATED = new HashSet<>();
private static final int PORT_MAX_TRIES = 50;
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 5d90670108a..012474d50d7 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
@@ -135,7 +135,7 @@ public class ProcessProperties {
if ("0".equals(port)) {
String address = props.nonNullValue(addressPropertyKey);
try {
- props.set(portPropertyKey, String.valueOf(NetworkUtils.INSTANCE.getNextAvailablePort(InetAddress.getByName(address))));
+ props.set(portPropertyKey, String.valueOf(NetworkUtilsImpl.INSTANCE.getNextAvailablePort(InetAddress.getByName(address))));
} catch (UnknownHostException e) {
throw new IllegalStateException("Cannot resolve address [" + address + "] set by property [" + addressPropertyKey + "]", e);
}
diff --git a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/DistributedAnswer.java b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/DistributedAnswer.java
index f5a0bc920c8..526b17ee183 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/DistributedAnswer.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/DistributedAnswer.java
@@ -30,6 +30,8 @@ import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
+import static org.sonar.process.cluster.hz.HazelcastMember.Attribute.NODE_NAME;
+
/**
* Answer of {@link DistributedCall}, aggregating the answers from
* all the target members.
@@ -75,7 +77,7 @@ public class DistributedAnswer<T> {
public void propagateExceptions() {
if (!failedMembers.isEmpty()) {
String failedMemberNames = failedMembers.keySet().stream()
- .map(m -> m.getStringAttribute(HazelcastMember.Attribute.NODE_NAME))
+ .map(m -> m.getStringAttribute(NODE_NAME.getKey()))
.collect(Collectors.joining(", "));
throw new IllegalStateException("Distributed cluster action in cluster nodes " + failedMemberNames + " (other nodes may have timed out)",
failedMembers.values().iterator().next());
@@ -83,7 +85,7 @@ public class DistributedAnswer<T> {
if (!timedOutMembers.isEmpty()) {
String timedOutMemberNames = timedOutMembers.stream()
- .map(m -> m.getStringAttribute(HazelcastMember.Attribute.NODE_NAME))
+ .map(m -> m.getStringAttribute(NODE_NAME.getKey()))
.collect(Collectors.joining(", "));
throw new IllegalStateException("Distributed cluster action timed out in cluster nodes " + timedOutMemberNames);
}
diff --git a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java
index 0a70741d020..d2e081d4443 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java
@@ -31,28 +31,38 @@ import org.sonar.process.cluster.NodeType;
public interface HazelcastMember extends AutoCloseable {
- interface Attribute {
+ enum Attribute {
/**
* The key of the hostname attribute of a member
*/
- String HOSTNAME = "HOSTNAME";
+ HOSTNAME("HOSTNAME"),
/**
* The key of the ips list attribute of a member
*/
- String IP_ADDRESSES = "IP_ADDRESSES";
+ IP_ADDRESSES("IP_ADDRESSES"),
/**
* The key of the node name attribute of a member
*/
- String NODE_NAME = "NODE_NAME";
+ NODE_NAME("NODE_NAME"),
/**
* The role of the sonar-application inside the SonarQube cluster
* {@link NodeType}
*/
- String NODE_TYPE = "NODE_TYPE";
+ NODE_TYPE("NODE_TYPE"),
/**
* Key of process as defined by {@link ProcessId#getKey()}
*/
- String PROCESS_KEY = "PROCESS_KEY";
+ PROCESS_KEY("PROCESS_KEY");
+
+ private final String key;
+
+ Attribute(String key) {
+ this.key = key;
+ }
+
+ public String getKey() {
+ return key;
+ }
}
<E> IAtomicReference<E> getAtomicReference(String name);
diff --git a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java
index 806b0d7cf8e..55a5dd0a4ed 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberBuilder.java
@@ -29,7 +29,7 @@ import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import javax.annotation.CheckForNull;
-import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
import org.sonar.process.ProcessProperties;
import org.sonar.process.cluster.NodeType;
@@ -130,11 +130,11 @@ public class HazelcastMemberBuilder {
.setProperty("hazelcast.logging.type", "slf4j");
MemberAttributeConfig attributes = config.getMemberAttributeConfig();
- attributes.setStringAttribute(Attribute.HOSTNAME, NetworkUtils.INSTANCE.getHostname());
- attributes.setStringAttribute(Attribute.IP_ADDRESSES, NetworkUtils.INSTANCE.getIPAddresses());
- attributes.setStringAttribute(Attribute.NODE_NAME, requireNonNull(nodeName, "Node name is missing"));
- attributes.setStringAttribute(Attribute.NODE_TYPE, requireNonNull(nodeType, "Node type is missing").getValue());
- attributes.setStringAttribute(Attribute.PROCESS_KEY, requireNonNull(processId, "Process key is missing").getKey());
+ attributes.setStringAttribute(Attribute.HOSTNAME.getKey(), NetworkUtilsImpl.INSTANCE.getHostname());
+ attributes.setStringAttribute(Attribute.IP_ADDRESSES.getKey(), NetworkUtilsImpl.INSTANCE.getIPAddresses());
+ attributes.setStringAttribute(Attribute.NODE_NAME.getKey(), requireNonNull(nodeName, "Node name is missing"));
+ attributes.setStringAttribute(Attribute.NODE_TYPE.getKey(), requireNonNull(nodeType, "Node type is missing").getValue());
+ attributes.setStringAttribute(Attribute.PROCESS_KEY.getKey(), requireNonNull(processId, "Process key is missing").getKey());
return new HazelcastMemberImpl(Hazelcast.newHazelcastInstance(config));
}
diff --git a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberSelectors.java b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberSelectors.java
index 3b7abe59f89..222ea28e7f9 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberSelectors.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberSelectors.java
@@ -25,6 +25,7 @@ import org.sonar.process.ProcessId;
import static java.util.Arrays.asList;
import static org.sonar.process.ProcessId.fromKey;
+import static org.sonar.process.cluster.hz.HazelcastMember.Attribute.PROCESS_KEY;
public class HazelcastMemberSelectors {
@@ -34,7 +35,7 @@ public class HazelcastMemberSelectors {
public static MemberSelector selectorForProcessIds(ProcessId... processIds) {
List<ProcessId> processIdList = asList(processIds);
return member -> {
- ProcessId memberProcessId = fromKey(member.getStringAttribute(HazelcastMember.Attribute.PROCESS_KEY));
+ ProcessId memberProcessId = fromKey(member.getStringAttribute(PROCESS_KEY.getKey()));
return processIdList.contains(memberProcessId);
};
}
diff --git a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastObjects.java b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastObjects.java
index 97e5952b8d7..ddcf39bc126 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastObjects.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastObjects.java
@@ -20,9 +20,6 @@
package org.sonar.process.cluster.hz;
-import org.sonar.process.ProcessId;
-import org.sonar.process.cluster.NodeType;
-
/**
* This class holds all object keys accessible via Hazelcast
*/
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/DistributedAnswerTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/DistributedAnswerTest.java
index 2cdf3d5dd75..5b45fc8a6a8 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/DistributedAnswerTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/DistributedAnswerTest.java
@@ -28,6 +28,7 @@ import org.junit.rules.ExpectedException;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
+import static org.sonar.process.cluster.hz.HazelcastMember.Attribute.NODE_NAME;
public class DistributedAnswerTest {
@@ -133,7 +134,7 @@ public class DistributedAnswerTest {
private static Member newMember(String uuid) {
Member member = mock(Member.class);
when(member.getUuid()).thenReturn(uuid);
- when(member.getStringAttribute(HazelcastMember.Attribute.NODE_NAME)).thenReturn(uuid);
+ when(member.getStringAttribute(NODE_NAME.getKey())).thenReturn(uuid);
return member;
}
}
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberBuilderTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberBuilderTest.java
index 9316ad6d3e0..6a4973b8d13 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberBuilderTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberBuilderTest.java
@@ -25,7 +25,7 @@ import org.junit.Test;
import org.junit.rules.DisableOnDebug;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
-import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
import org.sonar.process.ProcessProperties;
import org.sonar.process.cluster.NodeType;
@@ -49,7 +49,7 @@ public class HazelcastMemberBuilderTest {
.setProcessId(ProcessId.COMPUTE_ENGINE)
.setClusterName("foo")
.setNodeName("bar")
- .setPort(NetworkUtils.INSTANCE.getNextAvailablePort(loopback))
+ .setPort(NetworkUtilsImpl.INSTANCE.getNextAvailablePort(loopback))
.setNetworkInterface(loopback.getHostAddress())
.build();
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java
index 72087914a8e..4d83a82f233 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberImplTest.java
@@ -35,7 +35,7 @@ import org.junit.rules.DisableOnDebug;
import org.junit.rules.ExpectedException;
import org.junit.rules.TestRule;
import org.junit.rules.Timeout;
-import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.ProcessId;
import org.sonar.process.cluster.NodeType;
@@ -56,9 +56,9 @@ public class HazelcastMemberImplTest {
@BeforeClass
public static void setUp() throws Exception {
- int port1 = NetworkUtils.INSTANCE.getNextAvailablePort(loopback);
- int port2 = NetworkUtils.INSTANCE.getNextAvailablePort(loopback);
- int port3 = NetworkUtils.INSTANCE.getNextAvailablePort(loopback);
+ int port1 = NetworkUtilsImpl.INSTANCE.getNextAvailablePort(loopback);
+ int port2 = NetworkUtilsImpl.INSTANCE.getNextAvailablePort(loopback);
+ int port3 = NetworkUtilsImpl.INSTANCE.getNextAvailablePort(loopback);
member1 = newHzMember(port1, port2, port3);
member2 = newHzMember(port2, port1, port3);
member3 = newHzMember(port3, port1, port2);
diff --git a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberSelectorsTest.java b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberSelectorsTest.java
index 309e3463a32..ce5c36de367 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberSelectorsTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/cluster/hz/HazelcastMemberSelectorsTest.java
@@ -38,13 +38,13 @@ public class HazelcastMemberSelectorsTest {
Member member = mock(Member.class);
MemberSelector underTest = HazelcastMemberSelectors.selectorForProcessIds(COMPUTE_ENGINE);
- when(member.getStringAttribute(PROCESS_KEY)).thenReturn(COMPUTE_ENGINE.getKey());
+ when(member.getStringAttribute(PROCESS_KEY.getKey())).thenReturn(COMPUTE_ENGINE.getKey());
assertThat(underTest.select(member)).isTrue();
- when(member.getStringAttribute(PROCESS_KEY)).thenReturn(WEB_SERVER.getKey());
+ when(member.getStringAttribute(PROCESS_KEY.getKey())).thenReturn(WEB_SERVER.getKey());
assertThat(underTest.select(member)).isFalse();
- when(member.getStringAttribute(PROCESS_KEY)).thenReturn(APP.getKey());
+ when(member.getStringAttribute(PROCESS_KEY.getKey())).thenReturn(APP.getKey());
assertThat(underTest.select(member)).isFalse();
}
@@ -53,13 +53,13 @@ public class HazelcastMemberSelectorsTest {
Member member = mock(Member.class);
MemberSelector underTest = HazelcastMemberSelectors.selectorForProcessIds(WEB_SERVER, APP);
- when(member.getStringAttribute(PROCESS_KEY)).thenReturn(COMPUTE_ENGINE.getKey());
+ when(member.getStringAttribute(PROCESS_KEY.getKey())).thenReturn(COMPUTE_ENGINE.getKey());
assertThat(underTest.select(member)).isFalse();
- when(member.getStringAttribute(PROCESS_KEY)).thenReturn(WEB_SERVER.getKey());
+ when(member.getStringAttribute(PROCESS_KEY.getKey())).thenReturn(WEB_SERVER.getKey());
assertThat(underTest.select(member)).isTrue();
- when(member.getStringAttribute(PROCESS_KEY)).thenReturn(APP.getKey());
+ when(member.getStringAttribute(PROCESS_KEY.getKey())).thenReturn(APP.getKey());
assertThat(underTest.select(member)).isTrue();
}
} \ No newline at end of file
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerLogging.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerLogging.java
index c7da8f50085..5075fff884c 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/ServerLogging.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ServerLogging.java
@@ -42,7 +42,7 @@ import static org.sonar.api.utils.log.LoggerLevel.TRACE;
public class ServerLogging implements Startable {
/** Used for Hazelcast's distributed queries in cluster mode */
- private static ServerLogging INSTANCE;
+ private static ServerLogging instance;
private final LogbackHelper helper;
private final Configuration config;
private final ServerProcessLogging serverProcessLogging;
@@ -62,16 +62,16 @@ public class ServerLogging implements Startable {
@Override
public void start() {
- INSTANCE = this;
+ instance = this;
}
@Override
public void stop() {
- INSTANCE = null;
+ instance = null;
}
public static void changeLevelFromHazelcastDistributedQuery(LoggerLevel level) {
- INSTANCE.changeLevel(level);
+ instance.changeLevel(level);
}
public void changeLevel(LoggerLevel level) {
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/OfficialDistribution.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/OfficialDistribution.java
index 4120fcda0f4..5d90aadf749 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/OfficialDistribution.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/OfficialDistribution.java
@@ -20,23 +20,23 @@
package org.sonar.server.platform.monitoring;
import java.io.File;
-import org.sonar.api.platform.Server;
import org.sonar.api.server.ServerSide;
+import org.sonar.server.platform.ServerFileSystem;
@ServerSide
public class OfficialDistribution {
static final String BRANDING_FILE_PATH = "web/WEB-INF/classes/com/sonarsource/branding";
- private final Server server;
+ private final ServerFileSystem serverFileSystem;
- public OfficialDistribution(Server server) {
- this.server = server;
+ public OfficialDistribution(ServerFileSystem serverFileSystem) {
+ this.serverFileSystem = serverFileSystem;
}
public boolean check() {
// the dependency com.sonarsource:sonarsource-branding is shaded to webapp
// during release (see sonar-web pom)
- File brandingFile = new File(server.getRootDir(), BRANDING_FILE_PATH);
+ File brandingFile = new File(serverFileSystem.getHomeDir(), BRANDING_FILE_PATH);
// no need to check that the file exists. java.io.File#length() returns zero in this case.
return brandingFile.length() > 0L;
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/cluster/AppNodesInfoLoaderImpl.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/cluster/AppNodesInfoLoaderImpl.java
index 67c943028f0..bb545a764eb 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/cluster/AppNodesInfoLoaderImpl.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/cluster/AppNodesInfoLoaderImpl.java
@@ -31,6 +31,9 @@ import org.sonar.process.cluster.hz.DistributedAnswer;
import org.sonar.process.cluster.hz.HazelcastMember;
import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
+import static org.sonar.process.cluster.hz.HazelcastMember.Attribute.NODE_NAME;
+import static org.sonar.process.cluster.hz.HazelcastMember.Attribute.PROCESS_KEY;
+
@ServerSide
public class AppNodesInfoLoaderImpl implements AppNodesInfoLoader {
@@ -45,7 +48,7 @@ public class AppNodesInfoLoaderImpl implements AppNodesInfoLoader {
Map<String, NodeInfo> nodesByName = new HashMap<>();
DistributedAnswer<ProtobufSystemInfo.SystemInfo> distributedAnswer = hzMember.call(ProcessInfoProvider::provide, new CeWebMemberSelector(), 15_000L);
for (Member member : distributedAnswer.getMembers()) {
- String nodeName = member.getStringAttribute(HazelcastMember.Attribute.NODE_NAME);
+ String nodeName = member.getStringAttribute(NODE_NAME.getKey());
NodeInfo nodeInfo = nodesByName.get(nodeName);
if (nodeInfo == null) {
nodeInfo = new NodeInfo(nodeName);
@@ -76,7 +79,7 @@ public class AppNodesInfoLoaderImpl implements AppNodesInfoLoader {
private static class CeWebMemberSelector implements MemberSelector {
@Override
public boolean select(Member member) {
- String processKey = member.getStringAttribute(HazelcastMember.Attribute.PROCESS_KEY);
+ String processKey = member.getStringAttribute(PROCESS_KEY.getKey());
return processKey.equals(ProcessId.WEB_SERVER.getKey()) || processKey.equals(ProcessId.COMPUTE_ENGINE.getKey());
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/cluster/ProcessInfoProvider.java b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/cluster/ProcessInfoProvider.java
index 3f4350c6619..a2f106b5a4f 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/cluster/ProcessInfoProvider.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/monitoring/cluster/ProcessInfoProvider.java
@@ -34,7 +34,7 @@ import org.sonar.process.systeminfo.protobuf.ProtobufSystemInfo;
public class ProcessInfoProvider implements Startable {
/** Used for Hazelcast's distributed queries in cluster mode */
- private static ProcessInfoProvider INSTANCE;
+ private static ProcessInfoProvider instance;
private final List<SystemInfoSection> sections;
public ProcessInfoProvider(SystemInfoSection[] sections) {
@@ -45,17 +45,17 @@ public class ProcessInfoProvider implements Startable {
@Override
public void start() {
- INSTANCE = this;
+ instance = this;
}
@Override
public void stop() {
- INSTANCE = null;
+ instance = null;
}
public static ProtobufSystemInfo.SystemInfo provide() {
ProtobufSystemInfo.SystemInfo.Builder protobuf = ProtobufSystemInfo.SystemInfo.newBuilder();
- INSTANCE.sections.forEach(section -> protobuf.addSections(section.toProtobuf()));
+ instance.sections.forEach(section -> protobuf.addSections(section.toProtobuf()));
return protobuf.build();
}
}
diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
index 56e31290229..87bfb90d1e7 100644
--- a/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
+++ b/server/sonar-server/src/main/java/org/sonar/server/platform/platformlevel/PlatformLevel1.java
@@ -22,7 +22,6 @@ package org.sonar.server.platform.platformlevel;
import java.time.Clock;
import java.util.Properties;
import javax.annotation.Nullable;
-import org.sonar.process.NetworkUtils;
import org.sonar.api.SonarQubeSide;
import org.sonar.api.SonarQubeVersion;
import org.sonar.api.internal.ApiVersion;
@@ -40,6 +39,7 @@ import org.sonar.db.DbClient;
import org.sonar.db.DefaultDatabase;
import org.sonar.db.purge.PurgeProfiler;
import org.sonar.db.semaphore.SemaphoresImpl;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.logging.LogbackHelper;
import org.sonar.server.app.ProcessCommandWrapperImpl;
import org.sonar.server.app.RestartFlagHolderImpl;
@@ -86,7 +86,7 @@ public class PlatformLevel1 extends PlatformLevel {
ProcessCommandWrapperImpl.class,
RestartFlagHolderImpl.class,
UuidFactoryImpl.INSTANCE,
- NetworkUtils.INSTANCE,
+ NetworkUtilsImpl.INSTANCE,
UrlSettings.class,
EmbeddedDatabaseFactory.class,
LogbackHelper.class,
diff --git a/server/sonar-server/src/test/java/org/sonar/server/app/EmbeddedTomcatTest.java b/server/sonar-server/src/test/java/org/sonar/server/app/EmbeddedTomcatTest.java
index 2840cba3b45..5162e13d240 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/app/EmbeddedTomcatTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/app/EmbeddedTomcatTest.java
@@ -28,7 +28,7 @@ import org.apache.commons.io.FileUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import org.sonar.process.Props;
import static org.assertj.core.api.Assertions.assertThat;
@@ -55,7 +55,7 @@ public class EmbeddedTomcatTest {
// start server on a random port
InetAddress address = InetAddress.getLoopbackAddress();
- int httpPort = NetworkUtils.INSTANCE.getNextAvailablePort(address);
+ int httpPort = NetworkUtilsImpl.INSTANCE.getNextAvailablePort(address);
props.set("sonar.web.host", address.getHostAddress());
props.set("sonar.web.port", String.valueOf(httpPort));
EmbeddedTomcat tomcat = new EmbeddedTomcat(props);
diff --git a/server/sonar-server/src/test/java/org/sonar/server/cluster/StartableHazelcastMemberTest.java b/server/sonar-server/src/test/java/org/sonar/server/cluster/StartableHazelcastMemberTest.java
index 475079444ec..84e82d23386 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/cluster/StartableHazelcastMemberTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/cluster/StartableHazelcastMemberTest.java
@@ -27,6 +27,7 @@ import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.Assert.fail;
@@ -45,7 +46,7 @@ public class StartableHazelcastMemberTest {
@Test
public void start_initializes_hazelcast() {
completeValidSettings();
- StartableHazelcastMember underTest = new StartableHazelcastMember(settings.asConfig(), NetworkUtils.INSTANCE);
+ StartableHazelcastMember underTest = new StartableHazelcastMember(settings.asConfig(), NetworkUtilsImpl.INSTANCE);
verifyStopped(underTest);
underTest.start();
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java
index 416524560f1..5306c9d4051 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/platform/db/EmbeddedDatabaseTest.java
@@ -34,7 +34,7 @@ import org.junit.rules.Timeout;
import org.sonar.api.config.internal.MapSettings;
import org.sonar.api.utils.System2;
import org.sonar.api.utils.log.LogTester;
-import org.sonar.process.NetworkUtils;
+import org.sonar.process.NetworkUtilsImpl;
import static junit.framework.Assert.fail;
import static org.mockito.Mockito.mock;
@@ -113,7 +113,7 @@ public class EmbeddedDatabaseTest {
@Test
public void start_ignores_URL_to_create_database_and_uses_default_username_and_password_when_then_are_not_set() throws IOException {
- int port = NetworkUtils.INSTANCE.getNextAvailablePort(InetAddress.getLoopbackAddress());
+ int port = NetworkUtilsImpl.INSTANCE.getNextAvailablePort(InetAddress.getLoopbackAddress());
settings
.setProperty(PATH_DATA, temporaryFolder.newFolder().getAbsolutePath())
.setProperty(PROP_URL, "jdbc url")
@@ -126,7 +126,7 @@ public class EmbeddedDatabaseTest {
@Test
public void start_creates_db_and_adds_tcp_listener() throws IOException {
- int port = NetworkUtils.INSTANCE.getNextAvailablePort(InetAddress.getLoopbackAddress());
+ int port = NetworkUtilsImpl.INSTANCE.getNextAvailablePort(InetAddress.getLoopbackAddress());
settings
.setProperty(PATH_DATA, temporaryFolder.newFolder().getAbsolutePath())
.setProperty(PROP_URL, "jdbc url")
@@ -144,7 +144,7 @@ public class EmbeddedDatabaseTest {
@Test
public void start_supports_in_memory_H2_JDBC_URL() throws IOException {
- int port = NetworkUtils.INSTANCE.getNextAvailablePort(InetAddress.getLoopbackAddress());
+ int port = NetworkUtilsImpl.INSTANCE.getNextAvailablePort(InetAddress.getLoopbackAddress());
settings
.setProperty(PATH_DATA, temporaryFolder.newFolder().getAbsolutePath())
.setProperty(PROP_URL, "jdbc:h2:mem:sonar")
diff --git a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/OfficialDistributionTest.java b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/OfficialDistributionTest.java
index 3f6a1cdb80a..dc68af71716 100644
--- a/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/OfficialDistributionTest.java
+++ b/server/sonar-server/src/test/java/org/sonar/server/platform/monitoring/OfficialDistributionTest.java
@@ -24,7 +24,7 @@ import org.apache.commons.io.FileUtils;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
-import org.sonar.api.platform.Server;
+import org.sonar.server.platform.ServerFileSystem;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.mock;
@@ -36,14 +36,14 @@ public class OfficialDistributionTest {
@Rule
public TemporaryFolder temp = new TemporaryFolder();
- private Server server = mock(Server.class);
- private OfficialDistribution underTest = new OfficialDistribution(server);
+ private ServerFileSystem serverFileSystem = mock(ServerFileSystem.class);
+ private OfficialDistribution underTest = new OfficialDistribution(serverFileSystem);
@Test
public void official_distribution() throws Exception {
File rootDir = temp.newFolder();
FileUtils.write(new File(rootDir, OfficialDistribution.BRANDING_FILE_PATH), "1.2");
- when(server.getRootDir()).thenReturn(rootDir);
+ when(serverFileSystem.getHomeDir()).thenReturn(rootDir);
assertThat(underTest.check()).isTrue();
}
@@ -52,7 +52,7 @@ public class OfficialDistributionTest {
public void not_an_official_distribution() throws Exception {
File rootDir = temp.newFolder();
// branding file is missing
- when(server.getRootDir()).thenReturn(rootDir);
+ when(serverFileSystem.getHomeDir()).thenReturn(rootDir);
assertThat(underTest.check()).isFalse();
}