aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-08-25 14:48:32 +0200
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2017-09-13 15:50:49 +0200
commitd919b231c0c406899f7ee1f9f2d3775d4d322380 (patch)
tree2d8615926e6b753b4312ebe7f36f80744a902605 /server
parent80269a5d22553335f22f3e8a8a5840724fb154f9 (diff)
downloadsonarqube-d919b231c0c406899f7ee1f9f2d3775d4d322380.tar.gz
sonarqube-d919b231c0c406899f7ee1f9f2d3775d4d322380.zip
SONAR-9741 rename HazelcastClientWrapper to HazelcastClient
Diffstat (limited to 'server')
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/CeDistributedInformationImpl.java18
-rw-r--r--server/sonar-ce/src/main/java/org/sonar/ce/container/ComputeEngineContainerImpl.java4
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java4
-rw-r--r--server/sonar-ce/src/test/java/org/sonar/ce/container/ComputeEngineContainerImplTest.java8
-rw-r--r--server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastClient.java (renamed from server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastClientWrapper.java)2
-rw-r--r--server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastLocalClient.java (renamed from server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastClientWrapperImpl.java)9
-rw-r--r--server/sonar-cluster/src/test/java/org/sonar/cluster/localclient/HazelcastLocalClientTest.java (renamed from server/sonar-cluster/src/test/java/org/sonar/cluster/localclient/HazelcastClientWrapperImplTest.java)18
7 files changed, 31 insertions, 32 deletions
diff --git a/server/sonar-ce/src/main/java/org/sonar/ce/CeDistributedInformationImpl.java b/server/sonar-ce/src/main/java/org/sonar/ce/CeDistributedInformationImpl.java
index 87436b26d1c..96cfbb6fdf5 100644
--- a/server/sonar-ce/src/main/java/org/sonar/ce/CeDistributedInformationImpl.java
+++ b/server/sonar-ce/src/main/java/org/sonar/ce/CeDistributedInformationImpl.java
@@ -26,7 +26,7 @@ import java.util.concurrent.locks.Lock;
import org.picocontainer.Startable;
import org.sonar.ce.taskprocessor.CeWorkerFactory;
import org.sonar.cluster.ClusterObjectKeys;
-import org.sonar.cluster.localclient.HazelcastClientWrapper;
+import org.sonar.cluster.localclient.HazelcastClient;
import static org.sonar.cluster.ClusterObjectKeys.WORKER_UUIDS;
import static org.sonar.core.util.stream.MoreCollectors.toSet;
@@ -35,17 +35,17 @@ import static org.sonar.core.util.stream.MoreCollectors.toSet;
* Provide the set of worker's UUID in a clustered SonarQube instance
*/
public class CeDistributedInformationImpl implements CeDistributedInformation, Startable {
- private final HazelcastClientWrapper hazelcastClientWrapper;
+ private final HazelcastClient hazelcastClient;
private final CeWorkerFactory ceCeWorkerFactory;
- public CeDistributedInformationImpl(HazelcastClientWrapper hazelcastClientWrapper, CeWorkerFactory ceCeWorkerFactory) {
- this.hazelcastClientWrapper = hazelcastClientWrapper;
+ public CeDistributedInformationImpl(HazelcastClient hazelcastClient, CeWorkerFactory ceCeWorkerFactory) {
+ this.hazelcastClient = hazelcastClient;
this.ceCeWorkerFactory = ceCeWorkerFactory;
}
@Override
public Set<String> getWorkerUUIDs() {
- Set<String> connectedWorkerUUIDs = hazelcastClientWrapper.getConnectedClients();
+ Set<String> connectedWorkerUUIDs = hazelcastClient.getConnectedClients();
return getClusteredWorkerUUIDs().entrySet().stream()
.filter(e -> connectedWorkerUUIDs.contains(e.getKey()))
@@ -56,12 +56,12 @@ public class CeDistributedInformationImpl implements CeDistributedInformation, S
@Override
public void broadcastWorkerUUIDs() {
- getClusteredWorkerUUIDs().put(hazelcastClientWrapper.getClientUUID(), ceCeWorkerFactory.getWorkerUUIDs());
+ getClusteredWorkerUUIDs().put(hazelcastClient.getClientUUID(), ceCeWorkerFactory.getWorkerUUIDs());
}
@Override
public Lock acquireCleanJobLock() {
- return hazelcastClientWrapper.getLock(ClusterObjectKeys.CE_CLEANING_JOB_LOCK);
+ return hazelcastClient.getLock(ClusterObjectKeys.CE_CLEANING_JOB_LOCK);
}
@Override
@@ -72,10 +72,10 @@ public class CeDistributedInformationImpl implements CeDistributedInformation, S
@Override
public void stop() {
// Removing the worker UUIDs
- getClusteredWorkerUUIDs().remove(hazelcastClientWrapper.getClientUUID());
+ getClusteredWorkerUUIDs().remove(hazelcastClient.getClientUUID());
}
private Map<String, Set<String>> getClusteredWorkerUUIDs() {
- return hazelcastClientWrapper.getReplicatedMap(WORKER_UUIDS);
+ return hazelcastClient.getReplicatedMap(WORKER_UUIDS);
}
}
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 d05761ecd7d..eaf94df4bdc 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
@@ -55,7 +55,7 @@ import org.sonar.ce.settings.ProjectConfigurationFactory;
import org.sonar.ce.taskprocessor.CeProcessingScheduler;
import org.sonar.ce.taskprocessor.CeTaskProcessorModule;
import org.sonar.ce.user.CeUserSession;
-import org.sonar.cluster.localclient.HazelcastClientWrapperImpl;
+import org.sonar.cluster.localclient.HazelcastLocalClient;
import org.sonar.core.component.DefaultResourceTypes;
import org.sonar.core.config.ConfigurationProvider;
import org.sonar.core.config.CorePropertyDefinitions;
@@ -191,7 +191,7 @@ public class ComputeEngineContainerImpl implements ComputeEngineContainer {
// TODO refactoring levelXComponents()
if (props.valueAsBoolean("sonar.cluster.enabled")) {
this.level4.add(
- HazelcastClientWrapperImpl.class,
+ HazelcastLocalClient.class,
CeDistributedInformationImpl.class);
} else {
this.level4.add(
diff --git a/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java b/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java
index 74b34822f6a..782db8bc4a4 100644
--- a/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java
+++ b/server/sonar-ce/src/test/java/org/sonar/ce/CeDistributedInformationImplTest.java
@@ -27,7 +27,7 @@ import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.sonar.ce.taskprocessor.CeWorkerFactory;
-import org.sonar.cluster.localclient.HazelcastClientWrapperImpl;
+import org.sonar.cluster.localclient.HazelcastLocalClient;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.data.MapEntry.entry;
@@ -45,7 +45,7 @@ public class CeDistributedInformationImplTest {
clientUUID3, ImmutableSet.of("4", "5", "6")
);
- private HazelcastClientWrapperImpl hzClientWrapper = mock(HazelcastClientWrapperImpl.class);
+ private HazelcastLocalClient hzClientWrapper = mock(HazelcastLocalClient.class);
@Test
public void getWorkerUUIDs_returns_union_of_workers_uuids_of_local_and_cluster_worker_uuids() {
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 28b8e81f499..1d927fb310f 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
@@ -41,7 +41,7 @@ import org.sonar.api.utils.System2;
import org.sonar.ce.CeDistributedInformationImpl;
import org.sonar.ce.StandaloneCeDistributedInformation;
import org.sonar.cluster.internal.HazelcastTestHelper;
-import org.sonar.cluster.localclient.HazelcastClientWrapperImpl;
+import org.sonar.cluster.localclient.HazelcastLocalClient;
import org.sonar.db.DbTester;
import org.sonar.db.property.PropertyDto;
import org.sonar.process.ProcessId;
@@ -103,7 +103,7 @@ public class ComputeEngineContainerImplTest {
assertThat(
picoContainer.getComponentAdapters().stream()
.map(ComponentAdapter::getComponentImplementation)
- .collect(Collectors.toList())).contains((Class) HazelcastClientWrapperImpl.class,
+ .collect(Collectors.toList())).contains((Class) HazelcastLocalClient.class,
(Class) CeDistributedInformationImpl.class);
underTest.stop();
}
@@ -153,7 +153,7 @@ public class ComputeEngineContainerImplTest {
assertThat(
picoContainer.getComponentAdapters().stream()
.map(ComponentAdapter::getComponentImplementation)
- .collect(Collectors.toList())).doesNotContain((Class) HazelcastClientWrapperImpl.class,
+ .collect(Collectors.toList())).doesNotContain((Class) HazelcastLocalClient.class,
(Class) CeDistributedInformationImpl.class).contains(
(Class) StandaloneCeDistributedInformation.class);
assertThat(picoContainer.getParent().getParent().getParent().getParent()).isNull();
@@ -185,4 +185,4 @@ public class ComputeEngineContainerImplTest {
dbTester.getDbClient().propertiesDao().saveProperty(dbTester.getSession(), dto);
dbTester.commit();
}
-} \ No newline at end of file
+}
diff --git a/server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastClientWrapper.java b/server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastClient.java
index ae42934f52a..b37718f46cc 100644
--- a/server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastClientWrapper.java
+++ b/server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastClient.java
@@ -28,7 +28,7 @@ import java.util.concurrent.locks.Lock;
/**
* The interface Hazelcast client wrapper.
*/
-public interface HazelcastClientWrapper {
+public interface HazelcastClient {
/**
* Gets the set shared by the cluster and identified by name
*/
diff --git a/server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastClientWrapperImpl.java b/server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastLocalClient.java
index 223b5ce6700..cc90fcce27b 100644
--- a/server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastClientWrapperImpl.java
+++ b/server/sonar-cluster/src/main/java/org/sonar/cluster/localclient/HazelcastLocalClient.java
@@ -21,7 +21,6 @@
package org.sonar.cluster.localclient;
import com.google.common.annotations.VisibleForTesting;
-import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.core.HazelcastInstance;
import java.util.List;
@@ -40,15 +39,15 @@ import static org.sonar.cluster.ClusterProperties.CLUSTER_LOCALENDPOINT;
/**
* This class will connect as a Hazelcast client to the local instance of Hazelcluster
*/
-public class HazelcastClientWrapperImpl implements Startable, HazelcastClientWrapper {
+public class HazelcastLocalClient implements Startable, HazelcastClient {
private static final String HAZELCAST_CLUSTER_NAME = "sonarqube";
private final ClientConfig hzConfig;
@VisibleForTesting
- protected HazelcastInstance hzInstance;
+ HazelcastInstance hzInstance;
- public HazelcastClientWrapperImpl(Configuration config) {
+ public HazelcastLocalClient(Configuration config) {
boolean clusterEnabled = config.getBoolean(CLUSTER_ENABLED).orElse(false);
String clusterLocalEndPoint = config.get(CLUSTER_LOCALENDPOINT).orElse(null);
@@ -106,7 +105,7 @@ public class HazelcastClientWrapperImpl implements Startable, HazelcastClientWra
@Override
public void start() {
- this.hzInstance = HazelcastClient.newHazelcastClient(hzConfig);
+ this.hzInstance = com.hazelcast.client.HazelcastClient.newHazelcastClient(hzConfig);
}
@Override
diff --git a/server/sonar-cluster/src/test/java/org/sonar/cluster/localclient/HazelcastClientWrapperImplTest.java b/server/sonar-cluster/src/test/java/org/sonar/cluster/localclient/HazelcastLocalClientTest.java
index 41c81e58349..5c0e754b5a1 100644
--- a/server/sonar-cluster/src/test/java/org/sonar/cluster/localclient/HazelcastClientWrapperImplTest.java
+++ b/server/sonar-cluster/src/test/java/org/sonar/cluster/localclient/HazelcastLocalClientTest.java
@@ -60,7 +60,7 @@ import static org.assertj.core.data.MapEntry.entry;
import static org.sonar.cluster.ClusterProperties.CLUSTER_ENABLED;
import static org.sonar.cluster.ClusterProperties.CLUSTER_LOCALENDPOINT;
-public class HazelcastClientWrapperImplTest {
+public class HazelcastLocalClientTest {
@Rule
public ExpectedException expectedException = ExpectedException.none();
@@ -68,7 +68,7 @@ public class HazelcastClientWrapperImplTest {
public TestRule safeguardTimeout = new DisableOnDebug(Timeout.seconds(60));
private static HazelcastInstance hzCluster;
- private static HazelcastClientWrapperImpl hzClient;
+ private static HazelcastLocalClient hzClient;
@BeforeClass
public static void setupHazelcastClusterAndHazelcastClient() {
@@ -76,7 +76,7 @@ public class HazelcastClientWrapperImplTest {
hzCluster = HazelcastTestHelper.createHazelcastCluster(NetworkUtils.getHostname(), port);
MapSettings settings = createClusterSettings("localhost:" + port);
- hzClient = new HazelcastClientWrapperImpl(settings.asConfig());
+ hzClient = new HazelcastLocalClient(settings.asConfig());
}
@AfterClass
@@ -96,7 +96,7 @@ public class HazelcastClientWrapperImplTest {
@Test
public void start_throws_ISE_if_LOCALENDPOINT_is_incorrect() {
MapSettings settings = createClusterSettings("\u4563\u1432\u1564");
- HazelcastClientWrapperImpl hzClient = new HazelcastClientWrapperImpl(settings.asConfig());
+ HazelcastLocalClient hzClient = new HazelcastLocalClient(settings.asConfig());
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Unable to connect to any address in the config! The following addresses were tried:");
@@ -111,7 +111,7 @@ public class HazelcastClientWrapperImplTest {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("LocalEndPoint have not been set");
- new HazelcastClientWrapperImpl(settings.asConfig());
+ new HazelcastLocalClient(settings.asConfig());
}
@Test
@@ -122,7 +122,7 @@ public class HazelcastClientWrapperImplTest {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Cluster is not enabled");
- new HazelcastClientWrapperImpl(settings.asConfig());
+ new HazelcastLocalClient(settings.asConfig());
}
@Test
@@ -133,7 +133,7 @@ public class HazelcastClientWrapperImplTest {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("Cluster is not enabled");
- new HazelcastClientWrapperImpl(settings.asConfig());
+ new HazelcastLocalClient(settings.asConfig());
}
@Test
@@ -144,7 +144,7 @@ public class HazelcastClientWrapperImplTest {
expectedException.expect(IllegalStateException.class);
expectedException.expectMessage("LocalEndPoint have not been set");
- new HazelcastClientWrapperImpl(settings.asConfig());
+ new HazelcastLocalClient(settings.asConfig());
}
@Test
@@ -154,7 +154,7 @@ public class HazelcastClientWrapperImplTest {
HazelcastInstance hzInstance = HazelcastTestHelper.createHazelcastCluster(NetworkUtils.getHostname(), port);
MapSettings settings = createClusterSettings("localhost:" + port);
- HazelcastClientWrapperImpl hazelcastClientWrapperImpl = new HazelcastClientWrapperImpl(settings.asConfig());
+ HazelcastLocalClient hazelcastClientWrapperImpl = new HazelcastLocalClient(settings.asConfig());
ClientListenerImpl clientListener = new ClientListenerImpl();
hzInstance.getClientService().addClientListener(clientListener);
try {