Skip to content

Commit

Permalink
[cleanup] [broker] fix return value of TransactionTimeoutTrackerImpl#…
Browse files Browse the repository at this point in the history
…addTransaction (apache#22020)

### Motivation
According to the method signature, we should return true when the transaction is added to the tracker.
```
    /**
     * Add a txnID to the tracker.
     *
     * @param sequenceId
     *            the sequenceId
     * @param timeout
     *            the absolute timestamp for transaction timeout
     *
     * @return true if the transaction was added to the tracker or false if had timed out
     */
    CompletableFuture<Boolean> addTransaction(long sequenceId, long timeout);
```
But actually, we return false for any cases.

Update: Moreover, we do not use the return value anyway, it is useless. We have better remove it.

### Modifications

~~Return true when the transaction is added to the tracker.~~
Remove the return value as it is useless.
  • Loading branch information
thetumbled authored Feb 6, 2024
1 parent 5df97b4 commit 0dabc97
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import io.netty.util.Timer;
import io.netty.util.TimerTask;
import java.time.Clock;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.broker.TransactionMetadataStoreService;
Expand Down Expand Up @@ -57,10 +56,10 @@ public class TransactionTimeoutTrackerImpl implements TransactionTimeoutTracker,
}

@Override
public CompletableFuture<Boolean> addTransaction(long sequenceId, long timeout) {
public void addTransaction(long sequenceId, long timeout) {
if (timeout < tickTimeMillis) {
this.transactionMetadataStoreService.endTransactionForTimeout(new TxnID(tcId, sequenceId));
return CompletableFuture.completedFuture(false);
return;
}
synchronized (this){
long nowTime = clock.millis();
Expand All @@ -79,7 +78,6 @@ public CompletableFuture<Boolean> addTransaction(long sequenceId, long timeout)
nowTaskTimeoutTime = transactionTimeoutTime;
}
}
return CompletableFuture.completedFuture(false);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.apache.pulsar.transaction.coordinator;

import com.google.common.annotations.Beta;
import java.util.concurrent.CompletableFuture;

/**
* Represent the tracker for the timeout of the transaction.
Expand All @@ -34,10 +33,8 @@ public interface TransactionTimeoutTracker extends AutoCloseable {
* the sequenceId
* @param timeout
* the absolute timestamp for transaction timeout
*
* @return true if the transaction was added to the tracker or false if had timed out
*/
CompletableFuture<Boolean> addTransaction(long sequenceId, long timeout);
void addTransaction(long sequenceId, long timeout);

/**
* When replay the log, add the txnMeta to timer task queue.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,7 @@ public void testManageLedgerWriteFailState(TxnLogBufferedWriterConfig txnLogBuff
public class TransactionTimeoutTrackerImpl implements TransactionTimeoutTracker {

@Override
public CompletableFuture<Boolean> addTransaction(long sequenceId, long timeout) {
return null;
public void addTransaction(long sequenceId, long timeout) {
}

@Override
Expand Down

0 comments on commit 0dabc97

Please sign in to comment.