Skip to content

Commit

Permalink
(trivial) removes some hardcoded fate values (apache#5243)
Browse files Browse the repository at this point in the history
Removes some hardcoded values used by Fate and Fate tests.
  • Loading branch information
kevinrr888 authored Jan 13, 2025
1 parent 34d27c9 commit 862b6e5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
16 changes: 12 additions & 4 deletions core/src/main/java/org/apache/accumulo/core/fate/Fate.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public class Fate<T> {
private final ExecutorService deadResCleanerExecutor;

private static final EnumSet<TStatus> FINISHED_STATES = EnumSet.of(FAILED, SUCCESSFUL, UNKNOWN);
public static final Duration INITIAL_DELAY = Duration.ofSeconds(3);
private static final Duration DEAD_RES_CLEANUP_DELAY = Duration.ofMinutes(3);
private static final Duration POOL_WATCHER_DELAY = Duration.ofSeconds(30);

private final AtomicBoolean keepRunning = new AtomicBoolean(true);
private final TransferQueue<FateId> workQueue;
Expand Down Expand Up @@ -457,7 +460,7 @@ public Fate(T environment, FateStore<T> store, boolean runDeadResCleaner,
idleCountHistory.add(workQueue.getWaitingConsumerCount());
}
}
}, 3, 30, SECONDS));
}, INITIAL_DELAY.toSeconds(), getPoolWatcherDelay().toSeconds(), SECONDS));
this.transactionExecutor = pool;

ScheduledExecutorService deadResCleanerExecutor = null;
Expand All @@ -466,8 +469,9 @@ public Fate(T environment, FateStore<T> store, boolean runDeadResCleaner,
// reservations held by dead processes, if they exist.
deadResCleanerExecutor = ThreadPools.getServerThreadPools().createScheduledExecutorService(1,
store.type() + "-dead-reservation-cleaner-pool");
ScheduledFuture<?> deadReservationCleaner = deadResCleanerExecutor.scheduleWithFixedDelay(
new DeadReservationCleaner(), 3, getDeadResCleanupDelay().toSeconds(), SECONDS);
ScheduledFuture<?> deadReservationCleaner =
deadResCleanerExecutor.scheduleWithFixedDelay(new DeadReservationCleaner(),
INITIAL_DELAY.toSeconds(), getDeadResCleanupDelay().toSeconds(), SECONDS);
ThreadPools.watchCriticalScheduledTask(deadReservationCleaner);
}
this.deadResCleanerExecutor = deadResCleanerExecutor;
Expand All @@ -477,7 +481,11 @@ public Fate(T environment, FateStore<T> store, boolean runDeadResCleaner,
}

public Duration getDeadResCleanupDelay() {
return Duration.ofMinutes(3);
return DEAD_RES_CLEANUP_DELAY;
}

public Duration getPoolWatcherDelay() {
return POOL_WATCHER_DELAY;
}

// get a transaction id back to the requester before doing any work
Expand Down
12 changes: 6 additions & 6 deletions test/src/main/java/org/apache/accumulo/test/fate/FateIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ protected void testTransactionStatus(FateStore<TestEnv> store, ServerContext sct
try {

// Wait for the transaction runner to be scheduled.
Thread.sleep(3000);
Thread.sleep(Fate.INITIAL_DELAY.toMillis() * 2);

callStarted = new CountDownLatch(1);
finishCall = new CountDownLatch(1);
Expand Down Expand Up @@ -295,7 +295,7 @@ protected void testCancelWhileNew(FateStore<TestEnv> store, ServerContext sctx)
try {

// Wait for the transaction runner to be scheduled.
Thread.sleep(3000);
Thread.sleep(Fate.INITIAL_DELAY.toMillis() * 2);

callStarted = new CountDownLatch(1);
finishCall = new CountDownLatch(1);
Expand Down Expand Up @@ -330,7 +330,7 @@ protected void testCancelWhileSubmittedAndRunning(FateStore<TestEnv> store, Serv
try {

// Wait for the transaction runner to be scheduled.
Thread.sleep(3000);
Thread.sleep(Fate.INITIAL_DELAY.toMillis() * 2);

callStarted = new CountDownLatch(1);
finishCall = new CountDownLatch(1);
Expand Down Expand Up @@ -365,7 +365,7 @@ protected void testCancelWhileInCall(FateStore<TestEnv> store, ServerContext sct
try {

// Wait for the transaction runner to be scheduled.
Thread.sleep(3000);
Thread.sleep(Fate.INITIAL_DELAY.toMillis() * 2);

callStarted = new CountDownLatch(1);
finishCall = new CountDownLatch(1);
Expand Down Expand Up @@ -402,7 +402,7 @@ protected void testDeferredOverflow(FateStore<TestEnv> store, ServerContext sctx
try {

// Wait for the transaction runner to be scheduled.
Thread.sleep(3000);
Thread.sleep(Fate.INITIAL_DELAY.toMillis() * 2);

DeferredTestRepo.executedCalls.set(0);
// Initialize the repo to have a delay of 30 seconds
Expand Down Expand Up @@ -479,7 +479,7 @@ protected void testRepoFails(FateStore<TestEnv> store, ServerContext sctx) throw
try {

// Wait for the transaction runner to be scheduled.
Thread.sleep(3000);
Thread.sleep(Fate.INITIAL_DELAY.toMillis() * 2);

List<String> expectedUndoOrder = List.of("OP3", "OP2", "OP1");
/*
Expand Down

0 comments on commit 862b6e5

Please sign in to comment.