-
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
[Issue 13854][broker] Fix call sync method in async rest api for internalTruncateNonPartitionedTopic #13904
[Issue 13854][broker] Fix call sync method in async rest api for internalTruncateNonPartitionedTopic #13904
Conversation
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
Outdated
Show resolved
Hide resolved
3c8ee2b
to
612d1d4
Compare
/pulsarbot run-failure-checks |
pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
Show resolved
Hide resolved
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
pulsar-broker/src/main/java/org/apache/pulsar/broker/web/PulsarWebResource.java
Outdated
Show resolved
Hide resolved
@Jason918 @Technoboy- @liudezhi2098 @mattisonchao Pls take a look. |
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
/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.
I left some suggestion here, PTAL :-)
.thenCompose(__ -> getTopicReferenceAsync(topicName)) | ||
.thenCompose(topic -> topic.truncate()) | ||
.thenAccept(__ -> { | ||
asyncResponse.resume(new RestException(Response.Status.NO_CONTENT.getStatusCode(), |
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.
Why resume
Exception ?
getPartitionedTopicMetadataAsync(topicName, authoritative, false) | ||
.whenComplete((meta, t) -> { | ||
if (meta.partitions > 0) { | ||
final List<CompletableFuture<Void>> futures = Lists.newArrayList(); |
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.
final List<CompletableFuture<Void>> futures = Lists.newArrayList(); | |
final List<CompletableFuture<Void>> futures = Lists.newArrayList(meta.partitions); |
try { | ||
futures.add(pulsar().getAdminClient().topics() | ||
.truncateAsync(topicNamePartition.toString())); | ||
} catch (Exception e) { |
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.
} catch (Exception e) { | |
} catch (PulsarServerException e) { |
futures.add(pulsar().getAdminClient().topics() | ||
.truncateAsync(topicNamePartition.toString())); | ||
} catch (Exception e) { | ||
log.error("[{}] Failed to truncate topic {}", clientAppId(), topicNamePartition, e); |
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.
log.error("[{}] Failed to truncate topic {}", clientAppId(), topicNamePartition, e); | |
log.error("[{}] Failed to truncate topic, while getting admin client {}", clientAppId(), topicNamePartition, e); |
} | ||
FutureUtil.waitForAll(futures).handle((result, exception) -> { |
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.
Use whenComplete
instead of handle
or return this future to the upper layer future?
"Proxy not authorized to access resource (proxy:%s,original:%s)", | ||
clientAppId, originalPrincipal)); | ||
} | ||
return null; |
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.
NPE?
originalPrincipal, clientAppId, tenant); | ||
future.complete(null); | ||
} | ||
return null; |
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.
NPE?
log.debug("Successfully authorized {} on tenant {}", clientAppId, tenant); | ||
future.complete(null); | ||
} | ||
return null; |
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.
NPE?
}); | ||
} | ||
} | ||
return null; |
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.
NPE?
PulsarService pulsar, String clientAppId, | ||
String originalPrincipal, String tenant, | ||
AuthenticationDataSource authenticationData) { | ||
CompletableFuture<Void> future = new CompletableFuture<>(); |
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.
Could we use combine
or another method to avoid using global future that complete at a lot of methods? it's hard to read the code. I think.
The pr had no activity for 30 days, mark with Stale label. |
d65be28
to
f7065f6
Compare
The pr had no activity for 30 days, mark with Stale label. |
Master Issue: #13854
Motivation
See #13854
Verifying this change
Make sure that the change passes the CI checks.
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changesDocumentation
Check the box below and label this PR (if you have committer privilege).
Need to update docs?
no-need-doc