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 2022/01/11 14:23:42 UTC
[GitHub] [pulsar] AnonHxy opened a new pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
AnonHxy opened a new pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710
<!--
### Contribution Checklist
- Name the pull request in the form "[Issue XYZ][component] Title of the pull request", where *XYZ* should be replaced by the actual issue number.
Skip *Issue XYZ* if there is no associated github issue for this pull request.
Skip *component* if you are unsure about which is the best component. E.g. `[docs] Fix typo in produce method`.
- Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
- Each pull request should address only one issue, not mix up code from multiple issues.
- Each commit in the pull request has a meaningful commit message
- Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
**(The sections below can be removed for hotfixes of typos)**
-->
### Motivation
* This is one of the serial topic policy optimization with HierarchyTopicPolicies.
### Modifications
* Add new field compactionThreshold in org.apache.pulsar.broker.service.AbstractTopic#topicPolicies.
### Verifying this change
- [x] Make sure that the change passes the CI checks.
### Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): (no)
- The public API: (no)
- The schema: (no )
- The default values of configurations: (no)
- The wire protocol: (no)
- The rest endpoints: (yno)
- The admin cli options: (no)
- Anything that affects deployment: (no)
### Documentation
- [x] `no-need-doc`
--
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
[GitHub] [pulsar] AnonHxy removed a comment on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy removed a comment on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1010602876
/pulsarbot run-failure-checks
--
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
[GitHub] [pulsar] codelipenghui merged pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
codelipenghui merged pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710
--
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
[GitHub] [pulsar] AnonHxy commented on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1011773324
/pulsarbot run-failure-checks
--
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
[GitHub] [pulsar] AnonHxy removed a comment on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy removed a comment on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1010486184
--
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
[GitHub] [pulsar] AnonHxy removed a comment on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy removed a comment on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1010570516
/pulsarbot run-failure-checks
--
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
[GitHub] [pulsar] AnonHxy commented on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1010568783
/pulsarbot run-failure-checks
--
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
[GitHub] [pulsar] codelipenghui commented on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
codelipenghui commented on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1011095432
@Jason918 Do we have a master issue for tracking all the hierarchy topic policies improvements? I'm not sure if we have some need to improve or we have done all topic policies improvements. It will help us to ship all the hierarchy topic policies improvements in 2.10
--
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
[GitHub] [pulsar] AnonHxy commented on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1010570516
/pulsarbot run-failure-checks
--
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
[GitHub] [pulsar] Jason918 commented on a change in pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
Jason918 commented on a change in pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#discussion_r782767023
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
##########
@@ -1438,45 +1438,15 @@ public void checkMessageDeduplicationInfo() {
}
public CompletableFuture<Boolean> isCompactionEnabled() {
- Optional<Long> topicCompactionThreshold = getTopicPolicies()
Review comment:
We can change this method to return bool since it's not blocking any more.
##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicTest.java
##########
@@ -1868,14 +1868,8 @@ public void testCompactionTriggeredAfterThresholdFirstInvocation() throws Except
Compactor compactor = pulsar.getCompactor();
doReturn(compactPromise).when(compactor).compact(anyString());
- Policies policies = new Policies();
- policies.compaction_threshold = 1L;
-
- NamespaceResources nsr = pulsar.getPulsarResources().getNamespaceResources();
- NamespaceName ns = TopicName.get(successTopicName).getNamespaceObject();
- doReturn(Optional.of(policies)).when(nsr).getPolicies(ns);
-
PersistentTopic topic = new PersistentTopic(successTopicName, ledgerMock, brokerService);
+ topic.topicPolicies.getCompactionThreshold().updateNamespaceValue(1L);
Review comment:
You can use `topic.initialize()` to trigger the init.
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
##########
@@ -1438,45 +1438,15 @@ public void checkMessageDeduplicationInfo() {
}
public CompletableFuture<Boolean> isCompactionEnabled() {
- Optional<Long> topicCompactionThreshold = getTopicPolicies()
- .map(TopicPolicies::getCompactionThreshold);
- if (topicCompactionThreshold.isPresent() && topicCompactionThreshold.get() > 0) {
- return CompletableFuture.completedFuture(true);
- }
-
- TopicName topicName = TopicName.get(topic);
- return brokerService.getPulsar().getPulsarResources().getNamespaceResources()
- .getPoliciesAsync(topicName.getNamespaceObject())
- .thenApply(policies -> {
- if (policies.isPresent()) {
- return policies.get().compaction_threshold != null
- && policies.get().compaction_threshold > 0;
- } else {
- // Check broker default
- return brokerService.pulsar().getConfiguration()
- .getBrokerServiceCompactionThresholdInBytes() > 0;
- }
- });
+ Long topicCompactionThreshold = topicPolicies.getCompactionThreshold().get();
+ return CompletableFuture.completedFuture(topicCompactionThreshold != null && topicCompactionThreshold > 0);
}
public void checkCompaction() {
TopicName name = TopicName.get(topic);
try {
- Long compactionThreshold = getTopicPolicies()
- .map(TopicPolicies::getCompactionThreshold)
- .orElse(null);
- if (compactionThreshold == null) {
- Policies policies = brokerService.pulsar().getPulsarResources().getNamespaceResources()
- .getPolicies(name.getNamespaceObject())
- .orElseThrow(() -> new MetadataStoreException.NotFoundException());
- compactionThreshold = policies.compaction_threshold;
- }
- if (compactionThreshold == null) {
- compactionThreshold = brokerService.pulsar().getConfiguration()
- .getBrokerServiceCompactionThresholdInBytes();
- }
-
- if (isSystemTopic() || compactionThreshold != 0
+ Long compactionThreshold = topicPolicies.getCompactionThreshold().get();
Review comment:
`compactionThreshold` can't be null since broker level value is `int` type.
##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentTopicTest.java
##########
@@ -1868,14 +1868,8 @@ public void testCompactionTriggeredAfterThresholdFirstInvocation() throws Except
Compactor compactor = pulsar.getCompactor();
doReturn(compactPromise).when(compactor).compact(anyString());
- Policies policies = new Policies();
- policies.compaction_threshold = 1L;
-
- NamespaceResources nsr = pulsar.getPulsarResources().getNamespaceResources();
- NamespaceName ns = TopicName.get(successTopicName).getNamespaceObject();
- doReturn(Optional.of(policies)).when(nsr).getPolicies(ns);
-
PersistentTopic topic = new PersistentTopic(successTopicName, ledgerMock, brokerService);
+ topic.topicPolicies.getCompactionThreshold().updateNamespaceValue(1L);
Review comment:
This does not cover the init procedure of `topicPolicies.getCompactionThreshold()`.
--
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
[GitHub] [pulsar] AnonHxy commented on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1010639232
/pulsarbot run-failure-checks
--
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
[GitHub] [pulsar] Jason918 commented on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
Jason918 commented on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1011937446
> @Jason918 Do we have a master issue for tracking all the hierarchy topic policies improvements? I'm not sure if we have some need to improve or we have done all topic policies improvements. It will help us to ship all the hierarchy topic policies improvements in 2.10
I will create an issue for this.
Currently, I tracks them locally.
--
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
[GitHub] [pulsar] AnonHxy commented on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1010486184
/pulsarbot run-failure-checks
--
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
[GitHub] [pulsar] AnonHxy removed a comment on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy removed a comment on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1010639232
/pulsarbot run-failure-checks
--
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
[GitHub] [pulsar] AnonHxy commented on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1010602876
/pulsarbot run-failure-checks
--
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
[GitHub] [pulsar] AnonHxy commented on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1010674724
/pulsarbot run-failure-checks
--
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
[GitHub] [pulsar] AnonHxy commented on pull request #13710: [broker] Optimize TopicPolicies#compactionThreshold with HierarchyTopicPolicies
Posted by GitBox <gi...@apache.org>.
AnonHxy commented on pull request #13710:
URL: https://github.com/apache/pulsar/pull/13710#issuecomment-1010910996
/pulsarbot run-failure-checks
--
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