/** * Get all of the paths that currently exist in the working directories. * * @param pathStr the path underneath the roots * @param conf the configuration to look up the roots in * @return all of the paths that exist under any of the roots * @throws IOException */ public Iterable<Path> getAllLocalPathsToRead(String pathStr, Configuration conf) throws IOException { AllocatorPerContext context; synchronized (this) { context = obtainContext(contextCfgItemName); } return context.getAllLocalPathsToRead(pathStr, conf); }
/** * Get the current directory index for the given configuration item. * * @return the current directory index for the given configuration item. */ int getCurrentDirectoryIndex() { AllocatorPerContext context = obtainContext(contextCfgItemName); return context.getCurrentDirectoryIndex(); }
/** * We search through all the configured dirs for the file's existence and return true when we find * * @param pathStr the requested file (this will be searched) * @param conf the Configuration object * @return true if files exist. false otherwise * @throws IOException */ public boolean ifExists(String pathStr, Configuration conf) { AllocatorPerContext context = obtainContext(contextCfgItemName); return context.ifExists(pathStr, conf); }
/** * Creates a temporary file in the local FS. Pass size as -1 if not known apriori. We round-robin * over the set of disks (via the configured dirs) and select the first complete path which has * enough space. A file is created on this directory. The file is guaranteed to go away when the * JVM exits. * * @param pathStr prefix for the temporary file * @param size the size of the file that is going to be written * @param conf the Configuration object * @return a unique temporary file * @throws IOException */ public File createTmpFileForWrite(String pathStr, long size, Configuration conf) throws IOException { AllocatorPerContext context = obtainContext(contextCfgItemName); return context.createTmpFileForWrite(pathStr, size, conf); }
/** * Get a path from the local FS for reading. We search through all the configured dirs for the * file's existence and return the complete path to the file when we find one * * @param pathStr the requested file (this will be searched) * @param conf the Configuration object * @return the complete path to the file on a local disk * @throws IOException */ public Path getLocalPathToRead(String pathStr, Configuration conf) throws IOException { AllocatorPerContext context = obtainContext(contextCfgItemName); return context.getLocalPathToRead(pathStr, conf); }
/** * Get a path from the local FS. Pass size as SIZE_UNKNOWN if not known apriori. We round-robin * over the set of disks (via the configured dirs) and return the first complete path which has * enough space * * @param pathStr the requested path (this will be created on the first available disk) * @param size the size of the file that is going to be written * @param conf the Configuration object * @param checkWrite ensure that the path is writable * @return the complete path to the file on a local disk * @throws IOException */ public Path getLocalPathForWrite( String pathStr, long size, Configuration conf, boolean checkWrite) throws IOException { AllocatorPerContext context = obtainContext(contextCfgItemName); return context.getLocalPathForWrite(pathStr, size, conf, checkWrite); }