kezhenxu94 commented on code in PR #10749:
URL: https://github.com/apache/dolphinscheduler/pull/10749#discussion_r917715705
##########
dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/utils/FileUtils.java:
##########
@@ -244,4 +244,15 @@ public static boolean directoryTraversal(String filename){
}
}
+ /**
+ * Get file size in Byte
+ *
+ * @param filename String type of filename
+ * @return file size in Byte
+ */
+ public static long getFileSizeInByte(String filename) {
+ File file = new File(filename);
+ return file.length();
+ }
Review Comment:
This is one-line code, just inline this util method and remove this method?
```java
new File(filename).length()
```
##########
dolphinscheduler-worker/src/main/java/org/apache/dolphinscheduler/server/worker/runner/TaskExecuteThread.java:
##########
@@ -278,8 +280,14 @@ public void downloadResource(String execLocalPath, Logger
logger, List<Pair<Stri
String tenantCode = fileDownload.getRight();
String resHdfsPath =
storageOperate.getResourceFileName(tenantCode, fullName);
logger.info("get resource file from hdfs :{}", resHdfsPath);
+ long resourceDownloadStartTime = System.currentTimeMillis();
storageOperate.download(tenantCode, resHdfsPath, execLocalPath
+ File.separator + fullName, false, true);
+
WorkerServerMetrics.recordWorkerResourceDownloadTime(System.currentTimeMillis()
- resourceDownloadStartTime);
+ WorkerServerMetrics.recordWorkerResourceDownloadSize(
+ FileUtils.getFileSizeInByte(execLocalPath +
File.separator + fullName));
Review Comment:
```suggestion
WorkerServerMetrics.recordWorkerResourceDownloadSize(
Files.size(Paths.get(execLocalPath, fullName)));
```
--
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]