Browse Source

remove try catch

pull/7526/head
chrislu 1 week ago
parent
commit
274750fb82
  1. 43
      other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java

43
other/java/client/src/main/java/seaweedfs/client/SeaweedRead.java

@ -55,36 +55,31 @@ public class SeaweedRead {
// TODO parallel this
long readCount = 0;
long startOffset = position;
try {
for (ChunkView chunkView : chunkViews) {
if (startOffset < chunkView.logicOffset) {
long gap = chunkView.logicOffset - startOffset;
LOG.debug("zero [{},{})", startOffset, startOffset + gap);
buf.position(buf.position() + (int) gap);
readCount += gap;
startOffset += gap;
}
for (ChunkView chunkView : chunkViews) {
String volumeId = parseVolumeId(chunkView.fileId);
FilerProto.Locations locations = knownLocations.get(volumeId);
if (locations == null || locations.getLocationsCount() == 0) {
LOG.error("failed to locate {}", chunkView.fileId);
volumeIdCache.clearLocations(volumeId);
throw new IOException("failed to locate fileId " + chunkView.fileId);
}
if (startOffset < chunkView.logicOffset) {
long gap = chunkView.logicOffset - startOffset;
LOG.debug("zero [{},{})", startOffset, startOffset + gap);
buf.position(buf.position() + (int) gap);
readCount += gap;
startOffset += gap;
}
int len = readChunkView(filerClient, startOffset, buf, chunkView, locations);
String volumeId = parseVolumeId(chunkView.fileId);
FilerProto.Locations locations = knownLocations.get(volumeId);
if (locations == null || locations.getLocationsCount() == 0) {
LOG.error("failed to locate {}", chunkView.fileId);
volumeIdCache.clearLocations(volumeId);
throw new IOException("failed to locate fileId " + chunkView.fileId);
}
LOG.debug("read [{},{}) {} size {}", startOffset, startOffset + len, chunkView.fileId, chunkView.size);
int len = readChunkView(filerClient, startOffset, buf, chunkView, locations);
readCount += len;
startOffset += len;
LOG.debug("read [{},{}) {} size {}", startOffset, startOffset + len, chunkView.fileId, chunkView.size);
}
} catch (Exception e) {
readCount += len;
startOffset += len;
throw e;
}
// Fix: Calculate the correct limit based on the read position and requested

Loading…
Cancel
Save