You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/10/29 09:21:08 UTC

[GitHub] [flink] 1996fanrui commented on a diff in pull request #21185: [FLINK-28643][runtime-web] HistoryServer support lazy unzip

1996fanrui commented on code in PR #21185:
URL: https://github.com/apache/flink/pull/21185#discussion_r1008667842


##########
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/history/HistoryServerStaticFileServerHandler.java:
##########
@@ -266,6 +324,18 @@ private void respondWithFile(ChannelHandlerContext ctx, HttpRequest request, Str
         }
     }
 
+    static String extractJobId(String requestPath) {
+        if (StringUtils.isNullOrWhitespaceOnly(requestPath)
+                || !requestPath.matches("^/jobs/.{32}\\.json$")) {
+            return null;
+        }
+        String secondPath = requestPath.split("/")[2];
+        if (StringUtils.isNullOrWhitespaceOnly(secondPath) || secondPath.length() < 32) {
+            return null;
+        }
+        return secondPath.substring(0, 32);

Review Comment:
   Too many 32, the 32 should be defined as constant.



##########
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/history/HistoryServerStaticFileServerHandler.java:
##########
@@ -166,10 +194,40 @@ private void respondWithFile(ChannelHandlerContext ctx, HttpRequest request, Str
                             }
                         }
                     }
+                    // try to unzip archived files
+                    if (enableUnzip && !success) {
+                        // extract jobid from requestPath
+                        String jobId = extractJobId(requestPath);
+                        if (!StringUtils.isNullOrWhitespaceOnly(jobId)) {
+                            // submit unzip Task and get future
+                            Boolean unzipped =
+                                    CompletableFuture.supplyAsync(
+                                                    unzipTask.apply(jobId), unzipExecutor)
+                                            .get(UNZIP_TIMEOUT, TimeUnit.SECONDS);
+                            if (unzipped && file.exists()) {
+                                success = true;
+                            }

Review Comment:
   The code can be simplified to: `success = unzipped && file.exists()`



##########
flink-runtime-web/src/main/java/org/apache/flink/runtime/webmonitor/history/HistoryServerStaticFileServerHandler.java:
##########
@@ -93,13 +102,31 @@
     private static final Logger LOG =
             LoggerFactory.getLogger(HistoryServerStaticFileServerHandler.class);
 
+    private static final long UNZIP_TIMEOUT = 10L;

Review Comment:
   How about `UNZIP_TIMEOUT_SECOND` ?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org