shibd commented on code in PR #22762:
URL: https://github.com/apache/pulsar/pull/22762#discussion_r1616464665
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java:
##########
@@ -3079,6 +3083,14 @@ private Response generateResponseWithEntry(Entry entry)
throws IOException {
if (metadata.hasNullPartitionKey()) {
responseBuilder.header("X-Pulsar-null-partition-key",
metadata.isNullPartitionKey());
}
+ if (metadata.hasTxnidMostBits() && metadata.hasTxnidLeastBits()) {
+ TxnID txnID = new TxnID(metadata.getTxnidMostBits(),
metadata.getTxnidLeastBits());
+ boolean isTxnAborted = persistentTopic.isTxnAborted(txnID,
(PositionImpl) entry.getPosition());
+ responseBuilder.header("X-Pulsar-txn-aborted", isTxnAborted);
+ }
+ boolean isTxnUncommitted = ((PositionImpl) entry.getPosition())
+ .compareTo(persistentTopic.getMaxReadPosition()) > 0;
+ responseBuilder.header("X-Pulsar-txn-uncommitted", isTxnUncommitted);
Review Comment:
The interface definitions for the `REST API` and the `admin CLI` are
different.
- [Admin
CLI](https://github.com/apache/pulsar/blob/8e82fd8b89b2fe50ed235775d186ba75eced5706/pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTopics.java#L1092)(and
[Admin
API](https://github.com/shibd/pulsar/blob/8e82fd8b89b2fe50ed235775d186ba75eced5706/pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/Topics.java#L1686-L1688)):
View recent N messages, and we now support the flag `--show-server-marker` and
`--transaction-isolation-level`.
- [REST
API](https://github.com/apache/pulsar/blob/a832d29e0eb6a0d687eef985d4247e846a1a8f3c/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v1/PersistentTopics.java#L813):
View the Nth message after the read position, which only returns one message.
In the implementation of the Admin CLI, the REST API is called [repeatedly
to
fetch](https://github.com/apache/pulsar/blob/8e82fd8b89b2fe50ed235775d186ba75eced5706/pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TopicsImpl.java#L929-L949)
the required number of messages. Therefore, for the REST API, we can avoid
adding the parameters `showServerMarker` and `transactionIsolationLevel`, and
instead, just mark the type of the message in the header returned, allowing the
caller to decide whether to use it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]