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

Pipe executor configuration of shouldShutDown to watchdogs #1859

Conversation

johnjcasey
Copy link

@johnjcasey johnjcasey commented Nov 1, 2022

This fixes the issue identified in #1858

@johnjcasey johnjcasey requested review from a team as code owners November 1, 2022 15:22
…leapis#1858)

BREAKING CHANGE: change WatchdogProvider interface to require whether or not to shut the executor down
if (shouldShutdownExecutor) {
return executor.isShutdown();
}
return true;
Copy link

Choose a reason for hiding this comment

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

Should this return whether the future is done instead of returning true in the case where we aren't shutting down the executor?

if (shouldShutdownExecutor){
return executor.isTerminated();
}
return true;
Copy link

Choose a reason for hiding this comment

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

Should this return whether the future is done instead of returning true in the case where we aren't shutting down the executor?

if (shouldShutdownExecutor) {
return executor.awaitTermination(duration, unit);
}
return true;
Copy link

Choose a reason for hiding this comment

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

Should this wait for the future to complete with the specified time limit instead of returning true?

@@ -70,20 +70,22 @@ public final class Watchdog implements Runnable, BackgroundResource {
private final ApiClock clock;
private final Duration scheduleInterval;
private final ScheduledExecutorService executor;
private final boolean shouldShutdownExecutor;
private ScheduledFuture<?> future;

/** returns a Watchdog which is scheduled at the provided interval. */
public static Watchdog create(
Copy link
Contributor

Choose a reason for hiding this comment

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

This is changing a public method that is not marked as InternalApi which is strictly forbidden.

@@ -45,7 +45,7 @@ public interface WatchdogProvider {

boolean needsExecutor();

WatchdogProvider withExecutor(ScheduledExecutorService executor);
WatchdogProvider withExecutor(ScheduledExecutorService executor, boolean shouldShutdownExecutor);
Copy link
Contributor

Choose a reason for hiding this comment

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

Changing interface is also strictly forbidden.

@@ -138,12 +140,18 @@ public void shutdown() {

@Override
public boolean isShutdown() {
return executor.isShutdown();
if (shouldShutdownExecutor) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What exactly is the problem we are trying to solve here? Is the problem that Watchdog shutting down executor regardless of the shouldAutoClose() flag or Watchdog reporting isShutdown() regardless of the shouldAutoClose() flag? The implementation seems try to solve the latter.

@johnjcasey
Copy link
Author

the issue is that the watchdog is trying to shut down the executor regardless of the executors shouldAutoClose flag

@blakeli0
Copy link
Contributor

blakeli0 commented Dec 8, 2022

Closing in favor of #1890 and #1884

@blakeli0 blakeli0 closed this Dec 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants