From 129c13bae4afcc3bb924841a6431e9bf7ebd4d4a Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Thu, 19 Oct 2017 12:16:11 +0200 Subject: [PATCH] Do not crash with technical errors when cluster is enabled --- .../java/org/sonar/ce/CeDistributedInformationImpl.java | 6 +++++- .../sonar/process/cluster/health/SharedHealthStateImpl.java | 4 ++++ .../platform/monitoring/cluster/AppNodesInfoLoaderImpl.java | 4 ++++ .../server/platform/ws/ChangeLogLevelClusterService.java | 4 ++++ 4 files changed, 17 insertions(+), 1 deletion(-) 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 23152f3521a..97b8c2a55b2 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 @@ -25,8 +25,8 @@ import java.util.Set; import java.util.concurrent.locks.Lock; import org.picocontainer.Startable; import org.sonar.ce.taskprocessor.CeWorkerFactory; -import org.sonar.process.cluster.hz.HazelcastObjects; import org.sonar.process.cluster.hz.HazelcastMember; +import org.sonar.process.cluster.hz.HazelcastObjects; import static org.sonar.core.util.stream.MoreCollectors.toSet; import static org.sonar.process.cluster.hz.HazelcastObjects.WORKER_UUIDS; @@ -43,6 +43,10 @@ public class CeDistributedInformationImpl implements CeDistributedInformation, S this.ceCeWorkerFactory = ceCeWorkerFactory; } + public CeDistributedInformationImpl(CeWorkerFactory ceCeWorkerFactory) { + this(null, ceCeWorkerFactory); + } + @Override public Set getWorkerUUIDs() { Set connectedWorkerUUIDs = hazelcastMember.getMemberUuids(); diff --git a/server/sonar-process/src/main/java/org/sonar/process/cluster/health/SharedHealthStateImpl.java b/server/sonar-process/src/main/java/org/sonar/process/cluster/health/SharedHealthStateImpl.java index 686aed8fee5..706b4d22d22 100644 --- a/server/sonar-process/src/main/java/org/sonar/process/cluster/health/SharedHealthStateImpl.java +++ b/server/sonar-process/src/main/java/org/sonar/process/cluster/health/SharedHealthStateImpl.java @@ -42,6 +42,10 @@ public class SharedHealthStateImpl implements SharedHealthState { this.hzMember = hzMember; } + public SharedHealthStateImpl() { + this(null); + } + @Override public void writeMine(NodeHealth nodeHealth) { requireNonNull(nodeHealth, "nodeHealth can't be null"); 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 9fd408680bf..1ea993db92d 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 @@ -48,6 +48,10 @@ public class AppNodesInfoLoaderImpl implements AppNodesInfoLoader { this.hzMember = hzMember; } + public AppNodesInfoLoaderImpl() { + this(null); + } + public Collection load() throws InterruptedException { Map nodesByName = new HashMap<>(); MemberSelector memberSelector = HazelcastMemberSelectors.selectorForProcessIds(ProcessId.WEB_SERVER, ProcessId.COMPUTE_ENGINE); diff --git a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelClusterService.java b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelClusterService.java index e26cf710cf2..d517e6a18e6 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelClusterService.java +++ b/server/sonar-server/src/main/java/org/sonar/server/platform/ws/ChangeLogLevelClusterService.java @@ -39,6 +39,10 @@ public class ChangeLogLevelClusterService implements ChangeLogLevelService { this.member = member; } + public ChangeLogLevelClusterService() { + this(null); + } + public void changeLogLevel(LoggerLevel level) throws InterruptedException { member.call(setLogLevelForNode(level), HazelcastMemberSelectors.selectorForProcessIds(ProcessId.WEB_SERVER, ProcessId.COMPUTE_ENGINE), CLUSTER_TIMEOUT_MILLIS) .propagateExceptions(); -- 2.39.5