You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@druid.apache.org by GitBox <gi...@apache.org> on 2018/07/09 18:22:55 UTC

[GitHub] gianm closed pull request #5964: [Backport] Allow GCS data segment killer to delete if present

gianm closed pull request #5964: [Backport] Allow GCS data segment killer to delete if present
URL: https://github.com/apache/incubator-druid/pull/5964
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/extensions-contrib/google-extensions/src/main/java/io/druid/storage/google/GoogleDataSegmentKiller.java b/extensions-contrib/google-extensions/src/main/java/io/druid/storage/google/GoogleDataSegmentKiller.java
index b7fbdc162a2..2285fbd6069 100644
--- a/extensions-contrib/google-extensions/src/main/java/io/druid/storage/google/GoogleDataSegmentKiller.java
+++ b/extensions-contrib/google-extensions/src/main/java/io/druid/storage/google/GoogleDataSegmentKiller.java
@@ -19,6 +19,7 @@
 
 package io.druid.storage.google;
 
+import com.google.api.client.googleapis.json.GoogleJsonResponseException;
 import com.google.inject.Inject;
 import io.druid.java.util.common.MapUtils;
 import io.druid.java.util.common.logger.Logger;
@@ -52,14 +53,27 @@ public void kill(DataSegment segment) throws SegmentLoadingException
     final String descriptorPath = indexPath.substring(0, indexPath.lastIndexOf("/")) + "/descriptor.json";
 
     try {
-      storage.delete(bucket, indexPath);
-      storage.delete(bucket, descriptorPath);
+      deleteIfPresent(bucket, indexPath);
+      deleteIfPresent(bucket, descriptorPath);
     }
     catch (IOException e) {
       throw new SegmentLoadingException(e, "Couldn't kill segment[%s]: [%s]", segment.getIdentifier(), e.getMessage());
     }
   }
 
+  private void deleteIfPresent(String bucket, String path) throws IOException
+  {
+    try {
+      storage.delete(bucket, path);
+    }
+    catch (GoogleJsonResponseException e) {
+      if (e.getStatusCode() != 404) {
+        throw e;
+      }
+      LOG.debug("Already deleted: [%s] [%s]", bucket, path);
+    }
+  }
+
   @Override
   public void killAll() throws IOException
   {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@druid.apache.org
For additional commands, e-mail: dev-help@druid.apache.org