cassandra-pr mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [cassandra] ifesdjeen commented on a change in pull request #428: CASSANDRA-15505
Date Thu, 23 Jan 2020 08:04:26 GMT
ifesdjeen commented on a change in pull request #428: CASSANDRA-15505 
URL: https://github.com/apache/cassandra/pull/428#discussion_r369974556
 
 

 ##########
 File path: test/distributed/org/apache/cassandra/distributed/impl/MessageFilters.java
 ##########
 @@ -18,65 +18,48 @@
 
 package org.apache.cassandra.distributed.impl;
 
+import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArraySet;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 
-import org.apache.cassandra.distributed.api.IInstance;
+import org.apache.cassandra.distributed.api.IMatcher;
+import org.apache.cassandra.distributed.api.IMessage;
 import org.apache.cassandra.distributed.api.IMessageFilters;
 import org.apache.cassandra.net.Verb;
 
-public class MessageFilters implements IMessageFilters
+public class MessageFilters implements IMessageFilters, IMatcher
 {
-    private final Set<Filter> filters = new CopyOnWriteArraySet<>();
-
-    public boolean permit(IInstance from, IInstance to, int verb)
+    private final IMatcher MATCH_ALL = (from, to, msg) -> true;
+    private final List<Filter> filters = new CopyOnWriteArrayList<>();
+
+    /**
+     * {@code true} value returned by this method implies that the message was not matched
by any
+     * filters and therefore should be delivered.
+     */
+    public boolean matches(int from, int to, IMessage message)
     {
-        if (from == null || to == null)
-            return false; // cannot deliver
-        int fromNum = from.config().num();
-        int toNum = to.config().num();
-
         for (Filter filter : filters)
-            if (filter.matches(fromNum, toNum, verb))
+        {
+            // here, matching logic is inverted: we _drop_ every message that matcher has
matched
+            if (filter.matches(from, to, message))
 
 Review comment:
   Renamed to `permit`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: pr-unsubscribe@cassandra.apache.org
For additional commands, e-mail: pr-help@cassandra.apache.org


Mime
View raw message