use of org.apache.pulsar.common.policies.data.TransactionPendingAckStats in project pulsar by apache.
the class PendingAckHandleImpl method getStats.
@Override
public TransactionPendingAckStats getStats() {
TransactionPendingAckStats transactionPendingAckStats = new TransactionPendingAckStats();
transactionPendingAckStats.state = this.getState().name();
return transactionPendingAckStats;
}
use of org.apache.pulsar.common.policies.data.TransactionPendingAckStats in project pulsar by apache.
the class TransactionsImpl method getPendingAckStatsAsync.
@Override
public CompletableFuture<TransactionPendingAckStats> getPendingAckStatsAsync(String topic, String subName) {
WebTarget path = adminV3Transactions.path("pendingAckStats");
path = path.path(TopicName.get(topic).getRestPath(false));
path = path.path(subName);
final CompletableFuture<TransactionPendingAckStats> future = new CompletableFuture<>();
asyncGetRequest(path, new InvocationCallback<TransactionPendingAckStats>() {
@Override
public void completed(TransactionPendingAckStats stats) {
future.complete(stats);
}
@Override
public void failed(Throwable throwable) {
future.completeExceptionally(getApiException(throwable.getCause()));
}
});
return future;
}
use of org.apache.pulsar.common.policies.data.TransactionPendingAckStats in project pulsar by apache.
the class AdminApiTransactionTest method testGetPendingAckStats.
@Test(timeOut = 20000, dataProvider = "ackType")
public void testGetPendingAckStats(String ackType) throws Exception {
initTransaction(2);
final String topic = "persistent://public/default/testGetPendingAckStats";
final String subName = "test1";
admin.topics().createNonPartitionedTopic(topic);
Producer<byte[]> producer = pulsarClient.newProducer(Schema.BYTES).sendTimeout(0, TimeUnit.SECONDS).topic(topic).create();
Consumer<byte[]> consumer = pulsarClient.newConsumer(Schema.BYTES).topic(topic).subscriptionName(subName).subscribe();
TransactionPendingAckStats transactionPendingAckStats = admin.transactions().getPendingAckStatsAsync(topic, subName).get();
assertEquals(transactionPendingAckStats.state, "None");
producer.newMessage().value("Hello pulsar!".getBytes()).send();
TransactionImpl transaction = (TransactionImpl) getTransaction();
if (ackType.equals("individual")) {
consumer.acknowledgeAsync(consumer.receive().getMessageId(), transaction);
} else {
consumer.acknowledgeCumulativeAsync(consumer.receive().getMessageId(), transaction);
}
transaction.commit().get();
transactionPendingAckStats = admin.transactions().getPendingAckStatsAsync(topic, subName).get();
assertEquals(transactionPendingAckStats.state, "Ready");
}
Aggregations