aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-main/src/main/java
diff options
context:
space:
mode:
authorZipeng WU <zipeng.wu@sonarsource.com>2021-04-13 09:14:07 +0200
committersonartech <sonartech@sonarsource.com>2021-04-15 20:03:44 +0000
commitd8130b676481993c2b258ea326a5778356d93085 (patch)
treefb6ee119dc0f4920a700a29e0603b7025235d7c8 /server/sonar-main/src/main/java
parent4e232156aab47f195c3558757df2b87a7153cfea (diff)
downloadsonarqube-d8130b676481993c2b258ea326a5778356d93085.tar.gz
sonarqube-d8130b676481993c2b258ea326a5778356d93085.zip
SONAR-14625 Upgrade to Hazelcast 4.2
Diffstat (limited to 'server/sonar-main/src/main/java')
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/cluster/AppNodesClusterHostsConsistency.java6
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterAppStateImpl.java38
-rw-r--r--server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterProcess.java7
3 files changed, 26 insertions, 25 deletions
diff --git a/server/sonar-main/src/main/java/org/sonar/application/cluster/AppNodesClusterHostsConsistency.java b/server/sonar-main/src/main/java/org/sonar/application/cluster/AppNodesClusterHostsConsistency.java
index 358facf4032..49e32144f66 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/cluster/AppNodesClusterHostsConsistency.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/cluster/AppNodesClusterHostsConsistency.java
@@ -20,10 +20,10 @@
package org.sonar.application.cluster;
import com.google.common.annotations.VisibleForTesting;
+import com.hazelcast.cluster.Address;
+import com.hazelcast.cluster.Member;
+import com.hazelcast.cluster.MemberSelector;
import com.hazelcast.cluster.memberselector.MemberSelectors;
-import com.hazelcast.core.Member;
-import com.hazelcast.core.MemberSelector;
-import com.hazelcast.nio.Address;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
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 76f30de035c..b2f7ab578e6 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
@@ -19,21 +19,21 @@
*/
package org.sonar.application.cluster;
+import com.hazelcast.cluster.Member;
+import com.hazelcast.cluster.MembershipEvent;
+import com.hazelcast.cluster.MembershipListener;
import com.hazelcast.core.EntryEvent;
import com.hazelcast.core.EntryListener;
import com.hazelcast.core.HazelcastInstanceNotActiveException;
-import com.hazelcast.core.IAtomicReference;
-import com.hazelcast.core.MapEvent;
-import com.hazelcast.core.Member;
-import com.hazelcast.core.MemberAttributeEvent;
-import com.hazelcast.core.MembershipEvent;
-import com.hazelcast.core.MembershipListener;
-import com.hazelcast.core.ReplicatedMap;
+import com.hazelcast.cp.IAtomicReference;
+import com.hazelcast.map.MapEvent;
+import com.hazelcast.replicatedmap.ReplicatedMap;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.UUID;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,8 +63,8 @@ public class ClusterAppStateImpl implements ClusterAppState {
private final List<AppStateListener> listeners = new ArrayList<>();
private final Map<ProcessId, Boolean> operationalLocalProcesses = new EnumMap<>(ProcessId.class);
private final ReplicatedMap<ClusterProcess, Boolean> operationalProcesses;
- private final String operationalProcessListenerUUID;
- private final String nodeDisconnectedListenerUUID;
+ private final UUID operationalProcessListenerUUID;
+ private final UUID nodeDisconnectedListenerUUID;
private final EsConnector esConnector;
private HealthStateSharing healthStateSharing = null;
@@ -120,7 +120,7 @@ public class ClusterAppStateImpl implements ClusterAppState {
@Override
public boolean tryToLockWebLeader() {
- IAtomicReference<String> leader = hzMember.getAtomicReference(LEADER);
+ IAtomicReference<UUID> leader = hzMember.getAtomicReference(LEADER);
return leader.compareAndSet(null, hzMember.getUuid());
}
@@ -159,9 +159,9 @@ public class ClusterAppStateImpl implements ClusterAppState {
@Override
public Optional<String> getLeaderHostName() {
- String leaderId = (String) hzMember.getAtomicReference(LEADER).get();
- if (leaderId != null) {
- Optional<Member> leader = hzMember.getCluster().getMembers().stream().filter(m -> m.getUuid().equals(leaderId)).findFirst();
+ UUID leaderUuid = (UUID) hzMember.getAtomicReference(LEADER).get();
+ if (leaderUuid != null) {
+ Optional<Member> leader = hzMember.getCluster().getMembers().stream().filter(m -> m.getUuid().equals(leaderUuid)).findFirst();
if (leader.isPresent()) {
return Optional.of(leader.get().getAddress().getHost());
}
@@ -239,6 +239,11 @@ public class ClusterAppStateImpl implements ClusterAppState {
public void mapEvicted(MapEvent event) {
// Ignore it
}
+
+ @Override
+ public void entryExpired(EntryEvent<ClusterProcess, Boolean> event) {
+ // Ignore it
+ }
}
private class NodeDisconnectedListener implements MembershipListener {
@@ -252,12 +257,7 @@ public class ClusterAppStateImpl implements ClusterAppState {
removeOperationalProcess(membershipEvent.getMember().getUuid());
}
- @Override
- public void memberAttributeChanged(MemberAttributeEvent memberAttributeEvent) {
- // Nothing to do
- }
-
- private void removeOperationalProcess(String uuid) {
+ private void removeOperationalProcess(UUID uuid) {
for (ClusterProcess clusterProcess : operationalProcesses.keySet()) {
if (clusterProcess.getNodeUuid().equals(uuid)) {
LOGGER.debug("Set node process off for [{}:{}] : ", clusterProcess.getNodeUuid(), clusterProcess.getProcessId());
diff --git a/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterProcess.java b/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterProcess.java
index cf7859c7b16..d48591bb056 100644
--- a/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterProcess.java
+++ b/server/sonar-main/src/main/java/org/sonar/application/cluster/ClusterProcess.java
@@ -21,15 +21,16 @@ package org.sonar.application.cluster;
import java.io.Serializable;
import java.util.Objects;
+import java.util.UUID;
import org.sonar.process.ProcessId;
import static java.util.Objects.requireNonNull;
public class ClusterProcess implements Serializable {
private final ProcessId processId;
- private final String nodeUuid;
+ private final UUID nodeUuid;
- public ClusterProcess(String nodeUuid, ProcessId processId) {
+ public ClusterProcess(UUID nodeUuid, ProcessId processId) {
this.processId = requireNonNull(processId);
this.nodeUuid = requireNonNull(nodeUuid);
}
@@ -38,7 +39,7 @@ public class ClusterProcess implements Serializable {
return processId;
}
- public String getNodeUuid() {
+ public UUID getNodeUuid() {
return nodeUuid;
}