You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/01/24 12:45:50 UTC
[GitHub] [pulsar] congbobo184 commented on a change in pull request #9284: [Pulsar Admin] Expose schema ledger in `topic stats-internal`
congbobo184 commented on a change in pull request #9284:
URL: https://github.com/apache/pulsar/pull/9284#discussion_r563287260
##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
##########
@@ -1774,14 +1776,71 @@ public TopicStats getStats(boolean getPreciseBacklog) {
cs.properties = cursor.getProperties();
stats.cursors.put(cursor.getName(), cs);
});
- if (futures != null) {
- FutureUtil.waitForAll(futures).handle((res, ex) -> {
- statFuture.complete(stats);
+
+ //Schema store ledgers
+ String schemaId;
+ try {
+ schemaId = TopicName.get(topic).getSchemaName();
+ } catch (Throwable t) {
+ statFuture.completeExceptionally(t);
+ return statFuture;
+ }
+
+
+ CompletableFuture<Void> schemaStoreLedgersFuture = new CompletableFuture<>();
+ stats.schemaLedgers = new ArrayList<>();
+ if (brokerService.getPulsar().getSchemaStorage() != null
+ && brokerService.getPulsar().getSchemaStorage() instanceof BookkeeperSchemaStorage) {
+ ((BookkeeperSchemaStorage) brokerService.getPulsar().getSchemaStorage())
+ .getStoreLedgerIdsBySchemaId(schemaId)
+ .thenAccept(ledgers -> {
+ List<CompletableFuture<Void>> getLedgerMetadataFutures = new ArrayList<>();
+ ledgers.forEach(ledgerId -> {
+ CompletableFuture<Void> completableFuture = new CompletableFuture<>();
+ getLedgerMetadataFutures.add(completableFuture);
+ brokerService.getPulsar().getBookKeeperClient()
+ .getLedgerMetadata(ledgerId)
+ .thenAccept(metadata -> {
+ LedgerInfo schemaLedgerInfo = new LedgerInfo();
+ schemaLedgerInfo.ledgerId = metadata.getLedgerId();
+ schemaLedgerInfo.entries = metadata.getLastEntryId() + 1;
+ schemaLedgerInfo.size = metadata.getLength();
+ if (includeLedgerMetadata) {
+ info.metadata = metadata.toSafeString();
+ }
+ stats.schemaLedgers.add(schemaLedgerInfo);
Review comment:
yes you are right, i will change this.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org