Skip to content

Commit

Permalink
feat: Introduce java.time to Gax-Java (#1872)
Browse files Browse the repository at this point in the history
This introduces the use of `java.time` in replacement of `org.threeten`
backport classes.


### Message to library users (release note)
We have made the following backwards-compatible changes in this library:
* We have changed the method return type and argument type in
__internal__ classes from `org.threeten.bp` to `java.time`. This has no
effect in the API surface.
* We have added `java.time` versions for each of the abstract methods
involving `org.threeten.bp`. The affected classes are
`BatchingSettings`, `RetrySettings`, `TimedAttemptSettings` and
`ClientContext`, all of which are `AutoValue` classes, not meant to be
extended by our users.
* All getters and setters using `org.threeten.bp` will be marked final
because we will force their behavior to be the same one as the
`java.time` counterpart, which has the actual implementation. The
affected classes are `BatchingSettings`, `RetrySettings`,
`TimedAttemptSettings` and `ClientContext`, all of which are `AutoValue`
classes, not meant to be extended by our users.
* In three `interface`s, we have added `java.time` versions for each of
the methods involving `org.threeten.bp`. The affected interfaces are
`WatchdogProvider` (public interface), `ApiTracer` (internal) and
`ApiCallContext` (internal). The new method in `WatchdogProvider` has a
`default` behavior, which is to call the `threeten` counterpart, in
order to make this a backwards-compatible change.


## Implementation
It preserves method signatures using `threeten`. The cases are:
### `@AutoValue` clases and classes with public interface involving time
objects
Autovalues will have an internal `threeten` variable with a convenience
`java.time` wrapper method. For example:

https://github.com/googleapis/sdk-platform-java/blob/667f2da15d0800d87d0866e36627ac23955c0b01/gax-java/gax/src/main/java/com/google/api/gax/retrying/RetrySettings.java#L78-L89

and 


https://github.com/googleapis/sdk-platform-java/blob/a99d3c1acd4b25a28bd571c8c6f7f7f5d74e1365/gax-java/gax/src/main/java/com/google/api/gax/retrying/RetrySettings.java#L243-L262

### Internal variables
`Duration` or `Instant` private variables are switched to `java.time`.
In this case, the wrappers are of `threeten` clasess. For example

https://github.com/googleapis/sdk-platform-java/blob/667f2da15d0800d87d0866e36627ac23955c0b01/gax-java/gax-httpjson/src/main/java/com/google/api/gax/httpjson/HttpJsonCallContext.java#L237-L247

## Deprecation warning
`threeten` methods will now have an `@ObsoleteApi` annotation. For
example:

https://github.com/googleapis/sdk-platform-java/blob/667f2da15d0800d87d0866e36627ac23955c0b01/gax-java/gax/src/main/java/com/google/api/gax/batching/BatchingSettings.java#L106

## CLIRR checks
### `gax-java/gax`
```
[ERROR] 7013: com.google.api.gax.batching.BatchingSettings: Abstract method 'public java.time.Duration getDelayThresholdDuration()' has been added
[ERROR] 7014: com.google.api.gax.batching.BatchingSettings$Builder: Method 'public com.google.api.gax.batching.BatchingSettings$Builder setDelayThreshold(org.threeten.bp.Duration)' is now final
[ERROR] 7013: com.google.api.gax.batching.BatchingSettings$Builder: Abstract method 'public com.google.api.gax.batching.BatchingSettings$Builder setDelayThresholdDuration(java.time.Duration)' has been added
[ERROR] 7005: com.google.api.gax.retrying.DirectRetryingExecutor: Parameter 1 of 'protected void sleep(org.threeten.bp.Duration)' has changed its type to java.time.Duration
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings: Abstract method 'public java.time.Duration getInitialRetryDelayDuration()' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings: Method 'public org.threeten.bp.Duration getInitialRpcTimeout()' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings: Abstract method 'public java.time.Duration getInitialRpcTimeoutDuration()' has been added
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings: Abstract method 'public java.time.Duration getMaxRetryDelayDuration()' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings: Method 'public org.threeten.bp.Duration getMaxRpcTimeout()' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings: Abstract method 'public java.time.Duration getMaxRpcTimeoutDuration()' has been added
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings: Abstract method 'public java.time.Duration getTotalTimeoutDuration()' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings$Builder: Method 'public org.threeten.bp.Duration getInitialRetryDelay()' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings$Builder: Abstract method 'public java.time.Duration getInitialRetryDelayDuration()' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings$Builder: Method 'public org.threeten.bp.Duration getInitialRpcTimeout()' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings$Builder: Abstract method 'public java.time.Duration getInitialRpcTimeoutDuration()' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings$Builder: Method 'public org.threeten.bp.Duration getMaxRetryDelay()' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings$Builder: Abstract method 'public java.time.Duration getMaxRetryDelayDuration()' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings$Builder: Method 'public org.threeten.bp.Duration getMaxRpcTimeout()' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings$Builder: Abstract method 'public java.time.Duration getMaxRpcTimeoutDuration()' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings$Builder: Method 'public org.threeten.bp.Duration getTotalTimeout()' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings$Builder: Abstract method 'public java.time.Duration getTotalTimeoutDuration()' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings$Builder: Method 'public com.google.api.gax.retrying.RetrySettings$Builder setInitialRetryDelay(org.threeten.bp.Duration)' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings$Builder: Abstract method 'public com.google.api.gax.retrying.RetrySettings$Builder setInitialRetryDelayDuration(java.time.Duration)' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings$Builder: Method 'public com.google.api.gax.retrying.RetrySettings$Builder setInitialRpcTimeout(org.threeten.bp.Duration)' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings$Builder: Abstract method 'public com.google.api.gax.retrying.RetrySettings$Builder setInitialRpcTimeoutDuration(java.time.Duration)' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings$Builder: Method 'public com.google.api.gax.retrying.RetrySettings$Builder setMaxRetryDelay(org.threeten.bp.Duration)' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings$Builder: Abstract method 'public com.google.api.gax.retrying.RetrySettings$Builder setMaxRetryDelayDuration(java.time.Duration)' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings$Builder: Method 'public com.google.api.gax.retrying.RetrySettings$Builder setMaxRpcTimeout(org.threeten.bp.Duration)' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings$Builder: Abstract method 'public com.google.api.gax.retrying.RetrySettings$Builder setMaxRpcTimeoutDuration(java.time.Duration)' has been added
[ERROR] 7014: com.google.api.gax.retrying.RetrySettings$Builder: Method 'public com.google.api.gax.retrying.RetrySettings$Builder setTotalTimeout(org.threeten.bp.Duration)' is now final
[ERROR] 7013: com.google.api.gax.retrying.RetrySettings$Builder: Abstract method 'public com.google.api.gax.retrying.RetrySettings$Builder setTotalTimeoutDuration(java.time.Duration)' has been added
[ERROR] 7014: com.google.api.gax.retrying.TimedAttemptSettings: Method 'public org.threeten.bp.Duration getRandomizedRetryDelay()' is now final
[ERROR] 7013: com.google.api.gax.retrying.TimedAttemptSettings: Abstract method 'public java.time.Duration getRandomizedRetryDelayDuration()' has been added
[ERROR] 7014: com.google.api.gax.retrying.TimedAttemptSettings: Method 'public org.threeten.bp.Duration getRetryDelay()' is now final
[ERROR] 7013: com.google.api.gax.retrying.TimedAttemptSettings: Abstract method 'public java.time.Duration getRetryDelayDuration()' has been added
[ERROR] 7014: com.google.api.gax.retrying.TimedAttemptSettings: Method 'public org.threeten.bp.Duration getRpcTimeout()' is now final
[ERROR] 7013: com.google.api.gax.retrying.TimedAttemptSettings: Abstract method 'public java.time.Duration getRpcTimeoutDuration()' has been added
[ERROR] 7014: com.google.api.gax.retrying.TimedAttemptSettings$Builder: Method 'public com.google.api.gax.retrying.TimedAttemptSettings$Builder setRandomizedRetryDelay(org.threeten.bp.Duration)' is now final
[ERROR] 7013: com.google.api.gax.retrying.TimedAttemptSettings$Builder: Abstract method 'public com.google.api.gax.retrying.TimedAttemptSettings$Builder setRandomizedRetryDelayDuration(java.time.Duration)' has been added
[ERROR] 7014: com.google.api.gax.retrying.TimedAttemptSettings$Builder: Method 'public com.google.api.gax.retrying.TimedAttemptSettings$Builder setRetryDelay(org.threeten.bp.Duration)' is now final
[ERROR] 7013: com.google.api.gax.retrying.TimedAttemptSettings$Builder: Abstract method 'public com.google.api.gax.retrying.TimedAttemptSettings$Builder setRetryDelayDuration(java.time.Duration)' has been added
[ERROR] 7014: com.google.api.gax.retrying.TimedAttemptSettings$Builder: Method 'public com.google.api.gax.retrying.TimedAttemptSettings$Builder setRpcTimeout(org.threeten.bp.Duration)' is now final
[ERROR] 7013: com.google.api.gax.retrying.TimedAttemptSettings$Builder: Abstract method 'public com.google.api.gax.retrying.TimedAttemptSettings$Builder setRpcTimeoutDuration(java.time.Duration)' has been added
[ERROR] 7012: com.google.api.gax.rpc.ApiCallContext: Method 'public java.time.Duration getStreamIdleTimeoutDuration()' has been added to an interface
[ERROR] 7012: com.google.api.gax.rpc.ApiCallContext: Method 'public java.time.Duration getStreamWaitTimeoutDuration()' has been added to an interface
[ERROR] 7012: com.google.api.gax.rpc.ApiCallContext: Method 'public java.time.Duration getTimeoutDuration()' has been added to an interface
[ERROR] 7012: com.google.api.gax.rpc.ApiCallContext: Method 'public com.google.api.gax.rpc.ApiCallContext withStreamIdleTimeoutDuration(java.time.Duration)' has been added to an interface
[ERROR] 7012: com.google.api.gax.rpc.ApiCallContext: Method 'public com.google.api.gax.rpc.ApiCallContext withStreamWaitTimeoutDuration(java.time.Duration)' has been added to an interface
[ERROR] 7012: com.google.api.gax.rpc.ApiCallContext: Method 'public com.google.api.gax.rpc.ApiCallContext withTimeoutDuration(java.time.Duration)' has been added to an interface
[ERROR] 7014: com.google.api.gax.rpc.ClientContext: Method 'public org.threeten.bp.Duration getStreamWatchdogCheckInterval()' is now final
[ERROR] 7013: com.google.api.gax.rpc.ClientContext: Abstract method 'public java.time.Duration getStreamWatchdogCheckIntervalDuration()' has been added
[ERROR] 7014: com.google.api.gax.rpc.ClientContext$Builder: Method 'public com.google.api.gax.rpc.ClientContext$Builder setStreamWatchdogCheckInterval(org.threeten.bp.Duration)' is now final
[ERROR] 7013: com.google.api.gax.rpc.ClientContext$Builder: Abstract method 'public com.google.api.gax.rpc.ClientContext$Builder setStreamWatchdogCheckIntervalDuration(java.time.Duration)' has been added
[ERROR] 7012: com.google.api.gax.rpc.WatchdogProvider: Method 'public com.google.api.gax.rpc.WatchdogProvider withCheckIntervalDuration(java.time.Duration)' has been added to an interface
[ERROR] 7012: com.google.api.gax.tracing.ApiTracer: Method 'public void attemptFailedDuration(java.lang.Throwable, java.time.Duration)' has been added to an interface
```

We have decided to ignore a these CLIRR messages due to the following
reasons

* `7005` (method type change): This has only been implemented in
internal classes, not exposed to our customers
* `7013` (new abstract method added): We have added several java.time
versions for each of the methods involving org.threeten.bp. This affects
`AutoValue` classes only.
* `7014` (convert to final): All getters and setters using
org.threeten.bp will be marked final because we will force their
behavior to be the same one as the java.time counterpart, which has the
actual implementation. This affects `AutoValue` classes only.
* `7012` (new method in interface): We have added several java.time
versions for each of the methods involving org.threeten.bp. For the only
public interface `WatchdogProvider`, we added a `default` behavior.

---------

Co-authored-by: Blake Li <[email protected]>
Co-authored-by: Mike Eltsufin <[email protected]>
Co-authored-by: Lawrence Qiu <[email protected]>
  • Loading branch information
4 people authored Jun 27, 2024
1 parent 36d12a6 commit 308aeaf
Show file tree
Hide file tree
Showing 104 changed files with 2,948 additions and 929 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.Nullable;
import org.threeten.bp.Duration;

/**
* A {@link ManagedChannel} that will send requests round-robin via a set of channels.
Expand All @@ -69,7 +68,7 @@
*/
class ChannelPool extends ManagedChannel {
@VisibleForTesting static final Logger LOG = Logger.getLogger(ChannelPool.class.getName());
private static final Duration REFRESH_PERIOD = Duration.ofMinutes(50);
private static final java.time.Duration REFRESH_PERIOD = java.time.Duration.ofMinutes(50);

private final ChannelPoolSettings settings;
private final ChannelFactory channelFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,12 @@
*/
package com.google.api.gax.grpc;

import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;
import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration;

import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.core.ObsoleteApi;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.ApiCallContext;
import com.google.api.gax.rpc.ApiExceptionFactory;
Expand Down Expand Up @@ -62,7 +66,6 @@
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.threeten.bp.Duration;

/**
* GrpcCallContext encapsulates context data used to make a grpc call.
Expand All @@ -84,9 +87,9 @@ public final class GrpcCallContext implements ApiCallContext {
private final Channel channel;
@Nullable private final Credentials credentials;
private final CallOptions callOptions;
@Nullable private final Duration timeout;
@Nullable private final Duration streamWaitTimeout;
@Nullable private final Duration streamIdleTimeout;
@Nullable private final java.time.Duration timeout;
@Nullable private final java.time.Duration streamWaitTimeout;
@Nullable private final java.time.Duration streamIdleTimeout;
@Nullable private final Integer channelAffinity;
@Nullable private final RetrySettings retrySettings;
@Nullable private final ImmutableSet<StatusCode.Code> retryableCodes;
Expand Down Expand Up @@ -132,9 +135,9 @@ private GrpcCallContext(
Channel channel,
@Nullable Credentials credentials,
CallOptions callOptions,
@Nullable Duration timeout,
@Nullable Duration streamWaitTimeout,
@Nullable Duration streamIdleTimeout,
@Nullable java.time.Duration timeout,
@Nullable java.time.Duration streamWaitTimeout,
@Nullable java.time.Duration streamIdleTimeout,
@Nullable Integer channelAffinity,
ImmutableMap<String, List<String>> extraHeaders,
ApiCallContextOptions options,
Expand Down Expand Up @@ -228,8 +231,15 @@ public GrpcCallContext withEndpointContext(EndpointContext endpointContext) {
endpointContext);
}

/** This method is obsolete. Use {@link #withTimeoutDuration(java.time.Duration)} instead. */
@Override
@ObsoleteApi("Use withTimeoutDuration(java.time.Duration) instead")
public GrpcCallContext withTimeout(@Nullable org.threeten.bp.Duration timeout) {
return withTimeoutDuration(toJavaTimeDuration(timeout));
}

@Override
public GrpcCallContext withTimeout(@Nullable Duration timeout) {
public GrpcCallContext withTimeoutDuration(@Nullable java.time.Duration timeout) {
// Default RetrySettings use 0 for RPC timeout. Treat that as disabled timeouts.
if (timeout != null && (timeout.isZero() || timeout.isNegative())) {
timeout = null;
Expand All @@ -255,17 +265,37 @@ public GrpcCallContext withTimeout(@Nullable Duration timeout) {
endpointContext);
}

/** This method is obsolete. Use {@link #getTimeoutDuration()} instead. */
@Nullable
@Override
public Duration getTimeout() {
@ObsoleteApi("Use getTimeoutDuration() instead")
public org.threeten.bp.Duration getTimeout() {
return toThreetenDuration(getTimeoutDuration());
}

@Nullable
@Override
public java.time.Duration getTimeoutDuration() {
return timeout;
}

/**
* This method is obsolete. Use {@link #withStreamWaitTimeoutDuration(java.time.Duration)}
* instead.
*/
@Override
@ObsoleteApi("Use withStreamWaitTimeoutDuration(java.time.Duration) instead")
public GrpcCallContext withStreamWaitTimeout(
@Nullable org.threeten.bp.Duration streamWaitTimeout) {
return withStreamWaitTimeoutDuration(toJavaTimeDuration(streamWaitTimeout));
}

@Override
public GrpcCallContext withStreamWaitTimeout(@Nullable Duration streamWaitTimeout) {
public GrpcCallContext withStreamWaitTimeoutDuration(
@Nullable java.time.Duration streamWaitTimeout) {
if (streamWaitTimeout != null) {
Preconditions.checkArgument(
streamWaitTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
streamWaitTimeout.compareTo(java.time.Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
}

return new GrpcCallContext(
Expand All @@ -283,11 +313,23 @@ public GrpcCallContext withStreamWaitTimeout(@Nullable Duration streamWaitTimeou
endpointContext);
}

/**
* This method is obsolete. Use {@link #withStreamIdleTimeoutDuration(java.time.Duration)}
* instead.
*/
@Override
@ObsoleteApi("Use withStreamIdleTimeoutDuration(java.time.Duration) instead")
public GrpcCallContext withStreamIdleTimeout(
@Nullable org.threeten.bp.Duration streamIdleTimeout) {
return withStreamIdleTimeoutDuration(toJavaTimeDuration(streamIdleTimeout));
}

@Override
public GrpcCallContext withStreamIdleTimeout(@Nullable Duration streamIdleTimeout) {
public GrpcCallContext withStreamIdleTimeoutDuration(
@Nullable java.time.Duration streamIdleTimeout) {
if (streamIdleTimeout != null) {
Preconditions.checkArgument(
streamIdleTimeout.compareTo(Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
streamIdleTimeout.compareTo(java.time.Duration.ZERO) >= 0, "Invalid timeout: < 0 s");
}

return new GrpcCallContext(
Expand Down Expand Up @@ -424,17 +466,17 @@ public ApiCallContext merge(ApiCallContext inputCallContext) {
newTracer = callOptions.getOption(TRACER_KEY);
}

Duration newTimeout = grpcCallContext.timeout;
java.time.Duration newTimeout = grpcCallContext.timeout;
if (newTimeout == null) {
newTimeout = timeout;
}

Duration newStreamWaitTimeout = grpcCallContext.streamWaitTimeout;
java.time.Duration newStreamWaitTimeout = grpcCallContext.streamWaitTimeout;
if (newStreamWaitTimeout == null) {
newStreamWaitTimeout = streamWaitTimeout;
}

Duration newStreamIdleTimeout = grpcCallContext.streamIdleTimeout;
java.time.Duration newStreamIdleTimeout = grpcCallContext.streamIdleTimeout;
if (newStreamIdleTimeout == null) {
newStreamIdleTimeout = streamIdleTimeout;
}
Expand Down Expand Up @@ -496,25 +538,40 @@ public CallOptions getCallOptions() {
return callOptions;
}

/** This method is obsolete. Use {@link #getStreamWaitTimeoutDuration()} instead. */
@Override
@Nullable
@ObsoleteApi("Use getStreamWaitTimeoutDuration() instead")
public org.threeten.bp.Duration getStreamWaitTimeout() {
return toThreetenDuration(getStreamWaitTimeoutDuration());
}

/**
* The stream wait timeout set for this context.
*
* @see ApiCallContext#withStreamWaitTimeout(Duration)
* @see ApiCallContext#withStreamWaitTimeoutDuration(java.time.Duration)
*/
@Override
@Nullable
public Duration getStreamWaitTimeout() {
public java.time.Duration getStreamWaitTimeoutDuration() {
return streamWaitTimeout;
}

/** This method is obsolete. Use {@link #getStreamIdleTimeoutDuration()} instead. */
@Override
@Nullable
@ObsoleteApi("Use getStreamIdleTimeoutDuration() instead")
public org.threeten.bp.Duration getStreamIdleTimeout() {
return toThreetenDuration(getStreamIdleTimeoutDuration());
}
/**
* The stream idle timeout set for this context.
*
* @see ApiCallContext#withStreamIdleTimeout(Duration)
* @see ApiCallContext#withStreamIdleTimeoutDuration(java.time.Duration)
*/
@Override
@Nullable
public Duration getStreamIdleTimeout() {
public java.time.Duration getStreamIdleTimeoutDuration() {
return streamIdleTimeout;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ public static <RequestT, ResponseT> ClientCall<RequestT, ResponseT> newCall(
Preconditions.checkNotNull(callOptions);

// Try to convert the timeout into a deadline and use it if it occurs before the actual deadline
if (grpcContext.getTimeout() != null) {
if (grpcContext.getTimeoutDuration() != null) {
Deadline newDeadline =
Deadline.after(grpcContext.getTimeout().toMillis(), TimeUnit.MILLISECONDS);
Deadline.after(grpcContext.getTimeoutDuration().toMillis(), TimeUnit.MILLISECONDS);
Deadline oldDeadline = callOptions.getDeadline();

if (oldDeadline == null || newDeadline.isBefore(oldDeadline)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@
*/
package com.google.api.gax.grpc;

import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;
import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration;

import com.google.api.core.ApiFunction;
import com.google.api.core.BetaApi;
import com.google.api.core.InternalApi;
import com.google.api.core.ObsoleteApi;
import com.google.api.gax.core.ExecutorProvider;
import com.google.api.gax.rpc.FixedHeaderProvider;
import com.google.api.gax.rpc.HeaderProvider;
Expand Down Expand Up @@ -67,7 +71,6 @@
import java.util.logging.Logger;
import javax.annotation.Nullable;
import javax.net.ssl.KeyManagerFactory;
import org.threeten.bp.Duration;

/**
* InstantiatingGrpcChannelProvider is a TransportChannelProvider which constructs a gRPC
Expand Down Expand Up @@ -106,8 +109,8 @@ public final class InstantiatingGrpcChannelProvider implements TransportChannelP
@Nullable private final GrpcInterceptorProvider interceptorProvider;
@Nullable private final Integer maxInboundMessageSize;
@Nullable private final Integer maxInboundMetadataSize;
@Nullable private final Duration keepAliveTime;
@Nullable private final Duration keepAliveTimeout;
@Nullable private final java.time.Duration keepAliveTime;
@Nullable private final java.time.Duration keepAliveTimeout;
@Nullable private final Boolean keepAliveWithoutCalls;
private final ChannelPoolSettings channelPoolSettings;
@Nullable private final Credentials credentials;
Expand Down Expand Up @@ -490,13 +493,25 @@ public String getEndpoint() {
return endpoint;
}

/** This method is obsolete. Use {@link #getKeepAliveTimeDuration()} instead. */
@ObsoleteApi("Use getKeepAliveTimeDuration() instead")
public org.threeten.bp.Duration getKeepAliveTime() {
return toThreetenDuration(getKeepAliveTimeDuration());
}

/** The time without read activity before sending a keepalive ping. */
public Duration getKeepAliveTime() {
public java.time.Duration getKeepAliveTimeDuration() {
return keepAliveTime;
}

/** This method is obsolete. Use {@link #getKeepAliveTimeoutDuration()} instead */
@ObsoleteApi("Use getKeepAliveTimeoutDuration() instead")
public org.threeten.bp.Duration getKeepAliveTimeout() {
return toThreetenDuration(getKeepAliveTimeoutDuration());
}

/** The time without read activity after sending a keepalive ping. */
public Duration getKeepAliveTimeout() {
public java.time.Duration getKeepAliveTimeoutDuration() {
return keepAliveTimeout;
}

Expand Down Expand Up @@ -540,8 +555,8 @@ public static final class Builder {
@Nullable private GrpcInterceptorProvider interceptorProvider;
@Nullable private Integer maxInboundMessageSize;
@Nullable private Integer maxInboundMetadataSize;
@Nullable private Duration keepAliveTime;
@Nullable private Duration keepAliveTimeout;
@Nullable private java.time.Duration keepAliveTime;
@Nullable private java.time.Duration keepAliveTimeout;
@Nullable private Boolean keepAliveWithoutCalls;
@Nullable private ApiFunction<ManagedChannelBuilder, ManagedChannelBuilder> channelConfigurator;
@Nullable private Credentials credentials;
Expand Down Expand Up @@ -679,25 +694,53 @@ public Integer getMaxInboundMetadataSize() {
return maxInboundMetadataSize;
}

/**
* This method is obsolete. Use {@link #setKeepAliveTimeDuration(java.time.Duration)} instead.
*/
@ObsoleteApi("Use setKeepAliveTimeDuration(java.time.Duration) instead")
public Builder setKeepAliveTime(org.threeten.bp.Duration duration) {
return setKeepAliveTimeDuration(toJavaTimeDuration(duration));
}
/** The time without read activity before sending a keepalive ping. */
public Builder setKeepAliveTime(Duration duration) {
public Builder setKeepAliveTimeDuration(java.time.Duration duration) {
this.keepAliveTime = duration;
return this;
}

/** This method is obsolete. Use {@link #getKeepAliveTimeDuration()} instead. */
@ObsoleteApi("Use getKeepAliveTimeDuration() instead")
public org.threeten.bp.Duration getKeepAliveTime() {
return toThreetenDuration(getKeepAliveTimeDuration());
}

/** The time without read activity before sending a keepalive ping. */
public Duration getKeepAliveTime() {
public java.time.Duration getKeepAliveTimeDuration() {
return keepAliveTime;
}

/**
* This method is obsolete. Use {@link #setKeepAliveTimeoutDuration(java.time.Duration)}
* instead.
*/
@ObsoleteApi("Use setKeepAliveTimeoutDuration(java.time.Duration) instead")
public Builder setKeepAliveTimeout(org.threeten.bp.Duration duration) {
return setKeepAliveTimeoutDuration(toJavaTimeDuration(duration));
}

/** The time without read activity after sending a keepalive ping. */
public Builder setKeepAliveTimeout(Duration duration) {
public Builder setKeepAliveTimeoutDuration(java.time.Duration duration) {
this.keepAliveTimeout = duration;
return this;
}

/** This method is obsolete. Use {@link #getKeepAliveTimeoutDuration()} instead */
@ObsoleteApi("Use getKeepAliveTimeoutDuration() instead")
public org.threeten.bp.Duration getKeepAliveTimeout() {
return toThreetenDuration(getKeepAliveTimeoutDuration());
}

/** The time without read activity after sending a keepalive ping. */
public Duration getKeepAliveTimeout() {
public java.time.Duration getKeepAliveTimeoutDuration() {
return keepAliveTimeout;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import com.google.longrunning.WaitOperationRequest;
import com.google.protobuf.Empty;
import java.io.IOException;
import org.threeten.bp.Duration;

/** Settings class to configure an instance of {@link OperationsStub}. */
public class OperationsStubSettings extends StubSettings<OperationsStubSettings> {
Expand Down Expand Up @@ -243,13 +242,13 @@ public static class Builder extends StubSettings.Builder<OperationsStubSettings,
RetrySettings settings = null;
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setInitialRetryDelayDuration(java.time.Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(90000L))
.setMaxRetryDelayDuration(java.time.Duration.ofMillis(60000L))
.setInitialRpcTimeoutDuration(java.time.Duration.ofMillis(90000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(90000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.setMaxRpcTimeoutDuration(java.time.Duration.ofMillis(90000L))
.setTotalTimeoutDuration(java.time.Duration.ofMillis(600000L))
.build();
definitions.put("default", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
Expand Down
Loading

0 comments on commit 308aeaf

Please sign in to comment.