You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/11/26 07:06:22 UTC

[GitHub] [pulsar] 315157973 commented on a change in pull request #12970: [PIP-105] Part-2 Support pluggable entry filter in Dispatcher

315157973 commented on a change in pull request #12970:
URL: https://github.com/apache/pulsar/pull/12970#discussion_r757269321



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/EntryFilter.java
##########
@@ -0,0 +1,132 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import java.nio.file.Path;
+import java.util.Map;
+import java.util.TreeMap;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.bookkeeper.mledger.Entry;
+import org.apache.bookkeeper.mledger.ManagedCursor;
+import org.apache.pulsar.common.api.proto.MessageMetadata;
+import org.apache.pulsar.common.nar.NarClassLoader;
+
+public interface EntryFilter {
+
+    /**
+     * Broker determines whether to filter out this entry based on the return value of this method.
+     * Do not deserialize the entire entry in this method,
+     * which has a great impact on the broker's memory and CPU.
+     * @param entry
+     * @param context
+     * @return
+     */
+    FilterResult filterEntry(Entry entry, FilterContext context);
+
+    @Data
+    class FilterContext {
+
+        private EntryBatchSizes batchSizes;
+        private SendMessageInfo sendMessageInfo;
+        private EntryBatchIndexesAcks indexesAcks;
+        private ManagedCursor cursor;
+        private boolean isReplayRead;
+        private Subscription subscription;
+        private SubscriptionOption subscriptionOption;
+        private MessageMetadata msgMetadata;
+
+        public void reset() {

Review comment:
       I think Context does not need to be made into an interface, just make it into a class directly




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