Return-Path: X-Original-To: apmail-hadoop-yarn-commits-archive@minotaur.apache.org Delivered-To: apmail-hadoop-yarn-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4AF03F302 for ; Tue, 14 May 2013 00:49:31 +0000 (UTC) Received: (qmail 41607 invoked by uid 500); 13 May 2013 23:49:31 -0000 Delivered-To: apmail-hadoop-yarn-commits-archive@hadoop.apache.org Received: (qmail 41571 invoked by uid 500); 13 May 2013 23:49:30 -0000 Mailing-List: contact yarn-commits-help@hadoop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: yarn-commits@hadoop.apache.org Delivered-To: mailing list yarn-commits@hadoop.apache.org Received: (qmail 41560 invoked by uid 99); 13 May 2013 23:49:30 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 May 2013 23:49:30 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 13 May 2013 23:49:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C78DB23889E3; Mon, 13 May 2013 23:49:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1482149 - in /hadoop/common/trunk/hadoop-yarn-project: CHANGES.txt hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java Date: Mon, 13 May 2013 23:49:05 -0000 To: yarn-commits@hadoop.apache.org From: acmurthy@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130513234905.C78DB23889E3@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: acmurthy Date: Mon May 13 23:49:05 2013 New Revision: 1482149 URL: http://svn.apache.org/r1482149 Log: YARN-597. TestFSDownload fails on Windows due to dependencies on tar/gzip/jar tools. Contributed by Ivan Mitic. Modified: hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java Modified: hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt?rev=1482149&r1=1482148&r2=1482149&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt (original) +++ hadoop/common/trunk/hadoop-yarn-project/CHANGES.txt Mon May 13 23:49:05 2013 @@ -41,6 +41,9 @@ Trunk - Unreleased classpath with new process's environment variables and localized resources (Chris Nauroth via bikas) + YARN-597. TestFSDownload fails on Windows due to dependencies on + tar/gzip/jar tools. (Ivan Mitic via acmurthy) + BREAKDOWN OF HADOOP-8562 SUBTASKS AND RELATED JIRAS YARN-158. Yarn creating package-info.java must not depend on sh. Modified: hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java?rev=1482149&r1=1482148&r2=1482149&view=diff ============================================================================== --- hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java (original) +++ hadoop/common/trunk/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/util/TestFSDownload.java Mon May 13 23:49:05 2013 @@ -25,7 +25,6 @@ import static org.junit.Assert.assertEqu import java.io.File; import java.io.FileOutputStream; import java.io.IOException; -import java.net.URI; import java.net.URISyntaxException; import java.util.EnumSet; import java.util.HashMap; @@ -36,11 +35,16 @@ import java.util.concurrent.ExecutorServ import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.atomic.AtomicLong; +import java.util.jar.JarEntry; import java.util.jar.JarOutputStream; import java.util.jar.Manifest; +import java.util.zip.ZipEntry; +import java.util.zip.ZipOutputStream; import junit.framework.Assert; +import org.apache.commons.compress.archivers.tar.TarArchiveEntry; +import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; @@ -49,12 +53,10 @@ import org.apache.hadoop.fs.FSDataOutput import org.apache.hadoop.fs.FileContext; import org.apache.hadoop.fs.FileStatus; import org.apache.hadoop.fs.FileSystem; -import org.apache.hadoop.fs.FileUtil; import org.apache.hadoop.fs.LocalDirAllocator; import org.apache.hadoop.fs.Path; import org.apache.hadoop.fs.permission.FsPermission; import org.apache.hadoop.security.UserGroupInformation; -import org.apache.hadoop.util.Shell.ShellCommandExecutor; import org.apache.hadoop.yarn.api.records.LocalResource; import org.apache.hadoop.yarn.api.records.LocalResourceType; import org.apache.hadoop.yarn.api.records.LocalResourceVisibility; @@ -122,32 +124,20 @@ public class TestFSDownload { static LocalResource createTarFile(FileContext files, Path p, int len, Random r, LocalResourceVisibility vis) throws IOException, URISyntaxException { + byte[] bytes = new byte[len]; + r.nextBytes(bytes); + + File archiveFile = new File(p.toUri().getPath() + ".tar"); + archiveFile.createNewFile(); + TarArchiveOutputStream out = new TarArchiveOutputStream( + new FileOutputStream(archiveFile)); + TarArchiveEntry entry = new TarArchiveEntry(p.getName()); + entry.setSize(bytes.length); + out.putArchiveEntry(entry); + out.write(bytes); + out.closeArchiveEntry(); + out.close(); - FSDataOutputStream outFile = null; - try { - byte[] bytes = new byte[len]; - Path tarPath = new Path(p.toString()); - outFile = files.create(tarPath, EnumSet.of(CREATE, OVERWRITE)); - r.nextBytes(bytes); - outFile.write(bytes); - } finally { - if (outFile != null) - outFile.close(); - } - StringBuffer tarCommand = new StringBuffer(); - URI u = new URI(p.getParent().toString()); - tarCommand.append("cd '"); - tarCommand.append(FileUtil.makeShellPath(u.getPath().toString())); - tarCommand.append("' ; "); - tarCommand.append("tar -czf " + p.getName() + ".tar " + p.getName()); - String[] shellCmd = { "bash", "-c", tarCommand.toString() }; - ShellCommandExecutor shexec = new ShellCommandExecutor(shellCmd); - shexec.execute(); - int exitcode = shexec.getExitCode(); - if (exitcode != 0) { - throw new IOException("Error untarring file " + p - + ". Tar process exited with exit code " + exitcode); - } LocalResource ret = recordFactory.newRecordInstance(LocalResource.class); ret.setResource(ConverterUtils.getYarnUrlFromPath(new Path(p.toString() + ".tar"))); @@ -162,32 +152,18 @@ public class TestFSDownload { static LocalResource createJarFile(FileContext files, Path p, int len, Random r, LocalResourceVisibility vis) throws IOException, URISyntaxException { + byte[] bytes = new byte[len]; + r.nextBytes(bytes); + + File archiveFile = new File(p.toUri().getPath() + ".jar"); + archiveFile.createNewFile(); + JarOutputStream out = new JarOutputStream( + new FileOutputStream(archiveFile)); + out.putNextEntry(new JarEntry(p.getName())); + out.write(bytes); + out.closeEntry(); + out.close(); - FSDataOutputStream outFile = null; - try { - byte[] bytes = new byte[len]; - Path tarPath = new Path(p.toString()); - outFile = files.create(tarPath, EnumSet.of(CREATE, OVERWRITE)); - r.nextBytes(bytes); - outFile.write(bytes); - } finally { - if (outFile != null) - outFile.close(); - } - StringBuffer tarCommand = new StringBuffer(); - URI u = new URI(p.getParent().toString()); - tarCommand.append("cd '"); - tarCommand.append(FileUtil.makeShellPath(u.getPath().toString())); - tarCommand.append("' ; "); - tarCommand.append("jar cf " + p.getName() + ".jar " + p.getName()); - String[] shellCmd = { "bash", "-c", tarCommand.toString() }; - ShellCommandExecutor shexec = new ShellCommandExecutor(shellCmd); - shexec.execute(); - int exitcode = shexec.getExitCode(); - if (exitcode != 0) { - throw new IOException("Error untarring file " + p - + ". Tar process exited with exit code " + exitcode); - } LocalResource ret = recordFactory.newRecordInstance(LocalResource.class); ret.setResource(ConverterUtils.getYarnUrlFromPath(new Path(p.toString() + ".jar"))); @@ -202,39 +178,25 @@ public class TestFSDownload { static LocalResource createZipFile(FileContext files, Path p, int len, Random r, LocalResourceVisibility vis) throws IOException, URISyntaxException { + byte[] bytes = new byte[len]; + r.nextBytes(bytes); + + File archiveFile = new File(p.toUri().getPath() + ".zip"); + archiveFile.createNewFile(); + ZipOutputStream out = new ZipOutputStream( + new FileOutputStream(archiveFile)); + out.putNextEntry(new ZipEntry(p.getName())); + out.write(bytes); + out.closeEntry(); + out.close(); - FSDataOutputStream outFile = null; - try { - byte[] bytes = new byte[len]; - Path tarPath = new Path(p.toString()); - outFile = files.create(tarPath, EnumSet.of(CREATE, OVERWRITE)); - r.nextBytes(bytes); - outFile.write(bytes); - } finally { - if (outFile != null) - outFile.close(); - } - StringBuffer zipCommand = new StringBuffer(); - URI u = new URI(p.getParent().toString()); - zipCommand.append("cd '"); - zipCommand.append(FileUtil.makeShellPath(u.getPath().toString())); - zipCommand.append("' ; "); - zipCommand.append("gzip " + p.getName()); - String[] shellCmd = { "bash", "-c", zipCommand.toString() }; - ShellCommandExecutor shexec = new ShellCommandExecutor(shellCmd); - shexec.execute(); - int exitcode = shexec.getExitCode(); - if (exitcode != 0) { - throw new IOException("Error untarring file " + p - + ". Tar process exited with exit code " + exitcode); - } LocalResource ret = recordFactory.newRecordInstance(LocalResource.class); ret.setResource(ConverterUtils.getYarnUrlFromPath(new Path(p.toString() + ".zip"))); ret.setSize(len); ret.setType(LocalResourceType.ARCHIVE); ret.setVisibility(vis); - ret.setTimestamp(files.getFileStatus(new Path(p.toString() + ".gz")) + ret.setTimestamp(files.getFileStatus(new Path(p.toString() + ".zip")) .getModificationTime()); return ret; }