1818
1919//[START tpu_queued_resources_delete_force]
2020import com .google .api .gax .retrying .RetrySettings ;
21- import com .google .api .gax .rpc .UnknownException ;
2221import com .google .cloud .tpu .v2alpha1 .DeleteQueuedResourceRequest ;
2322import com .google .cloud .tpu .v2alpha1 .TpuClient ;
2423import com .google .cloud .tpu .v2alpha1 .TpuSettings ;
2726import org .threeten .bp .Duration ;
2827
2928public class DeleteForceQueuedResource {
30- public static void main (String [] args ) {
29+ public static void main (String [] args )
30+ throws IOException , ExecutionException , InterruptedException {
3131 // TODO(developer): Replace these variables before running the sample.
3232 // Project ID or project number of the Google Cloud project.
3333 String projectId = "YOUR_PROJECT_ID" ;
@@ -41,7 +41,8 @@ public static void main(String[] args) {
4141
4242 // Deletes a Queued Resource asynchronously with --force flag.
4343 public static void deleteForceQueuedResource (
44- String projectId , String zone , String queuedResourceId ) {
44+ String projectId , String zone , String queuedResourceId )
45+ throws IOException , ExecutionException , InterruptedException {
4546 String name = String .format ("projects/%s/locations/%s/queuedResources/%s" ,
4647 projectId , zone , queuedResourceId );
4748 // With these settings the client library handles the Operation's polling mechanism
@@ -64,14 +65,13 @@ public static void deleteForceQueuedResource(
6465 // once, and can be reused for multiple requests.
6566 try (TpuClient tpuClient = TpuClient .create (clientSettings .build ())) {
6667 DeleteQueuedResourceRequest request =
67- DeleteQueuedResourceRequest .newBuilder ().setName (name ).setForce (true ).build ();
68+ DeleteQueuedResourceRequest .newBuilder ().setName (name ).setForce (true ).build ();
6869
6970 tpuClient .deleteQueuedResourceAsync (request ).get ();
70-
71- } catch ( UnknownException | InterruptedException | ExecutionException | IOException e ) {
72- System .out .println ( e . getMessage () );
71+ // Waiting for updates in the library. Until then, the operation will complete successfully,
72+ // but the user will receive an error message with UnknownException and IllegalStateException.
73+ System .out .printf ( "Deleted Queued Resource: %s \n " , name );
7374 }
74- System .out .printf ("Deleted Queued Resource: %s\n " , name );
7575 }
7676}
7777//[END tpu_queued_resources_delete_force]
0 commit comments