浏览代码

YARN-9747. Reduce additional namenode call by EntityGroupFSTimelineStore#cleanLogs. Contributed by Prabhu Joseph.

bibinchundatt 5 年之前
父节点
当前提交
89a53c7eb4

+ 4 - 6
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timeline-pluginstorage/src/main/java/org/apache/hadoop/yarn/server/timeline/EntityGroupFSTimelineStore.java

@@ -469,8 +469,8 @@ public class EntityGroupFSTimelineStore extends CompositeService
     RemoteIterator<FileStatus> iter = list(dirpath);
     while (iter.hasNext()) {
       FileStatus stat = iter.next();
-      Path clusterTimeStampPath = stat.getPath();
-      if (isValidClusterTimeStampDir(clusterTimeStampPath)) {
+      if (isValidClusterTimeStampDir(stat)) {
+        Path clusterTimeStampPath = stat.getPath();
         MutableBoolean appLogDirPresent = new MutableBoolean(false);
         cleanAppLogDir(clusterTimeStampPath, retainMillis, appLogDirPresent);
         if (appLogDirPresent.isFalse() &&
@@ -520,11 +520,9 @@ public class EntityGroupFSTimelineStore extends CompositeService
     }
   }
 
-  private boolean isValidClusterTimeStampDir(Path clusterTimeStampPath)
-      throws IOException {
-    FileStatus stat = fs.getFileStatus(clusterTimeStampPath);
+  private boolean isValidClusterTimeStampDir(FileStatus stat) {
     return stat.isDirectory() &&
-        StringUtils.isNumeric(clusterTimeStampPath.getName());
+        StringUtils.isNumeric(stat.getPath().getName());
   }