Repository: googleapis/java-datastore
Pull request #1673 (2024-11-21 02:26:03)

chore: Update generation configuration at Sat Dec  7 02:27:08 UTC 2024
This pull request is generated with proto changes between [googleapis/googleapis@a547fc1](https://github.com/googleapis/googleapis/commit/a547fc1420eb0a0f3ae32b0a4eb72d3b8b17d136) (exclusive) and [googleapis/googleapis@0f3a20e](https://github.com/googleapis/googleapis/commit/0f3a20ebd29fb1deb2bd1f75c7ba55500d35457d) (inclusive).

BEGIN_COMMIT_OVERRIDE
BEGIN_NESTED_COMMIT
chore: update the libraries_bom version to 26.51.0
END_NESTED_COMMIT
END_COMMIT_OVERRIDE


Patch:
diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml
index ab421dce..20364434 100644
--- a/.github/sync-repo-settings.yaml
+++ b/.github/sync-repo-settings.yaml
@@ -19,6 +19,7 @@ branchProtectionRules:
       - 'Kokoro - Test: Java 17 GraalVM Native Image'
       - javadoc
       - library_generation
+      - unmanaged_dependency_check
   - pattern: 1.106.5-sp
     isAdminEnforced: true
     requiredApprovingReviewCount: 1
diff --git a/.readme-partials.yaml b/.readme-partials.yaml
index ced21e49..3e8d3a46 100644
--- a/.readme-partials.yaml
+++ b/.readme-partials.yaml
@@ -110,28 +110,33 @@ custom_content: |
   -------
   In this feature launch, the [Java Datastore client](https://github.com/googleapis/java-datastore) now offers gRPC as a transport layer option with experimental support. Using [gRPC connection pooling](https://grpc.io/docs/guides/performance/) enables distributing RPCs over multiple connections which may improve performance.
   
-  #### Download Instructions
-  Instructions:
-  1. Clone the grpc-experimental branch from GitHub:
-  ```python
-  git clone -b grpc-experimental https://github.com/googleapis/java-datastore.git
-  ```
-  2. Run the following commands to build the library:
-  ```python
-  # Go to the directory the code was downloaded to
-  cd java-datastore/
-  
-  # Build the library
-  mvn clean install -DskipTests=true
-  ```
-  3. Add the following dependency to your project:
-  ```xml
-  <dependency>
+  #### Installation Instructions
+  The client can be built from the `grpc-experimental` branch on GitHub. For private preview, you can also download the artifact with the instructions provided below.
+
+  1. Download the datastore private preview package with dependencies:
+    ```
+    curl -o <path-to-downloaded-jar>  https://datastore-sdk-feature-release.web.app/google-cloud-datastore-2.20.0-grpc-experimental-1-SNAPSHOT-jar-with-dependencies.jar
+    ```
+  2. Run the following commands to install JDK locally:
+    ```
+    mvn install:install-file -Dfile=<path-to-downloaded-jar> -DgroupId=com.google.cloud -DartifactId=google-cloud-datastore -Dversion=2.20.0-grpc
+    ```
+  3. Edit your pom.xml to add above package to `<dependencies/>` section:
+    ```xml
+    <dependency>
     <groupId>com.google.cloud</groupId>
     <artifactId>google-cloud-datastore</artifactId>
     <version>2.20.0-grpc-experimental-1-SNAPSHOT</version>
-  </dependency>
-  ```
+    </dependency>
+    ```
+  
+  And if you have not yet, add below to `<repositories/>` section:
+    ```xml
+    <repository>
+    <id>local-repo</id>
+    <url>file://${user.home}/.m2/repository</url>
+    </repository>
+    ```
   
   #### How to Use
   To opt-in to the gRPC transport behavior, simply add the below line of code (`setTransportOptions`) to your Datastore client instantiation.
@@ -181,11 +186,44 @@ custom_content: |
   #### New Features
   There are new gRPC specific features available to use in this update.
   
-  ##### Channel Pooling
-  To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions. 
+  ##### Connection Pool
+  A connection pool, also known as a channel pool, is a cache of database connections that are shared and reused to improve connection latency and performance. With this update, now you will be able to configure the channel pool to improve application performance. This section guides you in determining the optimal connection pool size and configuring it within the Java datastore client.
+  To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions.
+  ###### Determine the best connection pool size
+  The default connection pool size is right for most applications, and in most cases there's no need to change it.
+  
+  However sometimes you may want to change your connection pool size due to high throughput or buffered requests. Ideally, to leave room for traffic fluctuations, a connection pool has about twice the number of connections it takes for maximum saturation. Because a connection can handle a maximum of 100 concurrent requests, between 10 and 50 outstanding requests per connection is optimal. The limit of 100 concurrent streams per gRPC connection is enforced in Google's middleware layer, and you are not able to reconfigure this number.
+  
+  The following steps help you calculate the optimal number of connections in your channel pool using estimate per-client QPS and average latency numbers.
+
+  To calculate the optimal connections, gather the following information:
+
+  1. The maximum number of queries per second (QPS) per client when your application is running a typical workload.
+  2. The average latency (the response time for a single request) in ms.
+  3. Determine the number of requests that you can send serially per second by dividing 1,000 by the average latency value.
+  4. Divide the QPS in seconds by the number of serial requests per second.
+  5. Divide the result by 50 requests per channel to determine the minimum optimal channel pool size. (If your calculation is less than 2, use at least 2 channels anyway, to ensure redundancy.)
+  6. Divide the same result by 10 requests per channel to determine the maximum optimal channel pool size.
+
+  These steps are expressed in the following equations:
+  ```java
+  (QPS ÷ (1,000 ÷ latency ms)) ÷ 50 streams = Minimum optimal number of connections
+  (QPS ÷ (1,000 ÷ latency ms)) ÷ 10 streams = Maximum optimal number of connections
+  ```
+
+  ###### Example
+  Your application typically sends 50,000 requests per second, and the average latency is 10 ms. Divide 1,000 by 10 ms to determine that you can send 100 requests serially per second.
+  Divide that number into 50,000 to get the parallelism needed to send 50,000 QPS: 500. Each channel can have at most 100 requests out concurrently, and your target channel utilization
+  is between 10 and 50 concurrent streams. Therefore, to calculate the minimum, divide 500 by 50 to get 10. To find the maximum, divide 500 by 10 to get 50. This means that your channel
+  pool size for this example should be between 10 and 50 connections.
+
+  It is also important to monitor your traffic after making changes and adjust the number of connections in your pool if necessary.
+  
+  ###### Set the pool size
+  The following code sample demonstrates how to configure the channel pool in the client libraries using `DatastoreOptions`.
   See [ChannelPoolSettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.ChannelPoolSettings) and [Performance Best Practices](https://grpc.io/docs/guides/performance/) for more information on channel pools and best practices for performance.
   
-  Example:
+  Code Example
   ```java
   InstantiatingGrpcChannelProvider channelProvider =
         DatastoreSettings.defaultGrpcTransportProviderBuilder()
diff --git a/README.md b/README.md
index f059e75e..780b96e7 100644
--- a/README.md
+++ b/README.md
@@ -49,7 +49,7 @@ If you are using Maven without the BOM, add this to your dependencies:
 If you are using Gradle 5.x or later, add this to your dependencies:
 
 ```Groovy
-implementation platform('com.google.cloud:libraries-bom:26.50.0')
+implementation platform('com.google.cloud:libraries-bom:26.51.0')
 
 implementation 'com.google.cloud:google-cloud-datastore'
 ```
@@ -208,28 +208,33 @@ gRPC Java Datastore Client User Guide
 -------
 In this feature launch, the [Java Datastore client](https://github.com/googleapis/java-datastore) now offers gRPC as a transport layer option with experimental support. Using [gRPC connection pooling](https://grpc.io/docs/guides/performance/) enables distributing RPCs over multiple connections which may improve performance.
 
-#### Download Instructions
-Instructions:
-1. Clone the grpc-experimental branch from GitHub:
-```python
-git clone -b grpc-experimental https://github.com/googleapis/java-datastore.git
-```
-2. Run the following commands to build the library:
-```python
-# Go to the directory the code was downloaded to
-cd java-datastore/
-
-# Build the library
-mvn clean install -DskipTests=true
-```
-3. Add the following dependency to your project:
-```xml
-<dependency>
+#### Installation Instructions
+The client can be built from the `grpc-experimental` branch on GitHub. For private preview, you can also download the artifact with the instructions provided below.
+
+1. Download the datastore private preview package with dependencies:
+  ```
+  curl -o <path-to-downloaded-jar>  https://datastore-sdk-feature-release.web.app/google-cloud-datastore-2.20.0-grpc-experimental-1-SNAPSHOT-jar-with-dependencies.jar
+  ```
+2. Run the following commands to install JDK locally:
+  ```
+  mvn install:install-file -Dfile=<path-to-downloaded-jar> -DgroupId=com.google.cloud -DartifactId=google-cloud-datastore -Dversion=2.20.0-grpc
+  ```
+3. Edit your pom.xml to add above package to `<dependencies/>` section:
+  ```xml
+  <dependency>
   <groupId>com.google.cloud</groupId>
   <artifactId>google-cloud-datastore</artifactId>
   <version>2.20.0-grpc-experimental-1-SNAPSHOT</version>
-</dependency>
-```
+  </dependency>
+  ```
+
+And if you have not yet, add below to `<repositories/>` section:
+  ```xml
+  <repository>
+  <id>local-repo</id>
+  <url>file://${user.home}/.m2/repository</url>
+  </repository>
+  ```
 
 #### How to Use
 To opt-in to the gRPC transport behavior, simply add the below line of code (`setTransportOptions`) to your Datastore client instantiation.
@@ -279,11 +284,44 @@ boolean isHTTP = datastore.getOptions().getTransportOptions() instanceof HTTPTra
 #### New Features
 There are new gRPC specific features available to use in this update.
 
-##### Channel Pooling
-To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions. 
+##### Connection Pool
+A connection pool, also known as a channel pool, is a cache of database connections that are shared and reused to improve connection latency and performance. With this update, now you will be able to configure the channel pool to improve application performance. This section guides you in determining the optimal connection pool size and configuring it within the Java datastore client.
+To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions.
+###### Determine the best connection pool size
+The default connection pool size is right for most applications, and in most cases there's no need to change it.
+
+However sometimes you may want to change your connection pool size due to high throughput or buffered requests. Ideally, to leave room for traffic fluctuations, a connection pool has about twice the number of connections it takes for maximum saturation. Because a connection can handle a maximum of 100 concurrent requests, between 10 and 50 outstanding requests per connection is optimal. The limit of 100 concurrent streams per gRPC connection is enforced in Google's middleware layer, and you are not able to reconfigure this number.
+
+The following steps help you calculate the optimal number of connections in your channel pool using estimate per-client QPS and average latency numbers.
+
+To calculate the optimal connections, gather the following information:
+
+1. The maximum number of queries per second (QPS) per client when your application is running a typical workload.
+2. The average latency (the response time for a single request) in ms.
+3. Determine the number of requests that you can send serially per second by dividing 1,000 by the average latency value.
+4. Divide the QPS in seconds by the number of serial requests per second.
+5. Divide the result by 50 requests per channel to determine the minimum optimal channel pool size. (If your calculation is less than 2, use at least 2 channels anyway, to ensure redundancy.)
+6. Divide the same result by 10 requests per channel to determine the maximum optimal channel pool size.
+
+These steps are expressed in the following equations:
+```java
+(QPS ÷ (1,000 ÷ latency ms)) ÷ 50 streams = Minimum optimal number of connections
+(QPS ÷ (1,000 ÷ latency ms)) ÷ 10 streams = Maximum optimal number of connections
+```
+
+###### Example
+Your application typically sends 50,000 requests per second, and the average latency is 10 ms. Divide 1,000 by 10 ms to determine that you can send 100 requests serially per second.
+Divide that number into 50,000 to get the parallelism needed to send 50,000 QPS: 500. Each channel can have at most 100 requests out concurrently, and your target channel utilization
+is between 10 and 50 concurrent streams. Therefore, to calculate the minimum, divide 500 by 50 to get 10. To find the maximum, divide 500 by 10 to get 50. This means that your channel
+pool size for this example should be between 10 and 50 connections.
+
+It is also important to monitor your traffic after making changes and adjust the number of connections in your pool if necessary.
+
+###### Set the pool size
+The following code sample demonstrates how to configure the channel pool in the client libraries using `DatastoreOptions`.
 See [ChannelPoolSettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.ChannelPoolSettings) and [Performance Best Practices](https://grpc.io/docs/guides/performance/) for more information on channel pools and best practices for performance.
 
-Example:
+Code Example
 ```java
 InstantiatingGrpcChannelProvider channelProvider =
       DatastoreSettings.defaultGrpcTransportProviderBuilder()
diff --git a/generation_config.yaml b/generation_config.yaml
index b9de0b01..d7067bcd 100644
--- a/generation_config.yaml
+++ b/generation_config.yaml
@@ -1,6 +1,6 @@
 gapic_generator_version: 2.50.0
-googleapis_commitish: a547fc1420eb0a0f3ae32b0a4eb72d3b8b17d136
-libraries_bom_version: 26.50.0
+googleapis_commitish: 0f3a20ebd29fb1deb2bd1f75c7ba55500d35457d
+libraries_bom_version: 26.51.0
 libraries:
   - api_shortname: datastore
     name_pretty: Cloud Datastore
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExecutionStats.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExecutionStats.java
index 52184a01..6738d84e 100644
--- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExecutionStats.java
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExecutionStats.java
@@ -15,25 +15,27 @@
  */
 package com.google.cloud.datastore.models;
 
+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.cloud.Structs;
 import com.google.common.base.Objects;
 import java.util.Map;
-import org.threeten.bp.Duration;
 
 /** Model class for {@link com.google.datastore.v1.ExecutionStats} */
 @BetaApi
 public class ExecutionStats {
   private final long resultsReturned;
-  private final Duration executionDuration;
+  private final java.time.Duration executionDuration;
   private final long readOperations;
   private final Map<String, Object> debugStats;
 
   @InternalApi
   public ExecutionStats(com.google.datastore.v1.ExecutionStats proto) {
     this.resultsReturned = proto.getResultsReturned();
-    this.executionDuration = Duration.ofNanos(proto.getExecutionDuration().getNanos());
+    this.executionDuration = java.time.Duration.ofNanos(proto.getExecutionDuration().getNanos());
     this.readOperations = proto.getReadOperations();
     this.debugStats = Structs.asMap(proto.getDebugStats());
   }
@@ -51,8 +53,14 @@ public class ExecutionStats {
     return debugStats;
   }
 
+  /** This method is obsolete. Use {@link #getExecutionDurationJavaTime()} instead. */
+  @ObsoleteApi("Use getExecutionDurationJavaTime() instead")
+  public org.threeten.bp.Duration getExecutionDuration() {
+    return toThreetenDuration(getExecutionDurationJavaTime());
+  }
+
   /** Returns the total time to execute the query in the backend. */
-  public Duration getExecutionDuration() {
+  public java.time.Duration getExecutionDurationJavaTime() {
     return executionDuration;
   }
 
diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml
index d31d40cb..95c5f4db 100644
--- a/samples/snippets/pom.xml
+++ b/samples/snippets/pom.xml
@@ -30,7 +30,7 @@
       <dependency>
         <groupId>com.google.cloud</groupId>
         <artifactId>libraries-bom</artifactId>
-        <version>26.50.0</version>
+        <version>26.51.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>


Test patch:
diff --git a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java
index 2723325e..32bf9611 100644
--- a/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java
+++ b/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java
@@ -16,9 +16,11 @@
 
 package com.google.cloud.datastore.testing;
 
+import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration;
 import static com.google.common.base.MoreObjects.firstNonNull;
 
 import com.google.api.core.InternalApi;
+import com.google.api.core.ObsoleteApi;
 import com.google.cloud.NoCredentials;
 import com.google.cloud.ServiceOptions;
 import com.google.cloud.datastore.DatastoreOptions;
@@ -38,7 +40,6 @@ import java.util.List;
 import java.util.UUID;
 import java.util.concurrent.TimeoutException;
 import java.util.logging.Logger;
-import org.threeten.bp.Duration;
 
 /**
  * Utility to start and stop local Google Cloud Datastore emulators.
@@ -307,6 +308,14 @@ public class LocalDatastoreHelper extends BaseEmulatorHelper<DatastoreOptions> {
     sendPostRequest("/reset");
   }
 
+  /** This method is obsolete. Use {@link #stopDuration(java.time.Duration)} instead */
+  @ObsoleteApi("Use stopDuration(java.time.Duration) instead")
+  @Override
+  public void stop(org.threeten.bp.Duration timeout)
+      throws IOException, InterruptedException, TimeoutException {
+    stopDuration(toJavaTimeDuration(timeout));
+  }
+
   /**
    * Stops the Datastore emulator.
    *
@@ -319,15 +328,16 @@ public class LocalDatastoreHelper extends BaseEmulatorHelper<DatastoreOptions> {
    *     this value high to ensure proper shutdown, like 5 seconds or more.
    */
   @Override
-  public void stop(Duration timeout) throws IOException, InterruptedException, TimeoutException {
+  public void stopDuration(java.time.Duration timeout)
+      throws IOException, InterruptedException, TimeoutException {
     sendPostRequest("/shutdown");
-    waitForProcess(timeout);
+    waitForProcessDuration(timeout);
     deleteRecursively(gcdPath);
   }
 
   /**
-   * Stops the Datastore emulator. The same as {@link #stop(Duration)} but with timeout duration of
-   * 20 seconds.
+   * Stops the Datastore emulator. The same as {@link #stopDuration(java.time.Duration)} but with
+   * timeout duration of 20 seconds.
    *
    * <p>It is important to stop the emulator. Since the emulator runs in its own process, not
    * stopping it might cause it to become orphan.
@@ -335,7 +345,7 @@ public class LocalDatastoreHelper extends BaseEmulatorHelper<DatastoreOptions> {
    * <p>It is not required to call {@link #reset()} before {@code stop()}.
    */
   public void stop() throws IOException, InterruptedException, TimeoutException {
-    stop(Duration.ofSeconds(20));
+    stopDuration(java.time.Duration.ofSeconds(20));
   }
 
   static void deleteRecursively(Path path) throws IOException {
diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTest.java
index d88e1d1e..459278f2 100644
--- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTest.java
+++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTest.java
@@ -68,6 +68,7 @@ import com.google.datastore.v1.RunQueryResponse;
 import com.google.datastore.v1.TransactionOptions;
 import com.google.protobuf.ByteString;
 import java.io.IOException;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -87,7 +88,6 @@ import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
-import org.threeten.bp.Duration;
 
 @RunWith(JUnit4.class)
 public class DatastoreTest {
@@ -193,7 +193,7 @@ public class DatastoreTest {
 
   @AfterClass
   public static void afterClass() throws IOException, InterruptedException, TimeoutException {
-    helper.stop(Duration.ofMinutes(1));
+    helper.stopDuration(Duration.ofMinutes(1));
   }
 
   @Test
diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java
index c012d28c..bf0c20dc 100644
--- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java
+++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTest.java
@@ -81,6 +81,7 @@ import com.google.common.collect.Range;
 import com.google.common.truth.Truth;
 import com.google.datastore.v1.TransactionOptions;
 import com.google.datastore.v1.TransactionOptions.ReadOnly;
+import java.time.Duration;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -103,7 +104,6 @@ import org.junit.Test;
 import org.junit.rules.Timeout;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
-import org.threeten.bp.Duration;
 
 @RunWith(Parameterized.class)
 public class ITDatastoreTest {
@@ -674,7 +674,7 @@ public class ITDatastoreTest {
     Truth.assertThat(debugStats.get("index_entries_scanned"))
         .isEqualTo(expectedIndexEntriesScanned);
 
-    Duration executionDuration = executionStats.getExecutionDuration();
+    Duration executionDuration = executionStats.getExecutionDurationJavaTime();
     Truth.assertThat(executionDuration).isIn(Range.greaterThan(Duration.ofMillis(0)));
 
     long readOperations = executionStats.getReadOperations();
diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExecutionStatsTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExecutionStatsTest.java
index 4706e3b8..a0e778ce 100644
--- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExecutionStatsTest.java
+++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExecutionStatsTest.java
@@ -41,8 +41,8 @@ public class ExecutionStatsTest {
   @Test
   public void testModel() {
     Truth.assertThat(executionStats.getDebugStats()).isEqualTo(Structs.asMap(struct));
-    Truth.assertThat(executionStats.getExecutionDuration())
-        .isEqualTo(org.threeten.bp.Duration.ofNanos(duration.getNanos()));
+    Truth.assertThat(executionStats.getExecutionDurationJavaTime())
+        .isEqualTo(java.time.Duration.ofNanos(duration.getNanos()));
     Truth.assertThat(executionStats.getReadOperations()).isEqualTo(2);
     Truth.assertThat(executionStats.getResultsReturned()).isEqualTo(3);
   }
diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/ITLocalDatastoreHelperTest.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/ITLocalDatastoreHelperTest.java
index 3ebd3ef4..dfa2255a 100644
--- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/ITLocalDatastoreHelperTest.java
+++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/ITLocalDatastoreHelperTest.java
@@ -32,6 +32,7 @@ import com.google.cloud.datastore.Key;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.time.Duration;
 import java.util.concurrent.TimeoutException;
 import org.junit.After;
 import org.junit.Assert;
@@ -39,7 +40,6 @@ import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
-import org.threeten.bp.Duration;
 
 @RunWith(JUnit4.class)
 public class ITLocalDatastoreHelperTest {
@@ -178,7 +178,7 @@ public class ITLocalDatastoreHelperTest {
       assertNotNull(datastore.get(key));
       helper.reset();
       assertNull(datastore.get(key));
-      helper.stop(Duration.ofMinutes(1));
+      helper.stopDuration(Duration.ofMinutes(1));
       datastore.get(key);
       Assert.fail();
     } catch (DatastoreException ex) {
@@ -198,7 +198,7 @@ public class ITLocalDatastoreHelperTest {
       assertNotNull(datastore.get(key));
       helper.reset();
       assertNull(datastore.get(key));
-      helper.stop(Duration.ofMinutes(1));
+      helper.stopDuration(Duration.ofMinutes(1));
       datastore.get(key);
       Assert.fail();
     } catch (DatastoreException ex) {
diff --git a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java
index 6167cedc..a4b389a1 100644
--- a/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java
+++ b/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java
@@ -27,9 +27,9 @@ import com.google.cloud.datastore.QueryResults;
 import com.google.cloud.datastore.StructuredQuery;
 import com.google.cloud.http.HttpTransportOptions;
 import io.opentelemetry.sdk.OpenTelemetrySdk;
+import java.time.Duration;
 import java.util.UUID;
 import javax.annotation.Nullable;
-import org.threeten.bp.Duration;
 
 /**
  * Utility to create a remote datastore configuration for testing. Datastore options can be obtained
@@ -110,13 +110,13 @@ public class RemoteDatastoreHelper {
   private static RetrySettings retrySettings() {
     return RetrySettings.newBuilder()
         .setMaxAttempts(10)
-        .setMaxRetryDelay(Duration.ofMillis(30000L))
-        .setTotalTimeout(Duration.ofMillis(120000L))
-        .setInitialRetryDelay(Duration.ofMillis(250L))
+        .setMaxRetryDelayDuration(Duration.ofMillis(30000L))
+        .setTotalTimeoutDuration(Duration.ofMillis(120000L))
+        .setInitialRetryDelayDuration(Duration.ofMillis(250L))
         .setRetryDelayMultiplier(1.0)
-        .setInitialRpcTimeout(Duration.ofMillis(120000L))
+        .setInitialRpcTimeoutDuration(Duration.ofMillis(120000L))
         .setRpcTimeoutMultiplier(1.0)
-        .setMaxRpcTimeout(Duration.ofMillis(120000L))
+        .setMaxRpcTimeoutDuration(Duration.ofMillis(120000L))
         .build();
   }
 }
diff --git a/samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java b/samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java
index 045b16a9..33aa63ab 100644
--- a/samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java
+++ b/samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java
@@ -77,7 +77,6 @@ import org.junit.Test;
 import org.junit.rules.ExpectedException;
 import org.junit.runner.RunWith;
 import org.junit.runners.JUnit4;
-import org.threeten.bp.Duration;
 
 /** Contains Cloud Datastore snippets demonstrating concepts for documentation. */
 @RunWith(JUnit4.class)
@@ -147,7 +146,7 @@ public class ConceptsTest {
    */
   @AfterClass
   public static void afterClass() throws IOException, InterruptedException, TimeoutException {
-    HELPER.stop(Duration.ofMinutes(1));
+    HELPER.stopDuration(java.time.Duration.ofMinutes(1));
   }
 
   private void assertValidKey(Key taskKey) {