aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process/src
diff options
context:
space:
mode:
authorPierre <pierre.guillot@sonarsource.com>2022-02-03 12:10:18 +0100
committersonartech <sonartech@sonarsource.com>2022-02-18 15:48:04 +0000
commit0c8ff1bac53c2dfa89e7be014b64b411f24434c0 (patch)
treebcad0a2d4daafe106d82f7765be71fec146eb879 /server/sonar-process/src
parent24cd8d71c3b6df3f33f1ff0232c83bbb0a9fc060 (diff)
downloadsonarqube-0c8ff1bac53c2dfa89e7be014b64b411f24434c0.tar.gz
sonarqube-0c8ff1bac53c2dfa89e7be014b64b411f24434c0.zip
SONAR-15919 add ruleset changes
Diffstat (limited to 'server/sonar-process/src')
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java6
-rw-r--r--server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberImpl.java16
2 files changed, 22 insertions, 0 deletions
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 65f43bae707..320a867eb29 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
@@ -26,6 +26,8 @@ import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.locks.Lock;
+import org.sonar.core.util.RuleActivationListener;
+import org.sonar.core.util.RuleSetChangeEvent;
import org.sonar.process.ProcessId;
public interface HazelcastMember extends AutoCloseable {
@@ -106,6 +108,10 @@ public interface HazelcastMember extends AutoCloseable {
*/
<T> void callAsync(DistributedCall<T> callable, MemberSelector memberSelector, DistributedCallback<T> callback);
+ void subscribeRuleActivationTopic(RuleActivationListener listener);
+
+ void publishEvent(RuleSetChangeEvent event);
+
@Override
void close();
}
diff --git a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberImpl.java b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberImpl.java
index 685910361af..9b223cb0c61 100644
--- a/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberImpl.java
+++ b/server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberImpl.java
@@ -27,6 +27,8 @@ import com.hazelcast.core.HazelcastInstanceNotActiveException;
import com.hazelcast.core.IExecutorService;
import com.hazelcast.core.MultiExecutionCallback;
import com.hazelcast.cp.IAtomicReference;
+import com.hazelcast.topic.ITopic;
+import com.hazelcast.topic.MessageListener;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@@ -37,6 +39,8 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.locks.Lock;
import java.util.stream.Collectors;
import org.slf4j.LoggerFactory;
+import org.sonar.core.util.RuleActivationListener;
+import org.sonar.core.util.RuleSetChangeEvent;
class HazelcastMemberImpl implements HazelcastMember {
@@ -126,6 +130,18 @@ class HazelcastMemberImpl implements HazelcastMember {
}
@Override
+ public void subscribeRuleActivationTopic(RuleActivationListener listener) {
+ ITopic<RuleSetChangeEvent> topic = hzInstance.getTopic("ruleActivated");
+ MessageListener<RuleSetChangeEvent> hzListener = message -> listener.listen(message.getMessageObject());
+ topic.addMessageListener(hzListener);
+ }
+
+ @Override
+ public void publishEvent(RuleSetChangeEvent event) {
+ hzInstance.getTopic("ruleActivated").publish(event);
+ }
+
+ @Override
public void close() {
try {
hzInstance.shutdown();