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

Watchdog: move to client context - #480

Merged
garrettjonesgoogle merged 8 commits into
googleapis:masterfrom
igorbernstein2:watchdog-context
Feb 28, 2018
Merged

Watchdog: move to client context#480
garrettjonesgoogle merged 8 commits into
googleapis:masterfrom
igorbernstein2:watchdog-context

Conversation

@igorbernstein2

@igorbernstein2igorbernstein2 commented Feb 15, 2018

Copy link
Copy Markdown
Contributor

This depends on #482, which handles preliminary refactoring to cut down on the noise in this PR.

This is a follow up on the watchdog introduced in #463. It moves it out of the RetryingServerStreamingCallable and into the ClientContext. The main benefits are:

  • Callables can be stateless again
  • There is only one scheduled reaper for all of the callables

Changes:

  • Add {Fixed,Instantiating}WatchdogProviders to allow for transitioning from built ClientContexts to StubSettings.Builders and ClientContext.Builders
  • Mark the Watchdog as nullable to keep backwards compatibility (to avoid NPEs building ClientContexts from Builders)
  • Allow StubSettings to configure both the WatchdogProvider and the WatchdogCheckInterval.
  • Enable the watchdog in StubSettings by default with an interval of 10 secs.
  • Add WatchdogServerStreamingCallable and plumb timeouts through ApiCallContext
  • Use the new WatchdogServerStreamingCallable and decouple RetryingServerStreamingCallable from the Watchdog

@codecov-io

codecov-io commented Feb 16, 2018

Copy link
Copy Markdown

Codecov Report

Merging #480 into master will increase coverage by 0.1%.
The diff coverage is 68.49%.

Impacted file tree graph

@@ Coverage Diff @@## master #480 +/- ##
===========================================
+ Coverage 70.33% 70.44% +0.1% - Complexity 775 810 +35 
===========================================
Files 163 166 +3 Lines 3668 3776 +108 Branches 273 289 +16 ===========================================
+ Hits 2580 2660 +80 - Misses 973 993 +20 - Partials 115 123 +8
Impacted FilesCoverage ΔComplexity Δ
...oogle/api/gax/rpc/ServerStreamingCallSettings.java67.27% <ø> (-4.16%)6 <0> (-1)
...e/api/gax/rpc/RetryingServerStreamingCallable.java0% <ø> (ø)0 <0> (ø)⬇️
...a/com/google/api/gax/grpc/GrpcCallableFactory.java67.27% <0%> (-2.54%)8 <0> (ø)
...e/api/gax/rpc/WatchdogServerStreamingCallable.java0% <0%> (ø)0 <0> (?)
...rc/main/java/com/google/api/gax/rpc/Callables.java63.63% <0%> (+4.06%)6 <0> (ø)⬇️
...m/google/api/gax/httpjson/HttpJsonCallContext.java29.31% <0%> (-2.18%)8 <0> (ø)
.../com/google/api/gax/rpc/FixedWatchdogProvider.java100% <100%> (ø)9 <9> (?)
...in/java/com/google/api/gax/rpc/ClientSettings.java93.24% <100%> (+1.3%)12 <2> (+2)⬆️
...ain/java/com/google/api/gax/rpc/ClientContext.java82.53% <55.55%> (-11.08%)9 <0> (ø)
.../java/com/google/api/gax/grpc/GrpcCallContext.java73.33% <75.86%> (+0.86%)30 <11> (+8)⬆️
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8d45d18...1e2bd88. Read the comment docs.

@igorbernstein2igorbernstein2 mentioned this pull request Feb 16, 2018
@igorbernstein2igorbernstein2 changed the title WIP: move watchdog to client contextWatchdog to client contextFeb 16, 2018
@igorbernstein2igorbernstein2 changed the title Watchdog to client contextWatchdog: move to client contextFeb 16, 2018
@igorbernstein2
igorbernstein2force-pushed the watchdog-context branch 2 times, most recently from 0af9abf to 91256b6CompareFebruary 22, 2018 22:09
@igorbernstein2

Copy link
Copy Markdown
ContributorAuthor

rebased on the latest prep changes

@igorbernstein2

Copy link
Copy Markdown
ContributorAuthor

Rebased. This is ready for review

@garrettjonesgooglegarrettjonesgoogle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The change generally looks good.

import com.google.common.base.Preconditions;

/**
* Integration {@link ServerStreamingCallable} for the {@link Watchdog}.

This comment was marked as spam.


WatchdogProvider withExecutor(ScheduledExecutorService executor);

boolean needsExecutor();

This comment was marked as spam.

ApiCallContext withTimeout(Duration rpcTimeout);

/**
* Returns a new ApiCallContext with the given timeout set.

This comment was marked as spam.

Duration getStreamWaitTimeout();

/**
* Returns a new ApiCallContext with the given timeout set.

This comment was marked as spam.


@Override
public ApiCallContext withStreamWaitTimeout(@Nullable Duration streamWaitTimeout) {
throw new UnsupportedOperationException("Http does not support streaming");

This comment was marked as spam.


@BetaApi("The surface for streaming is not stable yet and may change in the future.")
@Nullable
public abstract Watchdog getWatchdog();

This comment was marked as spam.

import javax.annotation.Nullable;
import org.threeten.bp.Duration;

public class FixedWatchdogProvider implements WatchdogProvider {

This comment was marked as spam.

@igorbernstein2

Copy link
Copy Markdown
ContributorAuthor

Incorporated all suggestions, PTAL

@garrettjonesgooglegarrettjonesgoogle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM - I will merge after you fix my last tiny requests


/**
* Returns a new ApiCallContext with the given timeout set.
* Returns a new ApiCallContext with the given stream idel timeout set.

This comment was marked as spam.


/**
* Integration {@link ServerStreamingCallable} for the {@link Watchdog}.
* A callable that uses the {@link Watchdog} to monitor streams.

This comment was marked as spam.

@igorbernstein2

igorbernstein2 commented Feb 27, 2018

Copy link
Copy Markdown
ContributorAuthor

just noticed a couple of bugs (I forgot to update the semantics to be nonnull for clientcontext). please don't merge yet

@igorbernstein2

Copy link
Copy Markdown
ContributorAuthor

Ok, fixed. The issue was a result of an incomplete rebase on top of the feedback in #482. The fix was to disallow null in CallContext for arguments. But to retain it internally to allow proper merge semantics. @garrettjonesgoogle PTAL

@igorbernstein2

Copy link
Copy Markdown
ContributorAuthor

hmm, that's odd I'm not sure why the verifyLicense check is failing

@garrettjonesgoogle

Copy link
Copy Markdown
Contributor

We updated license headers in #487 - you'll need to update your files too.

Preconditions.checkArgument(
streamWaitTimeout.compareTo(Duration.ZERO) > 0, "Invalid timeout: <= 0 s");
}
public GrpcCallContext withStreamWaitTimeout(@Nonnull Duration streamWaitTimeout) {

This comment was marked as spam.

- Add {Fixed,Instantiating}WatchdogProviders to allow for transitioning from built ClientContexts to StubSettings.Builders and ClientContext.Builders
- Mark the Watchdog as nullable to keep backwards compatibility (to avoid NPEs building ClientContexts from Builders)
- Allow StubSettings to configure both the WatchdogProvider and the WatchdogCheckInterval.
- Enable the watchdog in StubSettings by default with an interval of 10 secs.
@igorbernstein2

Copy link
Copy Markdown
ContributorAuthor

updated: licenses fixed & allowing users to clear timeouts. PTAL

@garrettjonesgooglegarrettjonesgoogle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@garrettjonesgoogle
garrettjonesgoogle merged commit d47fccd into googleapis:masterFeb 28, 2018
@igorbernstein2
igorbernstein2 deleted the watchdog-context branch March 18, 2018 06:30
Sign up for freeto 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.

3 participants

@igorbernstein2@codecov-io@garrettjonesgoogle