/** * Adds the jars from a directory into the distributed cache of a job. * * @param job The job to configure. * @param jarDirectory A path to a directory of jar files. * @throws IOException on I/O error. */ public static void addJarsToDistributedCache(Job job, String jarDirectory) throws IOException { addJarsToDistributedCache(job, qualifiedPathFromString(jarDirectory, job.getConfiguration())); }
/** * Adds the jars from a directory into the distributed cache of a job. * * @param job The job to configure. * @param jarDirectory A path to a directory of jar files. * @throws IOException on I/O error. */ public static void addJarsToDistributedCache(Job job, Path jarDirectory) throws IOException { if (null == jarDirectory) { throw new IllegalArgumentException("Jar directory may not be null"); } addJarsToDistributedCache(job, listJarFilesFromDirectory(job.getConfiguration(), jarDirectory)); }
/** * Adds the jar files into the distributed cache of a job. * * @param job The job to configure. * @param jarFiles Collection of jar files to add. * @throws IOException on I/O error. */ public static void addJarsToDistributedCache(Job job, Collection<Path> jarFiles) throws IOException { // Get existing jars named in configuration. final List<Path> allJars = Lists.newArrayList(getJarsFromConfiguration(job.getConfiguration())); // Add jars from jarDirectory. for (Path path : jarFiles) { final Path qualifiedPath = path.getFileSystem(job.getConfiguration()).makeQualified(path); LOG.debug("Adding jar {}, fully qualified as {}", path, qualifiedPath); allJars.add(qualifiedPath); } // De-duplicate the list of jar files, based on their names: final Collection<Path> deDupedJars = deDuplicateFilenames(allJars); job.getConfiguration().set(CONF_TMPJARS, StringUtils.join(deDupedJars, ",")); }
/** * Adds the jars from a directory into the distributed cache of a job. * * @param job The job to configure. * @param jarDirectory A path to a directory of jar files. * @throws IOException on I/O error. */ public static void addJarsToDistributedCache(Job job, File jarDirectory) throws IOException { addJarsToDistributedCache(job, new Path("file:" + jarDirectory.getCanonicalPath())); }
DistributedCacheJars.addJarsToDistributedCache(job, jarDirectory); DistributedCacheJars.addJarsToDistributedCache(job, jarFiles);