private void loadInLocationWithStartMarker(DataSegment segment, File storageDir) throws SegmentLoadingException { // We use a marker to prevent the case where a segment is downloaded, but before the download completes, // the parent directories of the segment are removed final File downloadStartMarker = new File(storageDir, "downloadStartMarker"); synchronized (lock) { if (!storageDir.mkdirs()) { log.debug("Unable to make parent file[%s]", storageDir); } try { if (!downloadStartMarker.createNewFile()) { throw new SegmentLoadingException("Was not able to create new download marker for [%s]", storageDir); } } catch (IOException e) { throw new SegmentLoadingException(e, "Unable to create marker file for [%s]", storageDir); } } loadInLocation(segment, storageDir); if (!downloadStartMarker.delete()) { throw new SegmentLoadingException("Unable to remove marker file for [%s]", storageDir); } }
private void loadInLocationWithStartMarker(DataSegment segment, File storageDir) throws SegmentLoadingException { // We use a marker to prevent the case where a segment is downloaded, but before the download completes, // the parent directories of the segment are removed final File downloadStartMarker = new File(storageDir, "downloadStartMarker"); synchronized (lock) { if (!storageDir.mkdirs()) { log.debug("Unable to make parent file[%s]", storageDir); } try { if (!downloadStartMarker.createNewFile()) { throw new SegmentLoadingException("Was not able to create new download marker for [%s]", storageDir); } } catch (IOException e) { throw new SegmentLoadingException(e, "Unable to create marker file for [%s]", storageDir); } } loadInLocation(segment, storageDir); if (!downloadStartMarker.delete()) { throw new SegmentLoadingException("Unable to remove marker file for [%s]", storageDir); } }