Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Transaction] Transaction admin api get transaction metadata #10690

Conversation

congbobo184
Copy link
Contributor

@congbobo184 congbobo184 commented May 24, 2021

Motivation

Transaction add admin api getTransactionMetadata

implement

@Data
public class TransactionMetadata {

    /** The txnId of this transaction. */
    public String txnId;

    /** The status of this transaction. */
    public String status;

    /** The open time of this transaction. */
    public long openTimestamp;

    /** The timeout of this transaction. */
    public long timeoutAt;

    /** The producedPartitions of this transaction. */
    public Map<String, TransactionInBufferStats> producedPartitions;

    /** The ackedPartitions of this transaction. */
    public Map<String, Map<String, TransactionInPendingAckStats>> ackedPartitions;
}

Verifying this change

Add the tests for it

Does this pull request potentially affect one of the following parts:
If yes was chosen, please highlight the changes

Dependencies (does it add or upgrade a dependency): (no)
The public API: (no)
The schema: (no)
The default values of configurations: (no)
The wire protocol: (no)
The rest endpoints: (no)
The admin cli options: (yes)
Anything that affects deployment: (no)

congbo added 17 commits May 19, 2021 16:54
…_admin_api

# Conflicts:
#	pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
…nto congbobo184_transaction_admin_api_transaction_in_pendingack_stats
…nto congbobo184_transaction_admin_api_transaction_in_pendingack_stats
…ion_in_pendingack_stats

# Conflicts:
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/TransactionsBase.java
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Transactions.java
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
#	pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v3/AdminApiTransactionTest.java
#	pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/Transactions.java
#	pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TransactionsImpl.java
#	pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
#	pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTransactions.java
…ongbobo184_transaction_admin_api_get_transaction_status
@congbobo184 congbobo184 added this to the 2.8.0 milestone May 24, 2021
@congbobo184 congbobo184 added the type/bug The PR fixed a bug or issue reported a bug label May 24, 2021
@congbobo184 congbobo184 self-assigned this May 24, 2021
…saction_status

# Conflicts:
#	pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v3/Transactions.java
#	pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/v3/AdminApiTransactionTest.java
#	pulsar-client-admin-api/src/main/java/org/apache/pulsar/client/admin/Transactions.java
#	pulsar-client-admin/src/main/java/org/apache/pulsar/client/admin/internal/TransactionsImpl.java
#	pulsar-client-tools-test/src/test/java/org/apache/pulsar/admin/cli/PulsarAdminToolTest.java
#	pulsar-client-tools/src/main/java/org/apache/pulsar/admin/cli/CmdTransactions.java
Transactions transactions = pulsar().getAdminClient().transactions();
TxnMeta txnMeta = pulsar().getTransactionMetadataStoreService()
.getTxnMeta(new TxnID(coordinatorId, sequenceID)).get();
TxnID txnID = txnMeta.id();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will introduce NPE here.

public CmdTransactions(Supplier<PulsarAdmin> admin) {
super("transactions", admin);
jcommander.addCommand("coordinator-status", new GetCoordinatorStatus());
jcommander.addCommand("transaction-in-buffer-stats", new GetTransactionInBufferStats());
jcommander.addCommand("transaction-in-pending-ack-stats", new GetTransactionInPendingAckStats());
jcommander.addCommand("transaction-status", new GetTransactionStatus());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use transaction-metadata here since we are using a transaction ID to fetch all transaction metadata through this command.

@@ -117,7 +117,7 @@ public synchronized void registerSendOp(CompletableFuture<MessageId> sendFuture)
return checkIfOpen().thenCompose(value -> {
synchronized (TransactionImpl.this) {
// we need to issue the request to TC to register the acked topic
return registerSubscriptionMap.compute(topic, (key, future) -> {
return registerSubscriptionMap.compute(topic + "-" + subscription, (key, future) -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems not related to this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test will use

congbo added 2 commits May 24, 2021 23:47
@congbobo184 congbobo184 added the doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. label May 25, 2021
congbo added 2 commits May 25, 2021 09:23
…ongbobo184_transaction_admin_api_get_transaction_status
…/admin/Transactions.java

Co-authored-by: Yu Liu <50226895+Anonymitaet@users.noreply.github.com>
@congbobo184 congbobo184 removed the type/bug The PR fixed a bug or issue reported a bug label May 25, 2021
@congbobo184 congbobo184 changed the title [Transaction] Transaction admin api get transaction status [Transaction] Transaction admin api get transaction metadata May 25, 2021
@codelipenghui codelipenghui merged commit fa0a1c1 into apache:master May 25, 2021
yangl pushed a commit to yangl/pulsar that referenced this pull request Jun 23, 2021
…10690)

## Motivation
Transaction add admin api `getTransactionMetadata`

## implement
```
@DaTa
public class TransactionMetadata {

    /** The txnId of this transaction. */
    public String txnId;

    /** The status of this transaction. */
    public String status;

    /** The open time of this transaction. */
    public long openTimestamp;

    /** The timeout of this transaction. */
    public long timeoutAt;

    /** The producedPartitions of this transaction. */
    public Map<String, TransactionInBufferStats> producedPartitions;

    /** The ackedPartitions of this transaction. */
    public Map<String, Map<String, TransactionInPendingAckStats>> ackedPartitions;
}
```
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
…10690)

## Motivation
Transaction add admin api `getTransactionMetadata`

## implement
```
@DaTa
public class TransactionMetadata {

    /** The txnId of this transaction. */
    public String txnId;

    /** The status of this transaction. */
    public String status;

    /** The open time of this transaction. */
    public long openTimestamp;

    /** The timeout of this transaction. */
    public long timeoutAt;

    /** The producedPartitions of this transaction. */
    public Map<String, TransactionInBufferStats> producedPartitions;

    /** The ackedPartitions of this transaction. */
    public Map<String, Map<String, TransactionInPendingAckStats>> ackedPartitions;
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Your PR contains doc changes, no matter whether the changes are in markdown or code files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants