You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "lhotari (via GitHub)" <gi...@apache.org> on 2023/01/31 06:10:06 UTC

[GitHub] [pulsar] lhotari commented on a diff in pull request #19364: [fix][broker] Execute per-topic entry filters with the same classloader

lhotari commented on code in PR #19364:
URL: https://github.com/apache/pulsar/pull/19364#discussion_r1091491319


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/plugin/EntryFilterProvider.java:
##########
@@ -37,74 +43,78 @@
 import org.apache.pulsar.common.util.ObjectMapperFactory;
 
 @Slf4j
-public class EntryFilterProvider {
+public class EntryFilterProvider implements AutoCloseable {
 
     @VisibleForTesting
     static final String ENTRY_FILTER_DEFINITION_FILE = "entry_filter";
 
-    /**
-     * create entry filter instance.
-     */
-    public static ImmutableMap<String, EntryFilterWithClassLoader> createEntryFilters(ServiceConfiguration conf,
-                                                                                      EntryFilters entryFilters)
+    private final ServiceConfiguration serviceConfiguration;
+    private Map<String, EntryFilterMetaData> definitions;
+    private Map<String, NarClassLoader> cachedClassLoaders;
+    private final List<EntryFilterWithClassLoader> brokerEntryFilters;
+
+    public EntryFilterProvider(ServiceConfiguration conf) throws IOException {
+        this.serviceConfiguration = conf;
+        initialize();
+        if (!conf.getEntryFilterNames().isEmpty()) {
+            brokerEntryFilters = loadEntryFilters(conf.getEntryFilterNames());
+        } else {
+            brokerEntryFilters = Collections.emptyList();
+        }
+    }
+
+    public List<EntryFilterWithClassLoader> loadEntryFiltersForPolicy(EntryFilters policy)

Review Comment:
   In the original implementation, `EntryFilterWithClassLoader` is unnecessarily used as a top level concept. I think that this is a bad approach. It's sufficient to use `EntryFilter`. 
   
   Please refactor the solution to hide `EntryFilterWithClassLoader`. It's possible that it could be removed completely. 



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org