jinglining commented on a change in pull request #11250: [FLINK-16302][rest]add 
log list and read log by name for taskmanager
URL: https://github.com/apache/flink/pull/11250#discussion_r394064136
 
 

 ##########
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/taskexecutor/TaskExecutor.java
 ##########
 @@ -309,6 +311,25 @@ public TaskExecutor(
                return 
CompletableFuture.completedFuture(shuffleEnvironment.getPartitionsOccupyingLocalResources().isEmpty());
        }
 
+       @Override
+       public CompletableFuture<Collection<Tuple2<String, Long>>> 
requestLogList(Time timeout) {
+               final String logDir = 
taskManagerConfiguration.getTaskManagerLogDir();
+               if (logDir != null) {
+                       final File[] logFiles = new File(logDir).listFiles();
+
+                       if (logFiles == null) {
+                               return FutureUtils.completedExceptionally(
+                                       new FlinkException("The specific log 
directory is not a valid directory."));
+                       }
+
+                       final List<Tuple2<String, Long>> logsWithLength = 
Arrays.stream(logFiles)
+                               .map(logFile -> Tuple2.of(logFile.getName(), 
logFile.length()))
+                               .collect(Collectors.toList());
+                       return 
CompletableFuture.completedFuture(logsWithLength);
+               }
+               return FutureUtils.completedExceptionally(new 
FlinkException("There is no log file available on the TaskExecutor."));
 
 Review comment:
   Because there must be a log file currently, if there is no log file, it 
should be an exception, not empty.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to