public CompletableFuture<PartitionedTopicMetadata> getPartitionedTopicMetadata(DestinationName destination) { return httpClient.get(String.format("admin/%s/partitions", destination.getLookupName()), PartitionedTopicMetadata.class); }
/** * Calls http-lookup api to find broker-service address which can serve a given topic. * * @param destination: topic-name * @return broker-socket-address that serves given topic */ @SuppressWarnings("deprecation") public CompletableFuture<InetSocketAddress> getBroker(DestinationName destination) { return httpClient.get(BasePath + destination.getLookupName(), LookupData.class).thenCompose(lookupData -> { // Convert LookupData into as SocketAddress, handling exceptions URI uri = null; try { if (useTls) { uri = new URI(lookupData.getBrokerUrlTls()); } else { String serviceUrl = lookupData.getBrokerUrl(); if (serviceUrl == null) { serviceUrl = lookupData.getNativeUrl(); } uri = new URI(serviceUrl); } return CompletableFuture.completedFuture(new InetSocketAddress(uri.getHost(), uri.getPort())); } catch (Exception e) { // Failed to parse url log.warn("[{}] Lookup Failed due to invalid url {}, {}", destination, uri, e.getMessage()); return FutureUtil.failedFuture(e); } }); }