Skip to content
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

Conversation

HQebupt
Copy link
Contributor

@HQebupt HQebupt commented Jan 22, 2022

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 changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

Check the box below and label this PR (if you have committer privilege).

Need to update docs?

  • no-need-doc

@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Jan 22, 2022
@Jason918
Copy link
Contributor

/pulsarbot run-failure-checks

@HQebupt
Copy link
Contributor Author

HQebupt commented Jan 28, 2022

/pulsarbot run-failure-checks

1 similar comment
@HQebupt
Copy link
Contributor Author

HQebupt commented Jan 29, 2022

/pulsarbot run-failure-checks

@HQebupt
Copy link
Contributor Author

HQebupt commented Jan 29, 2022

@Jason918 @Technoboy- @liudezhi2098 @mattisonchao Pls take a look.

@HQebupt
Copy link
Contributor Author

HQebupt commented Jan 29, 2022

/pulsarbot run-failure-checks

1 similar comment
@HQebupt
Copy link
Contributor Author

HQebupt commented Jan 30, 2022

/pulsarbot run-failure-checks

@Jason918
Copy link
Contributor

Jason918 commented Feb 8, 2022

/pulsarbot run-failure-checks

Copy link
Member

@mattisonchao mattisonchao left a 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(),
Copy link
Member

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();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} 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);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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) -> {
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

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;
Copy link
Member

Choose a reason for hiding this comment

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

NPE?

});
}
}
return null;
Copy link
Member

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<>();
Copy link
Member

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.

@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@HQebupt HQebupt force-pushed the issue-13854-internalTruncateNonPartitionedTopic branch from d65be28 to f7065f6 Compare March 21, 2022 15:38
@github-actions
Copy link

The pr had no activity for 30 days, mark with Stale label.

@github-actions github-actions bot added the Stale label May 28, 2022
@HQebupt HQebupt closed this Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs lifecycle/stale Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants