DaveTeng0 commented on code in PR #4073:
URL: https://github.com/apache/ozone/pull/4073#discussion_r1097079308
##########
hadoop-hdds/client/src/main/java/org/apache/hadoop/hdds/scm/storage/BlockInputStream.java:
##########
@@ -279,139 +252,38 @@ protected ChunkInputStream
createChunkInputStream(ChunkInfo chunkInfo) {
protected synchronized int readWithStrategy(ByteReaderStrategy strategy)
throws IOException {
Preconditions.checkArgument(strategy != null);
- if (!initialized) {
+ if (!isInitialized()) {
initialize();
}
-
- checkOpen();
- int totalReadLen = 0;
- int len = strategy.getTargetLength();
- while (len > 0) {
- // if we are at the last chunk and have read the entire chunk, return
- if (chunkStreams.size() == 0 ||
- (chunkStreams.size() - 1 <= chunkIndex &&
- chunkStreams.get(chunkIndex)
- .getRemaining() == 0)) {
- return totalReadLen == 0 ? EOF : totalReadLen;
- }
-
- // Get the current chunkStream and read data from it
- ChunkInputStream current = chunkStreams.get(chunkIndex);
- int numBytesToRead = Math.min(len, (int)current.getRemaining());
- int numBytesRead;
- try {
- numBytesRead = strategy.readFromBlock(current, numBytesToRead);
- retries = 0;
- // If we get a StorageContainerException or an IOException due to
- // datanodes are not reachable, refresh to get the latest pipeline
- // info and retry.
- // Otherwise, just retry according to the retry policy.
- } catch (SCMSecurityException ex) {
- throw ex;
- } catch (StorageContainerException e) {
- if (shouldRetryRead(e)) {
- handleReadError(e);
- continue;
- } else {
- throw e;
- }
- } catch (IOException ex) {
- if (shouldRetryRead(ex)) {
- if (isConnectivityIssue(ex)) {
- handleReadError(ex);
- } else {
- current.releaseClient();
- }
- continue;
- } else {
- throw ex;
- }
- }
-
- if (numBytesRead != numBytesToRead) {
- // This implies that there is either data loss or corruption in the
- // chunk entries. Even EOF in the current stream would be covered in
- // this case.
- throw new IOException(String.format(
- "Inconsistent read for chunkName=%s length=%d numBytesToRead= %d "
+
- "numBytesRead=%d", current.getChunkName(), current.getLength(),
- numBytesToRead, numBytesRead));
- }
- totalReadLen += numBytesRead;
- len -= numBytesRead;
- if (current.getRemaining() <= 0 &&
- ((chunkIndex + 1) < chunkStreams.size())) {
- chunkIndex += 1;
- }
- }
- return totalReadLen;
+ return delegateStream.readWithStrategy(strategy);
}
/**
* Seeks the BlockInputStream to the specified position. If the stream is
* not initialized, save the seeked position via blockPosition. Otherwise,
* update the position in 2 steps:
- * 1. Updating the chunkIndex to the chunkStream corresponding to the
- * seeked position.
- * 2. Seek the corresponding chunkStream to the adjusted position.
- *
+ * 1. Updating the chunkIndex to the chunkStream corresponding to the
+ * seeked position.
+ * 2. Seek the corresponding chunkStream to the adjusted position.
+ * <p>
Review Comment:
Maybe this "<p>" was added by accident?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]