Skip to content
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,16 @@ public void run() {
logger.info("Started {}", taskId);
isRunning.set(true);
try {
// wait for 60 seconds for controller to become leader as it's required to be leader for dead store stats
long deadline = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(60);
// wait for 300 seconds for controller to become leader as it's required to be leader for dead store stats
long deadline = System.currentTimeMillis() + TimeUnit.SECONDS.toMillis(300);
while (!admin.isLeaderControllerFor(clusterName)) {
if (System.currentTimeMillis() > deadline) {
throw new VeniceException("Timed out waiting for controller to become leader for cluster: " + clusterName);
}
Utils.sleep(10_000); // sleep for 10 seconds
if (!Utils.sleep(10_000)) {
logger.info("Sleep was interrupted, stopping dead store stats prefetch task for cluster: {}", clusterName);
break;
}
}

logger.debug("Initial fetch of dead store stats for cluster: {}", clusterName);
Expand All @@ -58,7 +61,11 @@ public void run() {

while (isRunning.get()) {
try {
Utils.sleep(refreshIntervalMs);
// Check return value of sleep to detect thread interruption for graceful shutdown
if (!Utils.sleep(refreshIntervalMs)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its cleaner to call Thread.sleep and capture the exception without this extra check on utils.sleep

logger.info("Sleep was interrupted, stopping dead store stats prefetch task for cluster: {}", clusterName);
break;
}
long startTime = System.currentTimeMillis();
logger.debug("Fetching dead store stats for cluster: {}", clusterName);
admin.preFetchDeadStoreStats(clusterName, getStoresInCluster());
Expand Down
Loading