|
51 | 51 | import org.apache.pulsar.broker.PulsarServerException;
|
52 | 52 | import org.apache.pulsar.broker.service.Topic;
|
53 | 53 | import org.apache.pulsar.broker.web.RestException;
|
54 |
| -import org.apache.pulsar.common.naming.NamespaceBundle; |
55 | 54 | import org.apache.pulsar.common.naming.TopicName;
|
56 | 55 | import org.apache.pulsar.common.policies.data.EntryFilters;
|
57 | 56 | import org.apache.pulsar.common.policies.data.NamespaceOperation;
|
@@ -449,35 +448,35 @@ public void getListFromBundle(
|
449 | 448 | bundleRange);
|
450 | 449 | asyncResponse.resume(Response.noContent().build());
|
451 | 450 | } else {
|
452 |
| - NamespaceBundle nsBundle; |
453 |
| - try { |
454 |
| - nsBundle = validateNamespaceBundleOwnership(namespaceName, policies.bundles, |
455 |
| - bundleRange, true, true); |
456 |
| - } catch (WebApplicationException wae) { |
457 |
| - asyncResponse.resume(wae); |
458 |
| - return; |
459 |
| - } |
460 |
| - try { |
461 |
| - ConcurrentOpenHashMap<String, ConcurrentOpenHashMap<String, Topic>> bundleTopics = |
462 |
| - pulsar().getBrokerService().getMultiLayerTopicsMap().get(namespaceName.toString()); |
463 |
| - if (bundleTopics == null || bundleTopics.isEmpty()) { |
464 |
| - asyncResponse.resume(Collections.emptyList()); |
465 |
| - return; |
466 |
| - } |
467 |
| - final List<String> topicList = new ArrayList<>(); |
468 |
| - String bundleKey = namespaceName.toString() + "/" + nsBundle.getBundleRange(); |
469 |
| - ConcurrentOpenHashMap<String, Topic> topicMap = bundleTopics.get(bundleKey); |
470 |
| - if (topicMap != null) { |
471 |
| - topicList.addAll(topicMap.keys().stream() |
472 |
| - .filter(name -> !TopicName.get(name).isPersistent()) |
473 |
| - .collect(Collectors.toList())); |
474 |
| - } |
475 |
| - asyncResponse.resume(topicList); |
476 |
| - } catch (Exception e) { |
477 |
| - log.error("[{}] Failed to list topics on namespace bundle {}/{}", clientAppId(), |
478 |
| - namespaceName, bundleRange, e); |
479 |
| - asyncResponse.resume(new RestException(e)); |
480 |
| - } |
| 451 | + validateNamespaceBundleOwnershipAsync(namespaceName, policies.bundles, bundleRange, true, true) |
| 452 | + .thenAccept(nsBundle -> { |
| 453 | + ConcurrentOpenHashMap<String, ConcurrentOpenHashMap<String, Topic>> bundleTopics = |
| 454 | + pulsar().getBrokerService() |
| 455 | + .getMultiLayerTopicsMap().get(namespaceName.toString()); |
| 456 | + if (bundleTopics == null || bundleTopics.isEmpty()) { |
| 457 | + asyncResponse.resume(Collections.emptyList()); |
| 458 | + return; |
| 459 | + } |
| 460 | + final List<String> topicList = new ArrayList<>(); |
| 461 | + String bundleKey = namespaceName.toString() + "/" + nsBundle.getBundleRange(); |
| 462 | + ConcurrentOpenHashMap<String, Topic> topicMap = bundleTopics.get(bundleKey); |
| 463 | + if (topicMap != null) { |
| 464 | + topicList.addAll(topicMap.keys().stream() |
| 465 | + .filter(name -> !TopicName.get(name).isPersistent()) |
| 466 | + .collect(Collectors.toList())); |
| 467 | + } |
| 468 | + asyncResponse.resume(topicList); |
| 469 | + }).exceptionally(ex -> { |
| 470 | + Throwable realCause = FutureUtil.unwrapCompletionException(ex); |
| 471 | + log.error("[{}] Failed to list topics on namespace bundle {}/{}", clientAppId(), |
| 472 | + namespaceName, bundleRange, realCause); |
| 473 | + if (realCause instanceof WebApplicationException) { |
| 474 | + asyncResponse.resume(realCause); |
| 475 | + } else { |
| 476 | + asyncResponse.resume(new RestException(realCause)); |
| 477 | + } |
| 478 | + return null; |
| 479 | + }); |
481 | 480 | }
|
482 | 481 | }).exceptionally(ex -> {
|
483 | 482 | log.error("[{}] Failed to list topics on namespace bundle {}/{}", clientAppId(),
|
|
0 commit comments