public CompletableFuture<PartitionedTopicMetadata> getPartitionedTopicMetadata(DestinationName destination) { return httpClient.get(String.format("admin/%s/partitions", destination.getLookupName()), PartitionedTopicMetadata.class); }
private String doDestinationLookup(WebTarget lookupResource, DestinationName destName) throws PulsarAdminException { LookupData lookupData = request(lookupResource.path(destName.getLookupName())).get(LookupData.class); if (useTls) { return lookupData.getBrokerUrlTls(); } else { return lookupData.getBrokerUrl(); } }
/** * 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); } }); }
: result.getLookupData().getHttpUrl(); redirect = new URI(String.format("%s%s%s?authoritative=%s", redirectUrl, "/lookup/v2/destination/", topic.getLookupName(), newAuthoritative)); } catch (URISyntaxException e) { log.error("Error in preparing redirect url for {}: {}", topic, e.getMessage(), e);