Skip to content

Commit

Permalink
reducing wait times
Browse files Browse the repository at this point in the history
Signed-off-by: Santhosh Gandhe <[email protected]>
  • Loading branch information
san81 committed Oct 25, 2024
1 parent 58bbf29 commit 0087491
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.Duration;
import java.util.Optional;

/**
Expand All @@ -22,7 +23,7 @@ public class WorkerScheduler implements Runnable {

private static final Logger log = LoggerFactory.getLogger(WorkerScheduler.class);
private static final int RETRY_BACKOFF_ON_EXCEPTION_MILLIS = 5_000;
private static final long SLEEP_DURATION_MILLIS = 10000;
private static final Duration DEFAULT_SLEEP_DURATION_MILLIS = Duration.ofMillis(10000);

private final EnhancedSourceCoordinator sourceCoordinator;
private final SaasSourceConfig sourceConfig;
Expand Down Expand Up @@ -54,9 +55,9 @@ public void run() {
processPartition(partition.get(), buffer, sourceConfig);

} else {
log.debug("No partition available. This thread will sleep for {}", SLEEP_DURATION_MILLIS);
log.debug("No partition available. This thread will sleep for {}", DEFAULT_SLEEP_DURATION_MILLIS);
try {
Thread.sleep(SLEEP_DURATION_MILLIS);
Thread.sleep(DEFAULT_SLEEP_DURATION_MILLIS.toMillis());
} catch (final InterruptedException e) {
log.info("InterruptedException occurred");
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void testExceptionWhileAcquiringWorkerPartition() throws InterruptedException {
ExecutorService executorService = Executors.newSingleThreadExecutor();
executorService.submit(workerScheduler);

Thread.sleep(1000);
Thread.sleep(10);
executorService.shutdownNow();

// Crawler shouldn't be invoked in this case
Expand All @@ -126,7 +126,7 @@ void testWhenNoPartitionToWorkOn() throws InterruptedException {
executorService.submit(workerScheduler);

//Wait for more than a minute as the default while loop wait time in leader scheduler is 1 minute
Thread.sleep(11000);
Thread.sleep(10);
executorService.shutdownNow();

// Crawler shouldn't be invoked in this case
Expand All @@ -142,7 +142,7 @@ void testRetryBackOffTriggeredWhenExceptionOccurred() throws InterruptedExceptio
executorService.submit(workerScheduler);

//Wait for more than a minute as the default while loop wait time in leader scheduler is 1 minute
Thread.sleep(11000);
Thread.sleep(10);
executorService.shutdownNow();

// Crawler shouldn't be invoked in this case
Expand Down

0 comments on commit 0087491

Please sign in to comment.