-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[improve][broker] Improve retention
endpoint to pure async.
#17496
Closed
Closed
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bc88b9c
Step commit
mattisonchao 70bbd6d
Step commmit
mattisonchao 613d851
Fix compile error
mattisonchao e461e80
Avoid pass asyncResponse to param
mattisonchao 13b27fe
Refactor name
mattisonchao 069521f
rollback some logic
mattisonchao c3b0d95
Move validation in to method.
mattisonchao 9c0e7df
fix async
mattisonchao 6148df4
Fix test
mattisonchao 3269135
Catch exception
mattisonchao d993a34
Merge branch 'master' into pip_149_13
mattisonchao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1195,12 +1195,16 @@ public void getRetention(@Suspended final AsyncResponse asyncResponse, | |
@PathParam("namespace") String namespace) { | ||
validateNamespaceName(property, cluster, namespace); | ||
validateNamespacePolicyOperationAsync(namespaceName, PolicyName.RETENTION, PolicyOperation.READ) | ||
.thenCompose(__ -> getNamespacePoliciesAsync(namespaceName)) | ||
.thenAccept(policies -> asyncResponse.resume(policies.retention_policies)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why need to change this? |
||
.thenCompose(__ -> namespaceResources().getPoliciesAsync(namespaceName)) | ||
.thenApply(policiesOpt -> { | ||
Policies policies = policiesOpt.orElseThrow(() -> new RestException(Response.Status.NOT_FOUND, | ||
"Namespace policies does not exist")); | ||
return policies.retention_policies; | ||
}).thenAccept(asyncResponse::resume) | ||
.exceptionally(ex -> { | ||
log.error("[{}] Failed to get retention config on a namespace {}", clientAppId(), namespaceName, | ||
ex); | ||
resumeAsyncResponseExceptionally(asyncResponse, ex); | ||
log.error("[{}] Failed to get retention config on a namespace {}", | ||
clientAppId(), namespaceName, ex); | ||
return null; | ||
}); | ||
} | ||
|
@@ -1212,10 +1216,22 @@ public void getRetention(@Suspended final AsyncResponse asyncResponse, | |
@ApiResponse(code = 404, message = "Namespace does not exist"), | ||
@ApiResponse(code = 409, message = "Concurrent modification"), | ||
@ApiResponse(code = 412, message = "Retention Quota must exceed backlog quota") }) | ||
public void setRetention(@PathParam("property") String property, @PathParam("cluster") String cluster, | ||
public void setRetention( | ||
@Suspended final AsyncResponse asyncResponse, | ||
@PathParam("property") String property, @PathParam("cluster") String cluster, | ||
@PathParam("namespace") String namespace, RetentionPolicies retention) { | ||
validateNamespaceName(property, cluster, namespace); | ||
internalSetRetention(retention); | ||
internalSetRetentionAsync(retention) | ||
.thenAccept(__ -> { | ||
asyncResponse.resume(Response.noContent().build()); | ||
log.info("[{}] Successfully updated retention configuration: namespace={}, map={}", clientAppId(), | ||
namespaceName, retention); | ||
}).exceptionally(ex -> { | ||
resumeAsyncResponseExceptionally(asyncResponse, ex); | ||
log.error("[{}] Failed to update retention configuration for namespace {}", | ||
clientAppId(), namespaceName, ex); | ||
return null; | ||
}); | ||
} | ||
|
||
@POST | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Maybe we can delete this method.