use of org.apache.pulsar.common.naming.TopicName in project incubator-pulsar by apache.
the class NonPersistentTopicsImpl method getStatsAsync.
@Override
public CompletableFuture<NonPersistentTopicStats> getStatsAsync(String topic) {
TopicName topicName = validateTopic(topic);
final CompletableFuture<NonPersistentTopicStats> future = new CompletableFuture<>();
WebTarget path = topicPath(topicName, "stats");
asyncGetRequest(path, new InvocationCallback<NonPersistentTopicStats>() {
@Override
public void completed(NonPersistentTopicStats response) {
future.complete(response);
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
use of org.apache.pulsar.common.naming.TopicName in project incubator-pulsar by apache.
the class PersistentTopicsImpl method getSubscriptionsAsync.
@Override
public CompletableFuture<List<String>> getSubscriptionsAsync(String topic) {
TopicName tn = validateTopic(topic);
WebTarget path = topicPath(tn, "subscriptions");
final CompletableFuture<List<String>> future = new CompletableFuture<>();
asyncGetRequest(path, new InvocationCallback<List<String>>() {
@Override
public void completed(List<String> response) {
future.complete(response);
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
use of org.apache.pulsar.common.naming.TopicName in project incubator-pulsar by apache.
the class PersistentTopicsImpl method getPartitionedTopicMetadataAsync.
@Override
public CompletableFuture<PartitionedTopicMetadata> getPartitionedTopicMetadataAsync(String topic) {
TopicName tn = validateTopic(topic);
WebTarget path = topicPath(tn, "partitions");
final CompletableFuture<PartitionedTopicMetadata> future = new CompletableFuture<>();
asyncGetRequest(path, new InvocationCallback<PartitionedTopicMetadata>() {
@Override
public void completed(PartitionedTopicMetadata response) {
future.complete(response);
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
use of org.apache.pulsar.common.naming.TopicName in project incubator-pulsar by apache.
the class PersistentTopicsImpl method peekNthMessage.
private CompletableFuture<List<Message<byte[]>>> peekNthMessage(String topic, String subName, int messagePosition) {
TopicName tn = validateTopic(topic);
String encodedSubName = Codec.encode(subName);
WebTarget path = topicPath(tn, "subscription", encodedSubName, "position", String.valueOf(messagePosition));
final CompletableFuture<List<Message<byte[]>>> future = new CompletableFuture<>();
asyncGetRequest(path, new InvocationCallback<Response>() {
@Override
public void completed(Response response) {
try {
future.complete(getMessageFromHttpResponse(response));
} catch (Exception e) {
future.completeExceptionally(getApiException(e));
}
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
use of org.apache.pulsar.common.naming.TopicName in project incubator-pulsar by apache.
the class PersistentTopicsImpl method expireMessagesForAllSubscriptionsAsync.
@Override
public CompletableFuture<Void> expireMessagesForAllSubscriptionsAsync(String topic, long expireTimeInSeconds) {
TopicName tn = validateTopic(topic);
WebTarget path = topicPath(tn, "all_subscription", "expireMessages", String.valueOf(expireTimeInSeconds));
return asyncPostRequest(path, Entity.entity("", MediaType.APPLICATION_JSON));
}
Aggregations