mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-20 00:08:04 +01:00
Only respond to cluster toplogy events from the same cluster to which we're subscribed
This commit is contained in:
committed by
Jon Chambers
parent
5afcd634b6
commit
60cdcf5f0c
@@ -35,7 +35,18 @@ public class FaultTolerantPubSubClusterConnection<K, V> extends AbstractFaultTol
|
||||
public void subscribeToClusterTopologyChangedEvents(final Runnable eventHandler) {
|
||||
|
||||
usePubSubConnection(connection -> connection.getResources().eventBus().get()
|
||||
.filter(event -> event instanceof ClusterTopologyChangedEvent)
|
||||
.filter(event -> {
|
||||
// If we use shared `ClientResources` for multiple clients, we may receive topology change events for clusters
|
||||
// other than our own. Filter for clusters that have at least one node in common with our current view of our
|
||||
// partitions.
|
||||
if (event instanceof ClusterTopologyChangedEvent clusterTopologyChangedEvent) {
|
||||
return withPubSubConnection(c -> c.getPartitions().stream().anyMatch(redisClusterNode ->
|
||||
clusterTopologyChangedEvent.before().contains(redisClusterNode) ||
|
||||
clusterTopologyChangedEvent.after().contains(redisClusterNode)));
|
||||
}
|
||||
|
||||
return false;
|
||||
})
|
||||
.subscribeOn(topologyChangedEventScheduler)
|
||||
.subscribe(event -> {
|
||||
logger.info("Got topology change event for {}, resubscribing all keyspace notifications", getName());
|
||||
|
||||
Reference in New Issue
Block a user