use of org.apache.pulsar.common.naming.TopicName in project incubator-pulsar by apache.
the class PersistentTopicsImpl method getPartitionedStatsAsync.
@Override
public CompletableFuture<PartitionedTopicStats> getPartitionedStatsAsync(String topic, boolean perPartition) {
TopicName tn = validateTopic(topic);
WebTarget path = topicPath(tn, "partitioned-stats");
final CompletableFuture<PartitionedTopicStats> future = new CompletableFuture<>();
asyncGetRequest(path, new InvocationCallback<PartitionedTopicStats>() {
@Override
public void completed(PartitionedTopicStats response) {
if (!perPartition) {
response.partitions.clear();
}
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 getStatsAsync.
@Override
public CompletableFuture<PersistentTopicStats> getStatsAsync(String topic) {
TopicName tn = validateTopic(topic);
WebTarget path = topicPath(tn, "stats");
final CompletableFuture<PersistentTopicStats> future = new CompletableFuture<>();
asyncGetRequest(path, new InvocationCallback<PersistentTopicStats>() {
@Override
public void completed(PersistentTopicStats 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 terminateTopicAsync.
@Override
public CompletableFuture<MessageId> terminateTopicAsync(String topic) {
TopicName tn = validateTopic(topic);
final CompletableFuture<MessageId> future = new CompletableFuture<>();
try {
final WebTarget path = topicPath(tn, "terminate");
request(path).async().post(Entity.entity("", MediaType.APPLICATION_JSON), new InvocationCallback<MessageIdImpl>() {
@Override
public void completed(MessageIdImpl messageId) {
future.complete(messageId);
}
@Override
public void failed(Throwable throwable) {
log.warn("[{}] Failed to perform http post request: {}", path.getUri(), throwable.getMessage());
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
} catch (PulsarAdminException cae) {
future.completeExceptionally(cae);
}
return future;
}
use of org.apache.pulsar.common.naming.TopicName in project incubator-pulsar by apache.
the class PersistentTopicsImpl method resetCursor.
@Override
public void resetCursor(String topic, String subName, MessageId messageId) throws PulsarAdminException {
try {
TopicName tn = validateTopic(topic);
String encodedSubName = Codec.encode(subName);
WebTarget path = topicPath(tn, "subscription", encodedSubName, "resetcursor");
request(path).post(Entity.entity(messageId, MediaType.APPLICATION_JSON), ErrorData.class);
} catch (Exception e) {
throw getApiException(e);
}
}
use of org.apache.pulsar.common.naming.TopicName in project incubator-pulsar by apache.
the class PersistentTopicsImpl method createSubscriptionAsync.
@Override
public CompletableFuture<Void> createSubscriptionAsync(String topic, String subscriptionName, MessageId messageId) {
TopicName tn = validateTopic(topic);
String encodedSubName = Codec.encode(subscriptionName);
WebTarget path = topicPath(tn, "subscription", encodedSubName);
return asyncPutRequest(path, Entity.entity(messageId, MediaType.APPLICATION_JSON));
}
Aggregations