hangc0276 commented on a change in pull request #12215:
URL: https://github.com/apache/pulsar/pull/12215#discussion_r726045295
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java
##########
@@ -969,21 +972,59 @@ public void unloadNamespaceBundlesGracefully() {
}
CompletableFuture<Void> future = new CompletableFuture<>();
- managedLedgerFactory.asyncDelete(tn.getPersistenceNamingEncoding(),
new DeleteLedgerCallback() {
- @Override
- public void deleteLedgerComplete(Object ctx) {
- future.complete(null);
- }
- @Override
- public void deleteLedgerFailed(ManagedLedgerException exception,
Object ctx) {
- future.completeExceptionally(exception);
+ CompletableFuture<Void> deleteTopicAuthenticationFuture = new
CompletableFuture<>();
+ deleteTopicAuthenticationWithRetry(topic,
deleteTopicAuthenticationFuture, 5);
+ deleteTopicAuthenticationFuture.whenComplete((v, ex) -> {
+ if (ex != null) {
+ future.completeExceptionally(ex);
+ return;
}
- }, null);
+
managedLedgerFactory.asyncDelete(tn.getPersistenceNamingEncoding(), new
DeleteLedgerCallback() {
+ @Override
+ public void deleteLedgerComplete(Object ctx) {
+ future.complete(null);
+ }
+
+ @Override
+ public void deleteLedgerFailed(ManagedLedgerException
exception, Object ctx) {
+ future.completeExceptionally(exception);
+ }
+ }, null);
+ });
+
return future;
}
+ public void deleteTopicAuthenticationWithRetry(String topic,
CompletableFuture<Void> future, int count) {
+ if (count == 0) {
+ log.error("The number of retries has exhausted for topic {}",
topic);
+ future.completeExceptionally(new RuntimeException("The number of
retries has exhausted"));
Review comment:
Please avoid to use unchecked exception.
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java
##########
@@ -635,32 +636,47 @@ protected void
internalDeletePartitionedTopic(AsyncResponse asyncResponse, boole
return;
}
}
- // Only tries to delete the znode for partitioned topic when all
its partitions are successfully deleted
- try {
- namespaceResources().getPartitionedTopicResources()
- .deletePartitionedTopicAsync(topicName).thenAccept(r2
-> {
- log.info("[{}] Deleted partitioned topic {}",
clientAppId(), topicName);
- asyncResponse.resume(Response.noContent().build());
- }).exceptionally(ex1 -> {
- log.error("[{}] Failed to delete partitioned topic {}",
clientAppId(), topicName, ex1.getCause());
- if (ex1.getCause()
- instanceof
org.apache.pulsar.metadata.api.MetadataStoreException.NotFoundException) {
- asyncResponse.resume(new RestException(
- new RestException(Status.NOT_FOUND,
"Partitioned topic does not exist")));
- } else if (ex1
- .getCause()
- instanceof
org.apache.pulsar.metadata.api.MetadataStoreException.BadVersionException) {
- asyncResponse.resume(
- new RestException(new
RestException(Status.CONFLICT, "Concurrent modification")));
- } else {
- asyncResponse.resume(new
RestException((ex1.getCause())));
- }
- return null;
- });
- } catch (Exception e1) {
- log.error("[{}] Failed to delete partitioned topic {}",
clientAppId(), topicName, e1);
- asyncResponse.resume(new RestException(e1));
- }
+ // Only tries to delete the authentication policies for
partitioned topic when all its partitions are
+ // successfully deleted
+ CompletableFuture<Void> deleteTopicAuthenticationFuture = new
CompletableFuture<>();
+ pulsar().getBrokerService()
+ .deleteTopicAuthenticationWithRetry(topicName.toString(),
deleteTopicAuthenticationFuture, 5);
+ deleteTopicAuthenticationFuture.whenComplete((r1, ex1) -> {
+ if (ex1 != null) {
+ asyncResponse.resume(new RestException(ex1));
Review comment:
Please add error log for the authentication delete failed exception.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]