-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Support get topic applied policy for message TTL #9225
Conversation
/pulsarbot run-failure-checks |
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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.
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/Topics.java
Outdated
Show resolved
Hide resolved
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TopicsImpl.java
Outdated
Show resolved
Hide resolved
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TopicsImpl.java
Outdated
Show resolved
Hide resolved
pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java
Outdated
Show resolved
Hide resolved
pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TopicsImpl.java
Show resolved
Hide resolved
…in/internal/TopicsImpl.java Co-authored-by: Yong Zhang <zhangyong1025.zy@gmail.com>
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
There was a problem hiding this comment.
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'
@@ -1604,7 +1604,15 @@ void setDelayedDeliveryPolicy(String topic | |||
* @throws PulsarAdminException | |||
* Unexpected error | |||
*/ | |||
int getMessageTTL(String topic) throws PulsarAdminException; | |||
Integer getMessageTTL(String topic) throws PulsarAdminException; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
"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 |
/pulsarbot run-failure-checks |
"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. |
@315157973 what's the impact on docs? or what's the impact on end users? |
Need to indicate the meaning of the return value |
/pulsarbot run-failure-checks |
@315157973 Thank you for your info. |
All will be unified soon. 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 |
@315157973 Got it, thank you very much for your detailed explanation. |
/pulsarbot run-failure-checks |
2 similar comments
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
@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. |
@315157973 thanks! You can ping me if you need a doc review. |
Docs have been added to source code files. |
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)
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