Search in sources :

Example 1 with TransactionNotFoundException

use of org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException.TransactionNotFoundException in project pulsar by apache.

the class InMemTransactionMetadataStore method getTxnMeta.

@Override
public CompletableFuture<TxnMeta> getTxnMeta(TxnID txnid) {
    CompletableFuture<TxnMeta> getFuture = new CompletableFuture<>();
    TxnMetaImpl txn = transactions.get(txnid);
    if (null == txn) {
        getFuture.completeExceptionally(new TransactionNotFoundException(txnid));
    } else {
        getFuture.complete(txn);
    }
    return getFuture;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) TransactionNotFoundException(org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException.TransactionNotFoundException) TxnMeta(org.apache.pulsar.transaction.coordinator.TxnMeta)

Example 2 with TransactionNotFoundException

use of org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException.TransactionNotFoundException in project pulsar by apache.

the class MLTransactionMetadataStore method getTxnPositionPair.

private CompletableFuture<Pair<TxnMeta, List<Position>>> getTxnPositionPair(TxnID txnID) {
    CompletableFuture<Pair<TxnMeta, List<Position>>> completableFuture = new CompletableFuture<>();
    Pair<TxnMeta, List<Position>> txnMetaListPair = txnMetaMap.get(txnID.getLeastSigBits());
    if (txnMetaListPair == null) {
        completableFuture.completeExceptionally(new TransactionNotFoundException(txnID));
    } else {
        completableFuture.complete(txnMetaListPair);
    }
    return completableFuture;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Position(org.apache.bookkeeper.mledger.Position) ArrayList(java.util.ArrayList) List(java.util.List) TransactionNotFoundException(org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException.TransactionNotFoundException) TxnMeta(org.apache.pulsar.transaction.coordinator.TxnMeta) MutablePair(org.apache.commons.lang3.tuple.MutablePair) Pair(org.apache.commons.lang3.tuple.Pair)

Example 3 with TransactionNotFoundException

use of org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException.TransactionNotFoundException in project pulsar by yahoo.

the class InMemTransactionMetadataStore method getTxnMeta.

@Override
public CompletableFuture<TxnMeta> getTxnMeta(TxnID txnid) {
    CompletableFuture<TxnMeta> getFuture = new CompletableFuture<>();
    TxnMetaImpl txn = transactions.get(txnid);
    if (null == txn) {
        getFuture.completeExceptionally(new TransactionNotFoundException(txnid));
    } else {
        getFuture.complete(txn);
    }
    return getFuture;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) TransactionNotFoundException(org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException.TransactionNotFoundException) TxnMeta(org.apache.pulsar.transaction.coordinator.TxnMeta)

Example 4 with TransactionNotFoundException

use of org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException.TransactionNotFoundException in project pulsar by yahoo.

the class MLTransactionMetadataStore method getTxnPositionPair.

private CompletableFuture<Pair<TxnMeta, List<Position>>> getTxnPositionPair(TxnID txnID) {
    CompletableFuture<Pair<TxnMeta, List<Position>>> completableFuture = new CompletableFuture<>();
    Pair<TxnMeta, List<Position>> txnMetaListPair = txnMetaMap.get(txnID.getLeastSigBits());
    if (txnMetaListPair == null) {
        completableFuture.completeExceptionally(new TransactionNotFoundException(txnID));
    } else {
        completableFuture.complete(txnMetaListPair);
    }
    return completableFuture;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Position(org.apache.bookkeeper.mledger.Position) ArrayList(java.util.ArrayList) List(java.util.List) TransactionNotFoundException(org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException.TransactionNotFoundException) TxnMeta(org.apache.pulsar.transaction.coordinator.TxnMeta) MutablePair(org.apache.commons.lang3.tuple.MutablePair) Pair(org.apache.commons.lang3.tuple.Pair)

Example 5 with TransactionNotFoundException

use of org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException.TransactionNotFoundException in project pulsar by yahoo.

the class MLTransactionMetadataStore method getTxnMeta.

@Override
public CompletableFuture<TxnMeta> getTxnMeta(TxnID txnID) {
    Pair<TxnMeta, List<Position>> txnMetaListPair = txnMetaMap.get(txnID.getLeastSigBits());
    CompletableFuture<TxnMeta> completableFuture = new CompletableFuture<>();
    if (txnMetaListPair == null) {
        completableFuture.completeExceptionally(new TransactionNotFoundException(txnID));
    } else {
        completableFuture.complete(txnMetaListPair.getLeft());
    }
    return completableFuture;
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) ArrayList(java.util.ArrayList) List(java.util.List) TransactionNotFoundException(org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException.TransactionNotFoundException) TxnMeta(org.apache.pulsar.transaction.coordinator.TxnMeta)

Aggregations

TransactionNotFoundException (org.apache.pulsar.transaction.coordinator.exceptions.CoordinatorException.TransactionNotFoundException)18 ArrayList (java.util.ArrayList)12 CompletableFuture (java.util.concurrent.CompletableFuture)12 TxnMeta (org.apache.pulsar.transaction.coordinator.TxnMeta)12 ExecutionException (java.util.concurrent.ExecutionException)9 TxnID (org.apache.pulsar.client.api.transaction.TxnID)9 List (java.util.List)6 Cleanup (lombok.Cleanup)6 ManagedLedgerConfig (org.apache.bookkeeper.mledger.ManagedLedgerConfig)6 ManagedLedgerFactory (org.apache.bookkeeper.mledger.ManagedLedgerFactory)6 ManagedLedgerFactoryConfig (org.apache.bookkeeper.mledger.ManagedLedgerFactoryConfig)6 ManagedLedgerFactoryImpl (org.apache.bookkeeper.mledger.impl.ManagedLedgerFactoryImpl)6 MLTransactionLogImpl (org.apache.pulsar.transaction.coordinator.impl.MLTransactionLogImpl)6 MLTransactionMetadataStore (org.apache.pulsar.transaction.coordinator.impl.MLTransactionMetadataStore)6 MLTransactionSequenceIdGenerator (org.apache.pulsar.transaction.coordinator.impl.MLTransactionSequenceIdGenerator)6 Test (org.testng.annotations.Test)6 Position (org.apache.bookkeeper.mledger.Position)3 MutablePair (org.apache.commons.lang3.tuple.MutablePair)3 Pair (org.apache.commons.lang3.tuple.Pair)3 PulsarServerException (org.apache.pulsar.broker.PulsarServerException)3