lhotari commented on code in PR #24833:
URL: https://github.com/apache/pulsar/pull/24833#discussion_r2432238309
##########
pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/LookupProxyHandler.java:
##########
@@ -357,6 +358,62 @@ private void performGetTopicsOfNamespace(long
clientRequestId,
});
}
+ private void internalPerformGetTopicsOfNamespace(long clientRequestId,
String namespaceName, ClientCnx clientCnx,
+ ByteBuf command, long
requestId) {
+ BooleanSupplier isPermitRequestCancelled = () ->
!proxyConnection.ctx().channel().isActive();
+
maxTopicListInFlightLimiter.withAcquiredPermits(INITIAL_TOPIC_LIST_HEAP_PERMITS_SIZE,
+ AsyncDualMemoryLimiter.LimitType.HEAP_MEMORY,
isPermitRequestCancelled, initialPermits -> {
+ return clientCnx.newGetTopicsOfNamespace(command,
requestId).whenComplete((r, t) -> {
+ if (t != null) {
+ log.warn("[{}] Failed to get TopicsOfNamespace {}:
{}", clientAddress, namespaceName,
+ t.getMessage());
+ writeAndFlush(Commands.newError(clientRequestId,
getServerError(t), t.getMessage()));
+ } else {
+ long actualSize =
+
r.getNonPartitionedOrPartitionTopics().stream()
+ .mapToInt(ByteBufUtil::utf8Bytes)
// convert character count to bytes
+ .map(n -> n + 32) // add 32 bytes
overhead for each entry
Review Comment:
Sure, there's multiple ways to use the Streams API. I don't see why that
would be any better.
--
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]