>From Michael Blow <[email protected]>: Michael Blow has submitted this change. ( https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19468 )
Change subject: [NO ISSUE][*DB][CLOUD] Cancel running GCS ops on interrupt ...................................................................... [NO ISSUE][*DB][CLOUD] Cancel running GCS ops on interrupt Ext-ref: MB-65432 Change-Id: I840f300f11a5bc2676cd4b542bda40cfb78e64e4 Reviewed-on: https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19468 Reviewed-by: Ali Alsuliman <[email protected]> Tested-by: Michael Blow <[email protected]> --- M asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/clients/google/gcs/GCSCloudClient.java 1 file changed, 34 insertions(+), 1 deletion(-) Approvals: Ali Alsuliman: Looks good to me, approved Michael Blow: Verified diff --git a/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/clients/google/gcs/GCSCloudClient.java b/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/clients/google/gcs/GCSCloudClient.java index 99cda9e..16fb278 100644 --- a/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/clients/google/gcs/GCSCloudClient.java +++ b/asterixdb/asterix-cloud/src/main/java/org/apache/asterix/cloud/clients/google/gcs/GCSCloudClient.java @@ -31,8 +31,10 @@ import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.concurrent.CancellationException; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; import java.util.function.Supplier; import org.apache.asterix.cloud.IWriteBufferProvider; @@ -348,12 +350,30 @@ } private <T> T runOpInterruptibly(Supplier<T> operation) throws HyracksDataException { + Future<T> opTask = executor.submit(operation::get); try { - return executor.submit(operation::get).get(); + return opTask.get(); } catch (InterruptedException e) { + cancelAndUnwind(opTask); throw HyracksDataException.create(e); } catch (ExecutionException e) { throw HyracksDataException.create(e.getCause()); } } + + private static <T> void cancelAndUnwind(Future<T> opTask) { + opTask.cancel(true); + while (true) { + try { + opTask.get(); + } catch (InterruptedException e1) { + continue; + } catch (CancellationException e1) { + LOGGER.debug("ignoring exception after cancel of op", e1); + } catch (ExecutionException e1) { + LOGGER.debug("ignoring exception after cancel of op", e1.getCause()); + } + return; + } + } } -- To view, visit https://asterix-gerrit.ics.uci.edu/c/asterixdb/+/19468 To unsubscribe, or for help writing mail filters, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-Project: asterixdb Gerrit-Branch: ionic Gerrit-Change-Id: I840f300f11a5bc2676cd4b542bda40cfb78e64e4 Gerrit-Change-Number: 19468 Gerrit-PatchSet: 2 Gerrit-Owner: Michael Blow <[email protected]> Gerrit-Reviewer: Ali Alsuliman <[email protected]> Gerrit-Reviewer: Jenkins <[email protected]> Gerrit-Reviewer: Michael Blow <[email protected]> Gerrit-CC: Anon. E. Moose #1000171 Gerrit-MessageType: merged
