Skip to content

Support get topic applied policy for message TTL - #9225

Merged
codelipenghui merged 5 commits into
apache:masterfrom
315157973:MessageTTL
Jan 20, 2021
Merged

codelipenghui merged 5 commits into
apache:masterfrom
315157973:MessageTTL

Conversation

@315157973

Copy link
Copy Markdown
Contributor

Master Issue: #9216

Motivation

Provide a way to get the applied policy of the topic. In Pulsar, the topic will apply the topic level policy if present or apply the namespace policy if present or use the broker level configuration. It needs to support get the applied policy for a topic that might use the namespace policy or topic policy or broker level default configuration.

Modifications

1 Now if there is no data at the namespace-level, the broker-level data will be returned by default, so I fix it
2 Now if there is no data at the topic-level, the data at the namespace-level will be returned by default, so I fix it
3 Add applied interface
4 Since the initial value becomes null, the corresponding unit test is modified

Verifying this change

unit test:
testDifferentLevelPolicyApplied

@315157973

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@zymap zymap left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks good. Left some suggested changes.

@zymap

zymap commented Jan 19, 2021

Copy link
Copy Markdown
Member

/pulsarbot run-failure-checks

1 similar comment
@315157973

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@eolivelli eolivelli left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work.
I have left a comment about backward compatibility, in my opinion we cannot change the behaviour of the existing method.

Also I would rename 'applied' to 'actual'

* Unexpected error
*/
int getMessageTTL(String topic) throws PulsarAdminException;
Integer getMessageTTL(String topic) throws PulsarAdminException;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a breaking change in the API,
code compiled for previous versions of Pulsar client will have to be re-compiled.
And also this is a behaviour change, recompiling is not enough to apply the new meaning of the value.
People who simply recompile will see NPE

I would not change this method and make it that returns the same value as before.
we are adding the new method and that will be the right way.
Here we have to add a javadoc that explains the meaning of the result,
we could also deprecate this method

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Methods with the same parameters and names cannot coexist. This is a problem left over from history. If we want to switch completely smoothly, we can add interfaces like admin.topicsV2(), admin.namespaceV2()...

If we modify the interface directly, users will know when upgrading the SDK(It will definitely trigger a recompilation when upgrading the SDK), we need to improve the doc of each interface, clarify the meaning of each return value

Please take a look here @sijie @codelipenghui

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eolivelli This method is introduced in 2.7.0(topic level policy) and I think this is a mistake in 2.7.0, most of the get policy method are returned Integer or Long, and the old behavior is the wrong behavior. I think we can clarify it in the release doc, I prefer to fix it directly. If left this method for future releases, users might be confused more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must pay more attention to public APIs, this kind of changes will hurt users, probably someone will get an unexpected NPE

I would accept to change the signature for a 2.8. release, but please do not cherry pick this change to 2.7 branch.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

topic policy is a newer feature that is not advertised as a stable change yet in 2.7.0. I think we should fix the bad behavior in the 2.7.x release.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is different from breaking a change that is introduced in old versions than 2.7.x.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see.
let's fix it for 2.7.x

@sijie

sijie commented Jan 19, 2021

Copy link
Copy Markdown
Member

Also I would rename 'applied' to 'actual'

"actual" is a confusing word. What does "actual" mean? Is it an "actual" value of the topic or a different thing?

"applied" or "merged" is better than "actual".

@eolivelli

Copy link
Copy Markdown
Contributor

Also I would rename 'applied' to 'actual'

"actual" is a confusing word. What does "actual" mean? Is it an "actual" value of the topic or a different thing?

"applied" or "merged" is better than "actual".

what about 'mergedWithDefaults', or 'defaultsApplied' ?

not a big deal for me, I was just suggesting a word that was more meaningful for me

@315157973

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@sijie

sijie commented Jan 19, 2021

Copy link
Copy Markdown
Member

what about 'mergedWithDefaults', or 'defaultsApplied' ?

"withDefaults" doesn't work in this case. Because there are multiple layers, it merged namespace-level and broker-level configs together. Hence "merged" or "applied" works there.

@Jennifer88huang-zz

Jennifer88huang-zz commented Jan 19, 2021 •

Copy link
Copy Markdown
Contributor

@315157973 what's the impact on docs? or what's the impact on end users?

@315157973

Copy link
Copy Markdown
Contributor Author

@315157973 what's the impact on docs? or what's the impact on end users?

Need to indicate the meaning of the return value
value == null: The default value, no parameters are set at this level
value == 0: This policy is disabled at this level
value> 0: Enable according to the set value

@315157973

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@Jennifer88huang-zz Jennifer88huang-zz added the doc-required Your PR changes impact docs and you will update later. label Jan 19, 2021
@Jennifer88huang-zz

Copy link
Copy Markdown
Contributor

@315157973 Thank you for your info.
Just confirm, in #9216, we have 14 commands, does the impact apply to all those cases? Is the impact same for all of them?

@315157973

Copy link
Copy Markdown
Contributor Author

@315157973 Thank you for your info.

Just confirm, in #9216, we have 14 commands, does the impact apply to all those cases? Is the impact same for all of them?

All will be unified soon.
For get method:
If applied=true, the topic will return the topic level policy if present or return the namespace policy if present or return the broker level configuration.

If applied=false, only return current level policy.the rules will be the same as the following:

value == null: The default value, no parameters are set at this level
value == 0: This policy is disabled at this level
value> 0: Enable according to the set value

@Jennifer88huang-zz

Copy link
Copy Markdown
Contributor

@315157973 Got it, thank you very much for your detailed explanation.
We can add the related doc content when you unify them.

@315157973

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

2 similar comments
@315157973

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@315157973

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@codelipenghui
codelipenghui merged commit 54b083b into apache:master Jan 20, 2021
@315157973
315157973 deleted the MessageTTL branch February 23, 2021 13:01
@Anonymitaet

Copy link
Copy Markdown
Member

@315157973 thanks for your great work! Shall the changes be added to the Admin API - Topics section? If so, could you please help add docs accordingly? Thanks

@315157973

Copy link
Copy Markdown
Contributor Author

@315157973 thanks for your great work! Shall the changes be added to the Admin API - Topics section? If so, could you please help add docs accordingly? Thanks

When #9216 is over, I will add all the documents.

@Anonymitaet

Copy link
Copy Markdown
Member

@315157973 thanks! You can ping me if you need a doc review.

@Anonymitaet

Copy link
Copy Markdown
Member

Docs have been added to source code files.

@Anonymitaet Anonymitaet removed the doc-required Your PR changes impact docs and you will update later. label Apr 15, 2021
eolivelli pushed a commit to datastax/pulsar that referenced this pull request May 24, 2021
Master Issue: apache#9216

Provide a way to get the applied policy of the topic. In Pulsar, the topic will apply the topic level policy if present or apply the namespace policy if present or use the broker level configuration. It needs to support get the applied policy for a topic that might use the namespace policy or topic policy or broker level default configuration.

1 Now if there is no data at the namespace-level, the broker-level data will be returned by default, so I fix it
2 Now if there is no data at the topic-level, the data at the namespace-level will be returned by default, so I fix it
3 Add applied interface
4 Since the initial value becomes null, the corresponding unit test is modified

(cherry picked from commit 54b083b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants