Allow GCS data segment killer to delete if present (#5675)

This commit is contained in:
Charles Allen 2018-04-24 07:16:54 -07:00 committed by Gian Merlino
parent fd76af9737
commit 2e76012aca
1 changed files with 16 additions and 2 deletions

View File

@ -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 class GoogleDataSegmentKiller implements DataSegmentKiller
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()
{