Repository navigation
Allow ability to specify retain key ordering in functions - #7647
Conversation
| functionConfig.setRetainOrdering(true); | ||
| functionConfig.setRetainKeyOrdering(false); | ||
| functionConfig.setProcessingGuarantees(FunctionConfig.ProcessingGuarantees.EFFECTIVELY_ONCE); | ||
| } else if (functionDetails.getSource().getSubscriptionType() == Function.SubscriptionType.KEY_SHARED) { |
There was a problem hiding this comment.
We also need to do this in SinkConfigUtils
There was a problem hiding this comment.
That can be added later.
| } else if (functionDetails.getSource().getSubscriptionType() == Function.SubscriptionType.KEY_SHARED) { | ||
| functionConfig.setRetainOrdering(false); | ||
| functionConfig.setRetainKeyOrdering(true); | ||
| functionConfig.setProcessingGuarantees(FunctionConfig.ProcessingGuarantees.ATLEAST_ONCE); |
There was a problem hiding this comment.
Why are we assuming ATLEAST_ONCE here? A user can set the processing guarantee to be at most once and still set the retain ordering to be true
There was a problem hiding this comment.
Yes. Even the existing code is broken in that regard. I will fix that
| Function.SubscriptionType subType = ((functionConfig.getRetainOrdering() != null && functionConfig.getRetainOrdering()) | ||
| || FunctionConfig.ProcessingGuarantees.EFFECTIVELY_ONCE.equals(functionConfig.getProcessingGuarantees())) | ||
| ? Function.SubscriptionType.FAILOVER | ||
| : (functionConfig.getRetainKeyOrdering() != null && functionConfig.getRetainKeyOrdering()) |
There was a problem hiding this comment.
Can we re-organize this giant conditional statement to be more readable?
if (effectively-once) {
subType = Failover
} else if (retain order) {
subType = failover
} else if (retain key order) {
subType = shared_key
} else {
subType = shared
}
| throw new IllegalArgumentException("Dead Letter Topic specified, however max retries is set to infinity"); | ||
| } | ||
| if (functionConfig.getRetainKeyOrdering() != null | ||
| && functionConfig.getRetainKeyOrdering() |
There was a problem hiding this comment.
I would remove this stanza. We should return an error if the retain order or retain key ordering is set at all
There was a problem hiding this comment.
Can you also check whether retain ordering is set?
| private String logTopic; | ||
| private ProcessingGuarantees processingGuarantees; | ||
| private Boolean retainOrdering; | ||
| private Boolean retainKeyOrdering; |
There was a problem hiding this comment.
Can we add some comments here for retainOrdering and retainKeyOrdering so people understand what they do and what the difference between the two is?
There was a problem hiding this comment.
also need to add this for SinkConfig
| @@ -317,9 +319,15 @@ public static FunctionConfig convertFromDetails(FunctionDetails functionDetails) | |||
| } | |||
| if (functionDetails.getSource().getSubscriptionType() == Function.SubscriptionType.FAILOVER) { | |||
There was a problem hiding this comment.
This whole conditional statement doesn't seem right to me. Why are se setting the processing guarantee by looking at what the subscription is? We already setting the processing guarantee in a previous line:
|
@jerrypeng addressed your comments. PTAL |
* Allow ability to specify retain key ordering in functions * Address comments Co-authored-by: Sanjeev Kulkarni <[email protected]> (cherry picked from commit ff4c3f6)
* Allow ability to specify retain key ordering in functions * Address comments Co-authored-by: Sanjeev Kulkarni <[email protected]>
* Allow ability to specify retain key ordering in functions * Address comments Co-authored-by: Sanjeev Kulkarni <[email protected]>
Signed-off-by: xiaolong.ran <[email protected]> Fixes #6527 ### Motivation We already support `key_shared` mode on Pulsar Functions in #7647, However, this option is not exposed in the command line parameters, so users currently cannot use this function. ### Modifications In this pull request, we expose this cmd flag of `--retain-key-ordering` and add the docs for this. ### Verifying this change The original test can cover this option, so, in this change, no relevant code is added
Signed-off-by: xiaolong.ran <[email protected]> Fixes apache#6527 ### Motivation We already support `key_shared` mode on Pulsar Functions in apache#7647, However, this option is not exposed in the command line parameters, so users currently cannot use this function. ### Modifications In this pull request, we expose this cmd flag of `--retain-key-ordering` and add the docs for this. ### Verifying this change The original test can cover this option, so, in this change, no relevant code is added (cherry picked from commit 8150da8)
Signed-off-by: xiaolong.ran <[email protected]> Fixes apache#6527 ### Motivation We already support `key_shared` mode on Pulsar Functions in apache#7647, However, this option is not exposed in the command line parameters, so users currently cannot use this function. ### Modifications In this pull request, we expose this cmd flag of `--retain-key-ordering` and add the docs for this. ### Verifying this change The original test can cover this option, so, in this change, no relevant code is added (cherry picked from commit 8150da8)
(If this PR fixes a github issue, please add
Fixes #<xyz>.)Fixes #
(or if this PR is one task of a github issue, please add
Master Issue: #<xyz>to link to the master issue.)Master Issue: #
Motivation
Just like retainOrdering, sometimes applications want to retain ordering over the message keys. This pr adds support to that.
Modifications
Describe the modifications you've done.
Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Does this pull request potentially affect one of the following parts:
If
yeswas chosen, please highlight the changesDocumentation