server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java
/**
   * If we have already reserved a location before, probably via {@link #reserve(DataSegment)}, then only that location
   * should be tried. Otherwise, we would fetch locations using {@link StorageLocationSelectorStrategy} and try all
   * of them one by one till there is success.
   * Location may fail because of IO failure, most likely in two cases:<p>
   * 1. druid don't have the write access to this location, most likely the administrator doesn't config it correctly<p>
   * 2. disk failure, druid can't read/write to this disk anymore
   * <p>
   * Locations are fetched using {@link StorageLocationSelectorStrategy}.
   */
If we have already reserved a location before, probably via  #reserve(DataSegment), then only that location
should be tried. Otherwise, we would fetch locations using  StorageLocationSelectorStrategy and try all
of them one by one till there is success.
Location may fail because of IO failure, most likely in two cases:
1. druid don't have the write access to this location, most likely the administrator doesn't config it correctly
2. disk failure, druid can't read/write to this disk anymore

Locations are fetched using  StorageLocationSelectorStrategy.
If we have already reserved a location before probably via #reserve ( DataSegment ) then only that location should be tried . Otherwise we would fetch locations using StorageLocationSelectorStrategy and try all of them one by one till there is success . Location may fail because of IO failure most likely in two cases : 1 . druid don ' t have the write access to this location most likely the administrator doesn ' t config it correctly 2 . disk failure druid can ' t read / write to this disk anymore Locations are fetched using StorageLocationSelectorStrategy .
private File loadSegmentWithRetry(DataSegment segment) throws SegmentLoadingException
  {
    String segmentDir = getSegmentDir(segment);
    for (StorageLocation loc : locations) {
      if (loc.isReserved(segmentDir)) {
        File storageDir = loc.segmentDirectoryAsFile(segmentDir);
        boolean success = loadInLocationWithStartMarkerQuietly(loc, segment, storageDir, false);
        if (!success) {
          throw new SegmentLoadingException("Failed to load segment %s in reserved location [%s]", segment.getId(), loc.getPath().getAbsolutePath());
        }
        return storageDir;
      }
    }
    Iterator<StorageLocation> locationsIterator = strategy.getLocations();
    while (locationsIterator.hasNext()) {
      StorageLocation loc = locationsIterator.next();
      File storageDir = loc.reserve(segmentDir, segment);
      if (storageDir != null) {
        boolean success = loadInLocationWithStartMarkerQuietly(loc, segment, storageDir, true);
        if (success) {
          return storageDir;
        }
      }
    }
    throw new SegmentLoadingException("Failed to load segment %s in all locations.", segment.getId());
  }
private File loadSegmentWithRetry ( DataSegment segment ) throws SegmentLoadingException { String segmentDir = getSegmentDir ( segment ) ; for ( StorageLocation loc : locations ) { if ( loc . isReserved ( segmentDir ) ) { File storageDir = loc . segmentDirectoryAsFile ( segmentDir ) ; boolean success = loadInLocationWithStartMarkerQuietly ( loc , segment , storageDir , false ) ; if ( ! success ) { throw new SegmentLoadingException ( "Failed to load segment %s in reserved location [%s]" , segment . getId ( ) , loc . getPath ( ) . getAbsolutePath ( ) ) ; } return storageDir ; } } Iterator < StorageLocation > locationsIterator = strategy . getLocations ( ) ; while ( locationsIterator . hasNext ( ) ) { StorageLocation loc = locationsIterator . next ( ) ; File storageDir = loc . reserve ( segmentDir , segment ) ; if ( storageDir != null ) { boolean success = loadInLocationWithStartMarkerQuietly ( loc , segment , storageDir , true ) ; if ( success ) { return storageDir ; } } } throw new SegmentLoadingException ( "Failed to load segment %s in all locations." , segment . getId ( ) ) ; }
If we have already reserved a location before, probably via {@link #reserve(DataSegment)}, then only that location
 should be tried.
If we have already reserved a location before probably via { @link #reserve ( DataSegment ) } then only that location should be tried .
// Try the already reserved location. If location has been reserved outside, then we do not release the location // here and simply delete any downloaded files. That is, we revert anything we do in this function and nothing else. // No location was reserved so we try all the locations // storageDir is the file path corresponding to segment dir