public void invalidateOfflineTopicStatCache(DestinationName topicName) { PersistentOfflineTopicStats removed = offlineTopicStatCache.remove(topicName); if (removed != null) { log.info("Removed cached offline topic stat for {} ", topicName.getPersistenceNamingEncoding()); } }
@GET @Path("{property}/{cluster}/{namespace}/{destination}/internal-info") @ApiOperation(value = "Get the internal stats for the topic.") @ApiResponses(value = { @ApiResponse(code = 403, message = "Don't have admin permission"), @ApiResponse(code = 404, message = "Topic does not exist") }) public void getManagedLedgerInfo(@PathParam("property") String property, @PathParam("cluster") String cluster, @PathParam("namespace") String namespace, @PathParam("destination") @Encoded String destination, @Suspended AsyncResponse asyncResponse) { destination = decode(destination); DestinationName dn = DestinationName.get(domain(), property, cluster, namespace, destination); validateAdminAccessOnProperty(dn.getProperty()); String managedLedger = dn.getPersistenceNamingEncoding(); pulsar().getManagedLedgerFactory().asyncGetManagedLedgerInfo(managedLedger, new ManagedLedgerInfoCallback() { @Override public void getInfoComplete(ManagedLedgerInfo info, Object ctx) { asyncResponse.resume((StreamingOutput) output -> { jsonMapper().writer().writeValue(output, info); }); } @Override public void getInfoFailed(ManagedLedgerException exception, Object ctx) { asyncResponse.resume(exception); } }, null); }
private void readLedgerMeta(final ManagedLedgerFactoryImpl factory, final DestinationName dn, final NavigableMap<Long, MLDataFormats.ManagedLedgerInfo.LedgerInfo> ledgers) throws Exception { String managedLedgerName = dn.getPersistenceNamingEncoding(); MetaStore store = factory.getMetaStore(); BookKeeper bk = factory.getBookKeeper();
managedLedgerFactory.asyncOpen(destinationName.getPersistenceNamingEncoding(), config, new OpenLedgerCallback() { @Override
public PersistentOfflineTopicStats estimateUnloadedTopicBacklog(ManagedLedgerFactoryImpl factory, DestinationName dn) throws Exception { String managedLedgerName = dn.getPersistenceNamingEncoding(); long numberOfEntries = 0; long totalSize = 0; final NavigableMap<Long, MLDataFormats.ManagedLedgerInfo.LedgerInfo> ledgers = new ConcurrentSkipListMap<>(); final PersistentOfflineTopicStats offlineTopicStats = new PersistentOfflineTopicStats(managedLedgerName, brokerName); // calculate total managed ledger size and number of entries without loading the topic readLedgerMeta(factory, dn, ledgers); for (MLDataFormats.ManagedLedgerInfo.LedgerInfo ls : ledgers.values()) { numberOfEntries += ls.getEntries(); totalSize += ls.getSize(); if (accurate) { offlineTopicStats.addLedgerDetails(ls.getEntries(), ls.getTimestamp(), ls.getSize(), ls.getLedgerId()); } } offlineTopicStats.totalMessages = numberOfEntries; offlineTopicStats.storageSize = totalSize; if (log.isDebugEnabled()) { log.debug("[{}] Total number of entries - {} and size - {}", managedLedgerName, numberOfEntries, totalSize); } // calculate per cursor message backlog calculateCursorBacklogs(factory, dn, ledgers, offlineTopicStats); offlineTopicStats.statGeneratedAt.setTime(System.currentTimeMillis()); return offlineTopicStats; }
return; String managedLedgerName = dn.getPersistenceNamingEncoding(); MetaStore store = factory.getMetaStore(); BookKeeper bk = factory.getBookKeeper();
final String ledgerName = dn.getPartition(1).getPersistenceNamingEncoding(); ((ManagedLedgerFactoryImpl) pulsar().getManagedLedgerFactory()).getMetaStore().getCursors(ledgerName, new MetaStoreCallback<List<String>>() {