/** * Copy source path to destination with localization rules. * @param source source path to copy. Typically HDFS * @param destination destination path. Typically local filesystem * @exception YarnException Any error has occurred */ private void downloadAndUnpack(Path source, Path destination) throws YarnException { try { FileSystem sourceFileSystem = source.getFileSystem(conf); FileSystem destinationFileSystem = destination.getFileSystem(conf); if (sourceFileSystem.getFileStatus(source).isDirectory()) { FileUtil.copy( sourceFileSystem, source, destinationFileSystem, destination, false, true, conf); } else { unpack(source, destination, sourceFileSystem, destinationFileSystem); } } catch (Exception e) { throw new YarnException("Download and unpack failed", e); } }
}; }); unpack(new File(dTmp.toUri()), new File(dFinal.toUri())); changePermissions(dFinal.getFileSystem(conf), dFinal); files.rename(dst_work, destDirPath, Rename.OVERWRITE);
}; }); unpack(new File(dTmp.toUri()), new File(dFinal.toUri())); changePermissions(dFinal.getFileSystem(conf), dFinal); files.rename(dst_work, destDirPath, Rename.OVERWRITE);