Java Code Examples for org.apache.pulsar.common.naming.TopicName#isV2()

The following examples show how to use org.apache.pulsar.common.naming.TopicName#isV2() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LookupImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<String> lookupTopicAsync(String topic) {
    TopicName topicName = TopicName.get(topic);
    String prefix = topicName.isV2() ? "/topic" : "/destination";
    WebTarget path = v2lookup.path(prefix).path(topicName.getLookupName());

    final CompletableFuture<String> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<LookupData>() {
                @Override
                public void completed(LookupData lookupData) {
                    if (useTls) {
                        future.complete(lookupData.getBrokerUrlTls());
                    } else {
                        future.complete(lookupData.getBrokerUrl());
                    }
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example 2
Source File: LookupImpl.java    From pulsar with Apache License 2.0 6 votes vote down vote up
@Override
public CompletableFuture<String> getBundleRangeAsync(String topic) {
    TopicName topicName = TopicName.get(topic);
    String prefix = topicName.isV2() ? "/topic" : "/destination";
    WebTarget path = v2lookup.path(prefix).path(topicName.getLookupName()).path("bundle");
    final CompletableFuture<String> future = new CompletableFuture<>();
    asyncGetRequest(path,
            new InvocationCallback<String>() {
                @Override
                public void completed(String bundleRange) {
                    future.complete(bundleRange);
                }

                @Override
                public void failed(Throwable throwable) {
                    future.completeExceptionally(getApiException(throwable.getCause()));
                }
            });
    return future;
}
 
Example 3
Source File: HttpLookupService.java    From pulsar with Apache License 2.0 4 votes vote down vote up
public CompletableFuture<PartitionedTopicMetadata> getPartitionedTopicMetadata(TopicName topicName) {
    String format = topicName.isV2() ? "admin/v2/%s/partitions" : "admin/%s/partitions";
    return httpClient.get(String.format(format, topicName.getLookupName()) + "?checkAllowAutoCreation=true",
            PartitionedTopicMetadata.class);
}