1717package tpu ;
1818
1919//[START tpu_queued_resources_create]
20- import com .google .api .gax .retrying .RetrySettings ;
2120import com .google .cloud .tpu .v2alpha1 .CreateQueuedResourceRequest ;
2221import com .google .cloud .tpu .v2alpha1 .Node ;
2322import com .google .cloud .tpu .v2alpha1 .QueuedResource ;
2423import com .google .cloud .tpu .v2alpha1 .TpuClient ;
25- import com .google .cloud .tpu .v2alpha1 .TpuSettings ;
2624import java .io .IOException ;
2725import java .util .concurrent .ExecutionException ;
2826import java .util .concurrent .TimeUnit ;
2927import java .util .concurrent .TimeoutException ;
30- import org .threeten .bp .Duration ;
3128
3229public class CreateQueuedResource {
3330 public static void main (String [] args )
@@ -59,26 +56,11 @@ public static void main(String[] args)
5956 public static QueuedResource createQueuedResource (String projectId , String zone ,
6057 String queuedResourceId , String nodeName , String tpuType , String tpuSoftwareVersion )
6158 throws IOException , ExecutionException , InterruptedException , TimeoutException {
62- // With these settings the client library handles the Operation's polling mechanism
63- // and prevent CancellationException error
64- TpuSettings .Builder clientSettings =
65- TpuSettings .newBuilder ();
66- clientSettings
67- .createQueuedResourceSettings ()
68- .setRetrySettings (
69- RetrySettings .newBuilder ()
70- .setInitialRetryDelay (Duration .ofMillis (5000L ))
71- .setRetryDelayMultiplier (2.0 )
72- .setInitialRpcTimeout (Duration .ZERO )
73- .setRpcTimeoutMultiplier (1.0 )
74- .setMaxRetryDelay (Duration .ofMillis (45000L ))
75- .setTotalTimeout (Duration .ofHours (24L ))
76- .build ());
7759 String resource = String .format ("projects/%s/locations/%s/queuedResources/%s" ,
7860 projectId , zone , queuedResourceId );
7961 // Initialize client that will be used to send requests. This client only needs to be created
8062 // once, and can be reused for multiple requests.
81- try (TpuClient tpuClient = TpuClient .create (clientSettings . build () )) {
63+ try (TpuClient tpuClient = TpuClient .create ()) {
8264 String parent = String .format ("projects/%s/locations/%s" , projectId , zone );
8365 Node node =
8466 Node .newBuilder ()
@@ -100,9 +82,6 @@ public static QueuedResource createQueuedResource(String projectId, String zone,
10082 .setNodeId (nodeName )
10183 .build ())
10284 .build ())
103- // You can request a queued resource using a reservation by specifying it in code
104- //.setReservationName(
105- // "projects/YOUR_PROJECT_ID/locations/YOUR_ZONE/reservations/YOUR_RESERVATION_NAME")
10685 .build ();
10786
10887 CreateQueuedResourceRequest request =
0 commit comments