Browse Source

YARN-9018. Add functionality to AuxiliaryLocalPathHandler to return all locations to read for a given path. Contributed by Kuhu Shukla (kshukla)

(cherry picked from commit 93233a7d6e4d6b8098622a1aa830355cc18d9589)
Eric E Payne 5 years ago
parent
commit
c296e3c0aa

+ 8 - 0
hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-shuffle/src/test/java/org/apache/hadoop/mapred/TestShuffleHandler.java

@@ -172,6 +172,14 @@ public class TestShuffleHandler {
         throws IOException {
         throws IOException {
       return new Path(ABS_LOG_DIR.getAbsolutePath());
       return new Path(ABS_LOG_DIR.getAbsolutePath());
     }
     }
+
+    @Override
+    public Iterable<Path> getAllLocalPathsForRead(String path)
+        throws IOException {
+      ArrayList<Path> paths = new ArrayList<>();
+      paths.add(new Path(ABS_LOG_DIR.getAbsolutePath()));
+      return paths;
+    }
   }
   }
 
 
   private static class MockShuffleHandler2 extends
   private static class MockShuffleHandler2 extends

+ 8 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-api/src/main/java/org/apache/hadoop/yarn/server/api/AuxiliaryLocalPathHandler.java

@@ -55,4 +55,12 @@ public interface AuxiliaryLocalPathHandler {
    * @throws IOException if the path creations fails
    * @throws IOException if the path creations fails
    */
    */
   Path getLocalPathForWrite(String path, long size) throws IOException;
   Path getLocalPathForWrite(String path, long size) throws IOException;
+
+  /**
+   * Get all paths from the local FS for reading for a given Auxiliary Service.
+   * @param path the requested path
+   * @return the complete path list to the file on a local disk as an Iterable
+   * @throws IOException if the file read encounters a problem
+   */
+  Iterable<Path> getAllLocalPathsForRead(String path) throws IOException;
 }
 }

+ 4 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/LocalDirsHandlerService.java

@@ -611,6 +611,10 @@ public class LocalDirsHandlerService extends AbstractService {
     return getPathToRead(pathStr, getLocalDirsForRead());
     return getPathToRead(pathStr, getLocalDirsForRead());
   }
   }
 
 
+  public Iterable<Path> getAllLocalPathsForRead(String pathStr) throws IOException {
+    return localDirsAllocator.getAllLocalPathsToRead(pathStr, getConfig());
+  }
+
   public Path getLogPathForWrite(String pathStr, boolean checkWrite)
   public Path getLogPathForWrite(String pathStr, boolean checkWrite)
       throws IOException {
       throws IOException {
     return logDirsAllocator.getLocalPathForWrite(pathStr,
     return logDirsAllocator.getLocalPathForWrite(pathStr,

+ 5 - 0
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/ContainerManagerImpl.java

@@ -1598,6 +1598,11 @@ public class ContainerManagerImpl extends CompositeService implements
         throws IOException {
         throws IOException {
       return dirhandlerService.getLocalPathForWrite(path, size, false);
       return dirhandlerService.getLocalPathForWrite(path, size, false);
     }
     }
+
+    @Override
+    public Iterable<Path> getAllLocalPathsForRead(String path) throws IOException {
+      return dirhandlerService.getAllLocalPathsForRead(path);
+    }
   }
   }
 
 
   @SuppressWarnings("unchecked")
   @SuppressWarnings("unchecked")