|
@ -53,11 +53,22 @@ public class SeaweedRead { |
|
|
return 0; |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int len = readChunkView(position, buffer, startOffset, chunkView, locations); |
|
|
|
|
|
|
|
|
|
|
|
readCount += len; |
|
|
|
|
|
startOffset += len; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return readCount; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static int readChunkView(long position, byte[] buffer, int startOffset, ChunkView chunkView, FilerProto.Locations locations) { |
|
|
HttpClient client = HttpClientBuilder.create().build(); |
|
|
HttpClient client = HttpClientBuilder.create().build(); |
|
|
HttpGet request = new HttpGet( |
|
|
HttpGet request = new HttpGet( |
|
|
String.format("http://%s/%s", locations.getLocations(0).getUrl(), chunkView.fileId)); |
|
|
String.format("http://%s/%s", locations.getLocations(0).getUrl(), chunkView.fileId)); |
|
|
|
|
|
|
|
|
if (!chunkView.isFullChunk){ |
|
|
|
|
|
|
|
|
if (!chunkView.isFullChunk) { |
|
|
request.setHeader(HttpHeaders.ACCEPT_ENCODING, ""); |
|
|
request.setHeader(HttpHeaders.ACCEPT_ENCODING, ""); |
|
|
request.setHeader(HttpHeaders.RANGE, |
|
|
request.setHeader(HttpHeaders.RANGE, |
|
|
String.format("bytes=%d-%d", chunkView.offset, chunkView.offset + chunkView.size)); |
|
|
String.format("bytes=%d-%d", chunkView.offset, chunkView.offset + chunkView.size)); |
|
@ -72,15 +83,12 @@ public class SeaweedRead { |
|
|
entity.writeTo(outputStream); |
|
|
entity.writeTo(outputStream); |
|
|
LOG.debug("* read chunkView:{} startOffset:{} length:{}", chunkView, startOffset, len); |
|
|
LOG.debug("* read chunkView:{} startOffset:{} length:{}", chunkView, startOffset, len); |
|
|
|
|
|
|
|
|
readCount += len; |
|
|
|
|
|
startOffset += len; |
|
|
|
|
|
|
|
|
return len; |
|
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
} catch (IOException e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return readCount; |
|
|
|
|
|
|
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static List<ChunkView> viewFromVisibles(List<VisibleInterval> visibleIntervals, long offset, long size) { |
|
|
public static List<ChunkView> viewFromVisibles(List<VisibleInterval> visibleIntervals, long offset, long size) { |
|
|