public boolean maybeAddImagePath(Map<String, LocalResource> localResources, Path imagePath) throws IOException { if (imagePath != null) { LocalResource resource = createAmResource(imagePath, LocalResourceType.ARCHIVE); localResources.put(SliderKeys.LOCAL_TARBALL_INSTALL_SUBDIR, resource); return true; } else { return false; } }
public boolean maybeAddImagePath(Map<String, LocalResource> localResources, Path imagePath) throws IOException { if (imagePath != null) { LocalResource resource = createAmResource(imagePath, LocalResourceType.ARCHIVE); localResources.put(SliderKeys.LOCAL_TARBALL_INSTALL_SUBDIR, resource); return true; } else { return false; } }
/** * Register all files under a fs path as a directory to push out * * @param srcDir src dir * @param destRelativeDir dest dir (no trailing /) * @return the map of entries */ public Map<String, LocalResource> submitDirectory(Path srcDir, String destRelativeDir) throws IOException { //now register each of the files in the directory to be //copied to the destination FileStatus[] fileset = fileSystem.listStatus(srcDir); Map<String, LocalResource> localResources = new HashMap<String, LocalResource>(fileset.length); for (FileStatus entry : fileset) { LocalResource resource = createAmResource(entry.getPath(), LocalResourceType.FILE); String relativePath = destRelativeDir + "/" + entry.getPath().getName(); localResources.put(relativePath, resource); } return localResources; }
/** * Register all files under a fs path as a directory to push out * * @param srcDir src dir * @param destRelativeDir dest dir (no trailing /) * @return the map of entries */ public Map<String, LocalResource> submitDirectory(Path srcDir, String destRelativeDir) throws IOException { //now register each of the files in the directory to be //copied to the destination FileStatus[] fileset = fileSystem.listStatus(srcDir); Map<String, LocalResource> localResources = new HashMap<String, LocalResource>(fileset.length); for (FileStatus entry : fileset) { LocalResource resource = createAmResource(entry.getPath(), LocalResourceType.FILE); String relativePath = destRelativeDir + "/" + entry.getPath().getName(); localResources.put(relativePath, resource); } return localResources; }
/** * Submit the AM tar.gz resource referenced by the instance's cluster * filesystem. Also, update the providerResources object with the new * resource. * * @param providerResources * the provider resource map to be updated * @throws IOException * trouble copying to HDFS */ public void submitTarGzipAndUpdate( Map<String, LocalResource> providerResources) throws IOException, BadClusterStateException { Path dependencyLibTarGzip = getDependencyTarGzip(); log.info("Loading all dependencies from {}", dependencyLibTarGzip); LocalResource lc = createAmResource(dependencyLibTarGzip, LocalResourceType.ARCHIVE); providerResources.put(SliderKeys.SLIDER_DEPENDENCY_LOCALIZED_DIR_LINK, lc); }
/** * Submit the AM tar.gz resource referenced by the instance's cluster * filesystem. Also, update the providerResources object with the new * resource. * * @param providerResources * the provider resource map to be updated * @throws IOException * trouble copying to HDFS */ public void submitTarGzipAndUpdate( Map<String, LocalResource> providerResources) throws IOException, BadClusterStateException { Path dependencyLibTarGzip = getDependencyTarGzip(); log.info("Loading all dependencies from {}", dependencyLibTarGzip); LocalResource lc = createAmResource(dependencyLibTarGzip, LocalResourceType.ARCHIVE); providerResources.put(SliderKeys.SLIDER_DEPENDENCY_LOCALIZED_DIR_LINK, lc); }
/** * Submit a local file to the filesystem references by the instance's cluster * filesystem * * @param localFile filename * @param subdir subdirectory (expected to end in a "/") * @param destFileName destination filename * @return the local resource ref * @throws IOException trouble copying to HDFS */ public LocalResource submitFile(File localFile, Path tempPath, String subdir, String destFileName) throws IOException { Path src = new Path(localFile.toString()); Path subdirPath = new Path(tempPath, subdir); fileSystem.mkdirs(subdirPath); Path destPath = new Path(subdirPath, destFileName); log.debug("Copying {} (size={} bytes) to {}", localFile, localFile.length(), destPath); fileSystem.copyFromLocalFile(false, true, src, destPath); // Set the type of resource - file or archive // archives are untarred at destination // we don't need the jar file to be untarred for now return createAmResource(destPath, LocalResourceType.FILE); }
/** * Submit a local file to the filesystem references by the instance's cluster * filesystem * * @param localFile filename * @param subdir subdirectory (expected to end in a "/") * @param destFileName destination filename * @return the local resource ref * @throws IOException trouble copying to HDFS */ public LocalResource submitFile(File localFile, Path tempPath, String subdir, String destFileName) throws IOException { Path src = new Path(localFile.toString()); Path subdirPath = new Path(tempPath, subdir); fileSystem.mkdirs(subdirPath); Path destPath = new Path(subdirPath, destFileName); log.debug("Copying {} (size={} bytes) to {}", localFile, localFile.length(), destPath); fileSystem.copyFromLocalFile(false, true, src, destPath); // Set the type of resource - file or archive // archives are untarred at destination // we don't need the jar file to be untarred for now return createAmResource(destPath, LocalResourceType.FILE); }