Z1Wu commented on code in PR #3093:
URL: https://github.com/apache/celeborn/pull/3093#discussion_r1951107309


##########
client/src/main/java/org/apache/celeborn/client/read/DfsPartitionReader.java:
##########
@@ -97,26 +98,28 @@ public DfsPartitionReader(
 
     if (endMapIndex != Integer.MAX_VALUE) {
       long fetchTimeoutMs = conf.clientFetchTimeoutMs();
-      try {
-        client = clientFactory.createClient(location.getHost(), 
location.getFetchPort());
-        TransportMessage openStream =
-            new TransportMessage(
-                MessageType.OPEN_STREAM,
-                PbOpenStream.newBuilder()
-                    .setShuffleKey(shuffleKey)
-                    .setFileName(location.getFileName())
-                    .setStartIndex(startMapIndex)
-                    .setEndIndex(endMapIndex)
-                    .build()
-                    .toByteArray());
-        ByteBuffer response = client.sendRpcSync(openStream.toByteBuffer(), 
fetchTimeoutMs);
-        streamHandler = 
TransportMessage.fromByteBuffer(response).getParsedPayload();
-        // Parse this message to ensure sort is done.
-      } catch (IOException | InterruptedException e) {
-        throw new IOException(
-            "read shuffle file from DFS failed, filePath: "
-                + location.getStorageInfo().getFilePath(),
-            e);
+      if (pbStreamHandler == null) {
+        try {
+          client = clientFactory.createClient(location.getHost(), 
location.getFetchPort());
+          TransportMessage openStream =
+              new TransportMessage(
+                  MessageType.OPEN_STREAM,
+                  PbOpenStream.newBuilder()
+                      .setShuffleKey(shuffleKey)
+                      .setFileName(location.getFileName())
+                      .setStartIndex(startMapIndex)
+                      .setEndIndex(endMapIndex)
+                      .build()
+                      .toByteArray());
+          ByteBuffer response = client.sendRpcSync(openStream.toByteBuffer(), 
fetchTimeoutMs);
+          streamHandler = 
TransportMessage.fromByteBuffer(response).getParsedPayload();
+          // Parse this message to ensure sort is done.
+        } catch (IOException | InterruptedException e) {
+          throw new IOException(
+              "read shuffle file from DFS failed, filePath: "
+                  + location.getStorageInfo().getFilePath(),
+              e);
+        }

Review Comment:
   `closeStream ` will use `streamHandler.getStreamId()` only when `client` is 
initialized and send request to worker to open stream. 
   
   
https://github.com/apache/celeborn/blob/299a0483d47e4f7fce86c8d914b5f6f8eb26ea3e/client/src/main/java/org/apache/celeborn/client/read/DfsPartitionReader.java#L282-L294
   
   You can also refer to the scenario when `DfsPartitionReader` reads a 
non-sorted file and there is also no initialization of  `streamHandler`
   
   
https://github.com/apache/celeborn/blob/299a0483d47e4f7fce86c8d914b5f6f8eb26ea3e/client/src/main/java/org/apache/celeborn/client/read/DfsPartitionReader.java#L129-L132



-- 
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]

Reply via email to