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



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/EntryFilter.java
##########
@@ -0,0 +1,71 @@
+/**
+ * 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 lombok.Data;
+import org.apache.bookkeeper.mledger.Entry;
+import org.apache.bookkeeper.mledger.ManagedCursor;
+import org.apache.pulsar.common.api.proto.MessageMetadata;
+
+public interface EntryFilter {
+    /**
+     * Broker will determine whether to filter out this Entry based on the 
return value of this method.

Review comment:
       ```suggestion
        * Broker determines whether to filter out this entry based on the 
return value of this method.
   ```

##########
File path: conf/broker.conf
##########
@@ -411,6 +411,11 @@ dispatcherReadFailureBackoffMandatoryStopTimeInMs=0
 # Precise dispathcer flow control according to history message number of each 
entry
 preciseDispatcherFlowControl=false
 
+# Class name of Pluggable entry filter that can decide whether the entry needs 
to be filtered

Review comment:
       ```suggestion
   # Class name of pluggable entry filter that decides whether the entry needs 
to be filtered
   ```

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/EntryFilter.java
##########
@@ -0,0 +1,71 @@
+/**
+ * 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 lombok.Data;
+import org.apache.bookkeeper.mledger.Entry;
+import org.apache.bookkeeper.mledger.ManagedCursor;
+import org.apache.pulsar.common.api.proto.MessageMetadata;
+
+public interface EntryFilter {
+    /**
+     * Broker will determine whether to filter out this Entry based on the 
return value of this method.
+     * Please do not deserialize the entire Entry in this method,
+     * which will have a great impact on Broker's memory and CPU.

Review comment:
       ```suggestion
        * which has a great impact on the broker's memory and CPU.
   ```

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/EntryFilter.java
##########
@@ -0,0 +1,71 @@
+/**
+ * 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 lombok.Data;
+import org.apache.bookkeeper.mledger.Entry;
+import org.apache.bookkeeper.mledger.ManagedCursor;
+import org.apache.pulsar.common.api.proto.MessageMetadata;
+
+public interface EntryFilter {
+    /**
+     * Broker will determine whether to filter out this Entry based on the 
return value of this method.
+     * Please do not deserialize the entire Entry in this method,

Review comment:
       ```suggestion
        * Do not deserialize the entire entry in this method,
   ```

##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/EntryFilter.java
##########
@@ -0,0 +1,71 @@
+/**
+ * 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 lombok.Data;
+import org.apache.bookkeeper.mledger.Entry;
+import org.apache.bookkeeper.mledger.ManagedCursor;
+import org.apache.pulsar.common.api.proto.MessageMetadata;
+
+public interface EntryFilter {
+    /**
+     * Broker will determine whether to filter out this Entry based on the 
return value of this method.
+     * Please do not deserialize the entire Entry in this method,
+     * which will have a great impact on 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() {
+            batchSizes = null;
+            sendMessageInfo = null;
+            indexesAcks = null;
+            cursor = null;
+            isReplayRead = false;
+            subscription = null;
+            subscriptionOption = null;
+            msgMetadata = null;
+        }
+    }
+
+    enum FilterResult {
+        /**
+         * deliver to the Consumer.

Review comment:
       ```suggestion
            * deliver to the consumer.
   ```




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to