archiveNameLC.endsWith(".tgz") || archiveNameLC.endsWith(".tar")) FileUtil.unTar(archiveFile, dstPath); else throw new IOException("Cannot unpack archive [path=" + srcPath + ", jobId=" + jobId + ']');
FileUtil.unTar(exportFile, folder); String[] child = folder.list(); Preconditions.checkState(child.length == 1);
public String extractOozieTarFileToTempDir(File fullOozieTarFilePath) throws IOException { File tempDir = File.createTempFile(OozieConfig.SHARE_LIB_LOCAL_TEMP_PREFIX, "", Paths.get(oozieTmpDir).toFile()); tempDir.delete(); tempDir.mkdir(); tempDir.deleteOnExit(); FileUtil.unTar(fullOozieTarFilePath, tempDir); return tempDir.getAbsolutePath(); }
public String extractOozieShareLibTarFileToTempDir(File fullOozieShareLibTarFilePath) throws IOException { File tempDir = File.createTempFile(SHARE_LIB_LOCAL_TEMP_PREFIX, ""); tempDir.delete(); tempDir.mkdir(); tempDir.deleteOnExit(); FileUtil.unTar(fullOozieShareLibTarFilePath, tempDir); // Remove shared lib to try to get the CP down. if (oozieShareLibFrameworks != null || !oozieShareLibFrameworks.isEmpty()) { Arrays.stream(Framework.values()).forEach(framework -> { if (!oozieShareLibFrameworks.contains(framework)) { LOGGER.info("OOZIE: Excluding framework " + framework.getValue() + " from shared lib."); File removeShareLibDir = new File(tempDir.getAbsolutePath() + "/share/lib/" + framework.getValue()); if (removeShareLibDir.isDirectory()) { try { org.apache.commons.io.FileUtils.deleteDirectory(removeShareLibDir); } catch (IOException e) { LOGGER.error("unable to delete directory {}", removeShareLibDir); } } } }); } return tempDir.getAbsolutePath(); }
throw new IOException("Could not delete dfs directory '" + dfsDir + "'"); FileUtil.unTar(new File(tarFile), new File(dataDir));
/** * Extract an archive to the temp directory. * Code borrowed from Hadoop's TrackerDistributedCacheManager * * @param cacheArchive the cache archive to extract * @param tmpDir root location of temp directory * @return the path to the extracted archive * @throws IOException */ public static Path extractArchiveToTemp(Path cacheArchive, File tmpDir) throws IOException { String tmpArchive = cacheArchive.getName().toLowerCase(); File srcFile = new File(cacheArchive.toString()); File destDir = new File(tmpDir, srcFile.getName()); LOG.debug(String.format("Extracting %s to %s", srcFile.toString(), destDir.toString())); if (tmpArchive.endsWith(".jar")) { RunJar.unJar(srcFile, destDir); } else if (tmpArchive.endsWith(".zip")) { FileUtil.unZip(srcFile, destDir); } else if (isTarFile(tmpArchive)) { FileUtil.unTar(srcFile, destDir); } else { LOG.warn(String.format( "Cache file %s specified as archive, but not valid extension.", srcFile.toString())); return cacheArchive; } return new Path(destDir.toString()); }
FileUtil.unZip(srcFile, destDir); } else if (isTarFile(tmpArchive)) { FileUtil.unTar(srcFile, destDir); } else { LOG.warn(String.format(
FileUtil.unZip(srcFile, destDir); } else if (isTarFile(tmpArchive)) { FileUtil.unTar(srcFile, destDir);
lowerDst.endsWith(".tgz") || lowerDst.endsWith(".tar")) { FileUtil.unTar(localrsrc, dst); } else { LOG.warn("Cannot unpack " + localrsrc); LOG.warn("Treating [" + localrsrc + "] as an archive even though it " + "was specified as PATTERN"); FileUtil.unTar(localrsrc, dst); } else { LOG.warn("Cannot unpack " + localrsrc);
lowerDst.endsWith(".tgz") || lowerDst.endsWith(".tar")) { FileUtil.unTar(inputStream, dst, lowerDst.endsWith("gz")); } else { LOG.warn("Cannot unpack " + source); LOG.warn("Treating [" + source + "] as an archive even though it " + "was specified as PATTERN"); FileUtil.unTar(inputStream, dst, lowerDst.endsWith("gz")); } else { LOG.warn("Cannot unpack " + source);
lowerDst.endsWith(".tgz") || lowerDst.endsWith(".tar")) { FileUtil.unTar(localrsrc, dst); } else { LOG.warn("Cannot unpack " + localrsrc); LOG.warn("Treating [" + localrsrc + "] as an archive even though it " + "was specified as PATTERN"); FileUtil.unTar(localrsrc, dst); } else { LOG.warn("Cannot unpack " + localrsrc);
FileUtil.unTar(srcFile, temp); srcFile = new File(temp.toString() + "/share/lib");
FileUtil.unTar(new File(tarFile), new File(dataDir));
private void doUntarAndVerify(File tarFile, File untarDir) throws IOException { if (untarDir.exists() && !FileUtil.fullyDelete(untarDir)) { throw new IOException("Could not delete directory '" + untarDir + "'"); } FileUtil.unTar(tarFile, untarDir); String parentDir = untarDir.getCanonicalPath() + Path.SEPARATOR + "name"; File testFile = new File(parentDir + Path.SEPARATOR + "version"); Assert.assertTrue(testFile.exists()); Assert.assertTrue(testFile.length() == 0); String imageDir = parentDir + Path.SEPARATOR + "image"; testFile = new File(imageDir + Path.SEPARATOR + "fsimage"); Assert.assertTrue(testFile.exists()); Assert.assertTrue(testFile.length() == 157); String currentDir = parentDir + Path.SEPARATOR + "current"; testFile = new File(currentDir + Path.SEPARATOR + "fsimage"); Assert.assertTrue(testFile.exists()); Assert.assertTrue(testFile.length() == 4331); testFile = new File(currentDir + Path.SEPARATOR + "edits"); Assert.assertTrue(testFile.exists()); Assert.assertTrue(testFile.length() == 1033); testFile = new File(currentDir + Path.SEPARATOR + "fstime"); Assert.assertTrue(testFile.exists()); Assert.assertTrue(testFile.length() == 8); }
private void doUntarAndVerify(File tarFile, File untarDir) throws IOException { if (untarDir.exists() && !FileUtil.fullyDelete(untarDir)) { throw new IOException("Could not delete directory '" + untarDir + "'"); } FileUtil.unTar(tarFile, untarDir); String parentDir = untarDir.getCanonicalPath() + Path.SEPARATOR + "name"; File testFile = new File(parentDir + Path.SEPARATOR + "version"); Assert.assertTrue(testFile.exists()); Assert.assertTrue(testFile.length() == 0); String imageDir = parentDir + Path.SEPARATOR + "image"; testFile = new File(imageDir + Path.SEPARATOR + "fsimage"); Assert.assertTrue(testFile.exists()); Assert.assertTrue(testFile.length() == 157); String currentDir = parentDir + Path.SEPARATOR + "current"; testFile = new File(currentDir + Path.SEPARATOR + "fsimage"); Assert.assertTrue(testFile.exists()); Assert.assertTrue(testFile.length() == 4331); testFile = new File(currentDir + Path.SEPARATOR + "edits"); Assert.assertTrue(testFile.exists()); Assert.assertTrue(testFile.length() == 1033); testFile = new File(currentDir + Path.SEPARATOR + "fstime"); Assert.assertTrue(testFile.exists()); Assert.assertTrue(testFile.length() == 8); }
throw new IOException("Could not delete dfs directory '" + dfsDir + "'"); FileUtil.unTar(new File(tarFile), new File(testDir));
throw new IOException("Could not delete dfs directory '" + dfsDir + "'"); FileUtil.unTar(new File(tarFile), new File(testDir));
throw new IOException("Could not delete dfs directory '" + dfsDir + "'"); FileUtil.unTar(new File(tarFile), new File(testDir)); File nameDir = new File(dfsDir, "name"); GenericTestUtils.assertExists(nameDir);