diff options
Diffstat (limited to 'server/sonar-process/src')
-rw-r--r-- | server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMember.java | 6 | ||||
-rw-r--r-- | server/sonar-process/src/main/java/org/sonar/process/cluster/hz/HazelcastMemberImpl.java | 16 |
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(); |