-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[PIP-105] Part-2 Support pluggable entry filter in Dispatcher #12970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e301f88
support entry filter
315157973 04f203a
Merge branch 'master' into plugin-filter
315157973 3bac1be
Support pluggable entry filter in Dispatcher
315157973 b1b033a
fix check style
315157973 4dccf98
Support multi entry filter
315157973 a215b6b
Update pulsar-broker/src/main/java/org/apache/pulsar/broker/service/E…
315157973 942812f
Update pulsar-broker/src/main/java/org/apache/pulsar/broker/service/E…
315157973 e49760f
Update pulsar-broker/src/main/java/org/apache/pulsar/broker/service/E…
315157973 1c06570
Update pulsar-broker/src/main/java/org/apache/pulsar/broker/service/E…
315157973 7e9f5b5
Address comment
315157973 40a86ba
Merge remote-tracking branch 'origin/plugin-filter' into plugin-filter
315157973 02c1e62
fix check style
315157973 efb7078
split into different class
315157973 313d402
fix check style
315157973 0d9f1a7
fix unit test
315157973 b5611dd
fix unit test
315157973 b428669
address comments
315157973 d69a0fd
change doc
315157973 e7c51a4
fix check style
315157973 e16c16b
add close
315157973 74aea66
Add unit test for closing
315157973 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/plugin/EntryFilter.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| /** | ||
| * 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.plugin; | ||
|
|
||
| import org.apache.bookkeeper.mledger.Entry; | ||
|
|
||
| public interface EntryFilter { | ||
|
315157973 marked this conversation as resolved.
|
||
|
|
||
| /** | ||
| * 1. Broker determines whether to filter out this entry based on the return value of this method. | ||
| * 2. Do not deserialize the entire entry in this method, | ||
| * which has a great impact on the broker's memory and CPU. | ||
| * 3. Return ACCEPT or null will be regarded as ACCEPT. | ||
| * @param entry | ||
| * @param context | ||
| * @return | ||
| */ | ||
| FilterResult filterEntry(Entry entry, FilterContext context); | ||
|
|
||
| /** | ||
| * close the entry filter. | ||
| */ | ||
| void close(); | ||
|
|
||
|
|
||
| enum FilterResult { | ||
| /** | ||
| * deliver to the consumer. | ||
| */ | ||
| ACCEPT, | ||
| /** | ||
| * skip the message. | ||
| */ | ||
| REJECT, | ||
| } | ||
|
|
||
| } | ||
42 changes: 42 additions & 0 deletions
42
...r-broker/src/main/java/org/apache/pulsar/broker/service/plugin/EntryFilterDefinition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| /** | ||
| * 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.plugin; | ||
|
|
||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Data | ||
| @NoArgsConstructor | ||
| public class EntryFilterDefinition { | ||
|
|
||
| /** | ||
| * The name of the entry filter. | ||
| */ | ||
| private String name; | ||
|
|
||
| /** | ||
| * The description of the entry filter to be used for user help. | ||
| */ | ||
| private String description; | ||
|
|
||
| /** | ||
| * The class name for the entry filter. | ||
| */ | ||
| private String entryFilterClass; | ||
| } |
28 changes: 28 additions & 0 deletions
28
...-broker/src/main/java/org/apache/pulsar/broker/service/plugin/EntryFilterDefinitions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /** | ||
| * 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.plugin; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.TreeMap; | ||
| import lombok.Data; | ||
|
|
||
| @Data | ||
| public class EntryFilterDefinitions { | ||
| private final Map<String, EntryFilterMetaData> filters = new TreeMap<>(); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.