Skip to content
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

[broker] Optimize TopicPolicies#messageTTLInSeconds with HierarchyTopicPolicies #13241

Merged
merged 1 commit into from
Dec 12, 2021

Conversation

Jason918
Copy link
Contributor

Motivation

This is one of the serial topic policy optimization with HierarchyTopicPolicies.

Update topic policy with HierarchyTopicPolicies comes with these benefits:

  • All topic policy related settings will goes into AbstractTopic#topicPolicies, easier to understand, check, review, and modify.
  • Unify policy update to AbstractTopic. And easier to find which policy is not applied to non-persistent topic yet. And we can easily add support for it.
  • Unify policy value with 3 level settings (topic/namespace/broker), and priority with topic > namespace > broker. And it's easier to find which level settings is missing.
  • All values are updated at creation or by trigger. We can save some resource to update it or recalculate each time we use it.
  • etc.

Modifications

Add new field messageTTLInSeconds in org.apache.pulsar.broker.service.AbstractTopic#topicPolicies.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as

  • class org.apache.pulsar.broker.admin.TopicMessageTTLTest
  • org.apache.pulsar.client.api.KeySharedSubscriptionTest#testContinueDispatchMessagesWhenMessageTTL
  • org.apache.pulsar.broker.stats.PrometheusMetricsTest#testPerTopicExpiredStat
  • org.apache.pulsar.client.impl.TopicsConsumerImplTest#testDefaultBacklogTTL

Some checklist for updating topic policy with HierarchyTopicPolicies.

  • Broker level value set. And if it's dynamic (no).
  • Namespace level value updated.
  • Topic level value updated.
  • Pre-existing unit test covers this change and updated to verify this change.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • 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: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

Check the box below and label this PR (if you have committer privilege).

Need to update docs?

  • no-need-doc

Code optimization.

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Dec 11, 2021
@Jason918
Copy link
Contributor Author

/pulsarbot run-failure-checks

@codelipenghui codelipenghui merged commit 057edd8 into apache:master Dec 12, 2021
fxbing pushed a commit to fxbing/pulsar that referenced this pull request Dec 19, 2021
…icPolicies (apache#13241)

### Motivation

This is one of the serial topic policy optimization with `HierarchyTopicPolicies`. 

Update topic policy with HierarchyTopicPolicies comes with these benefits:
- All topic policy related settings will goes into AbstractTopic#topicPolicies, easier to understand, check, review, and modify.
- Unify policy update to AbstractTopic. And easier to find which policy is not applied to non-persistent topic yet. And we can easily add support for it.
- Unify policy value with 3 level settings (topic/namespace/broker), and priority with topic > namespace > broker.  And it's easier to find which level settings is missing.
- All values are updated at creation or by trigger. We can save some resource to update it or recalculate each time we use it. 
- etc.

### Modifications

Add new field `messageTTLInSeconds` in org.apache.pulsar.broker.service.AbstractTopic#topicPolicies.

### Verifying this change

- [ ] Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as 
- class org.apache.pulsar.broker.admin.TopicMessageTTLTest
- org.apache.pulsar.client.api.KeySharedSubscriptionTest#testContinueDispatchMessagesWhenMessageTTL
- org.apache.pulsar.broker.stats.PrometheusMetricsTest#testPerTopicExpiredStat
- org.apache.pulsar.client.impl.TopicsConsumerImplTest#testDefaultBacklogTTL

Some checklist for updating topic policy with `HierarchyTopicPolicies`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants