String sha = getSha(localFile);
String sha = getSha(localFile);
/** * Returns a local resource representing a jar. * This resource will be used to execute the plan on the cluster. * @param localJarPath Local path to the jar to be localized. * @return LocalResource corresponding to the localized hive exec resource. * @throws IOException when any file system related call fails. * @throws LoginException when we are unable to determine the user. * @throws URISyntaxException when current jar location cannot be determined. */ private LocalResource createJarLocalResource(String localJarPath) throws IOException, LoginException, IllegalArgumentException, FileNotFoundException { FileStatus destDirStatus = utils.getHiveJarDirectory(conf); assert destDirStatus != null; Path destDirPath = destDirStatus.getPath(); Path localFile = new Path(localJarPath); String sha = getSha(localFile); String destFileName = localFile.getName(); // Now, try to find the file based on SHA and name. Currently we require exact name match. // We could also allow cutting off versions and other stuff provided that SHA matches... destFileName = FilenameUtils.removeExtension(destFileName) + "-" + sha + FilenameUtils.EXTENSION_SEPARATOR + FilenameUtils.getExtension(destFileName); if (LOG.isDebugEnabled()) { LOG.debug("The destination file name for [" + localJarPath + "] is " + destFileName); } // TODO: if this method is ever called on more than one jar, getting the dir and the // list need to be refactored out to be done only once. Path destFile = new Path(destDirPath.toString() + "/" + destFileName); return utils.localizeResource(localFile, destFile, LocalResourceType.FILE, conf); }