|
17 | 17 | package tpu; |
18 | 18 |
|
19 | 19 | //[START tpu_vm_create_topology] |
20 | | -import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; |
21 | | -import com.google.api.gax.retrying.RetrySettings; |
22 | 20 | import com.google.cloud.tpu.v2.AcceleratorConfig; |
23 | 21 | import com.google.cloud.tpu.v2.AcceleratorConfig.Type; |
24 | 22 | import com.google.cloud.tpu.v2.CreateNodeRequest; |
25 | 23 | import com.google.cloud.tpu.v2.Node; |
26 | 24 | import com.google.cloud.tpu.v2.TpuClient; |
27 | | -import com.google.cloud.tpu.v2.TpuSettings; |
28 | 25 | import java.io.IOException; |
29 | 26 | import java.util.concurrent.ExecutionException; |
30 | | -import org.threeten.bp.Duration; |
31 | 27 |
|
32 | 28 | public class CreateTpuWithTopologyFlag { |
33 | 29 |
|
@@ -60,29 +56,10 @@ public static void main(String[] args) |
60 | 56 | public static Node createTpuWithTopologyFlag(String projectId, String zone, String nodeName, |
61 | 57 | Type tpuVersion, String tpuSoftwareVersion, String topology) |
62 | 58 | throws IOException, ExecutionException, InterruptedException { |
63 | | - // With these settings the client library handles the Operation's polling mechanism |
64 | | - // and prevent CancellationException error |
65 | | - TpuSettings.Builder clientSettings = |
66 | | - TpuSettings.newBuilder(); |
67 | | - clientSettings |
68 | | - .createNodeOperationSettings() |
69 | | - .setPollingAlgorithm( |
70 | | - OperationTimedPollAlgorithm.create( |
71 | | - RetrySettings.newBuilder() |
72 | | - .setInitialRetryDelay(Duration.ofMillis(5000L)) |
73 | | - .setRetryDelayMultiplier(1.5) |
74 | | - .setMaxRetryDelay(Duration.ofMillis(45000L)) |
75 | | - .setInitialRpcTimeout(Duration.ZERO) |
76 | | - .setRpcTimeoutMultiplier(1.0) |
77 | | - .setMaxRpcTimeout(Duration.ZERO) |
78 | | - .setTotalTimeout(Duration.ofHours(24L)) |
79 | | - .build())); |
80 | | - |
81 | 59 | // Initialize client that will be used to send requests. This client only needs to be created |
82 | 60 | // once, and can be reused for multiple requests. |
83 | | - try (TpuClient tpuClient = TpuClient.create(clientSettings.build())) { |
| 61 | + try (TpuClient tpuClient = TpuClient.create()) { |
84 | 62 | String parent = String.format("projects/%s/locations/%s", projectId, zone); |
85 | | - |
86 | 63 | Node tpuVm = |
87 | 64 | Node.newBuilder() |
88 | 65 | .setName(nodeName) |
|
0 commit comments