Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
smatthewenglish committed Apr 30, 2019
1 parent c64c680 commit b888bf4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,8 @@ public PendingTransactions(

public void evictOldTransactions() {
synchronized (pendingTransactions) {
final Instant removeTransactionsBefore = clock.instant().minus(maxTransactionRetentionHours, ChronoUnit.HOURS);

System.out.println("clock.instant(): " + clock.instant());
System.out.println("maxTransactionRetentionHours: " + maxTransactionRetentionHours);
System.out.println("clock.instant().minus(maxTransactionRetentionHours, ChronoUnit.HOURS): " + clock.instant().minus(maxTransactionRetentionHours, ChronoUnit.HOURS));

final Instant removeTransactionsBefore =
clock.instant().minus(maxTransactionRetentionHours, ChronoUnit.HOURS);
final List<TransactionInfo> transactionsToRemove =
prioritizedTransactions.stream()
.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ private Transaction createTransaction(final int transactionNumber) {

@Test
public void shouldEvictMultipleOldTransactions() {
final int maxTransactionRetentionHours = 1000;
final int maxTransactionRetentionHours = 1;
final PendingTransactions transactions =
new PendingTransactions(
maxTransactionRetentionHours, MAX_TRANSACTIONS, clock, metricsSystem);
Expand All @@ -428,7 +428,7 @@ public void shouldEvictMultipleOldTransactions() {
transactions.addRemoteTransaction(transaction2);
assertThat(transactions.size()).isEqualTo(2);

clock.stepMillis(2000);
clock.step(2L, ChronoUnit.HOURS);
transactions.evictOldTransactions();
assertThat(transactions.size()).isEqualTo(0);
}
Expand All @@ -441,9 +441,7 @@ public void shouldEvictSingleOldTransaction() {
maxTransactionRetentionHours, MAX_TRANSACTIONS, clock, metricsSystem);
transactions.addRemoteTransaction(transaction1);
assertThat(transactions.size()).isEqualTo(1);

clock.step(2L, ChronoUnit.HOURS);

transactions.evictOldTransactions();
assertThat(transactions.size()).isEqualTo(0);
}
Expand All @@ -456,7 +454,7 @@ public void shouldEvictExclusivelyOldTransactions() {
maxTransactionRetentionHours, MAX_TRANSACTIONS, clock, metricsSystem);
transactions.addRemoteTransaction(transaction1);
assertThat(transactions.size()).isEqualTo(1);
clock.stepMillis(2001);
clock.step(3L, ChronoUnit.HOURS);
transactions.addRemoteTransaction(transaction2);
assertThat(transactions.size()).isEqualTo(2);
transactions.evictOldTransactions();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.time.Instant;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.temporal.TemporalAmount;
import java.time.temporal.TemporalUnit;

public class TestClock extends Clock {
Expand Down

0 comments on commit b888bf4

Please sign in to comment.