Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 53967 invoked from network); 5 Nov 2010 19:32:16 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Nov 2010 19:32:16 -0000 Received: (qmail 52944 invoked by uid 500); 5 Nov 2010 19:32:47 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 52824 invoked by uid 500); 5 Nov 2010 19:32:47 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 52815 invoked by uid 99); 5 Nov 2010 19:32:47 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Nov 2010 19:32:47 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of ralph.goers@dslextreme.com designates 209.85.216.178 as permitted sender) Received: from [209.85.216.178] (HELO mail-qy0-f178.google.com) (209.85.216.178) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 05 Nov 2010 19:32:39 +0000 Received: by qyk9 with SMTP id 9so978608qyk.9 for ; Fri, 05 Nov 2010 12:32:18 -0700 (PDT) Received: by 10.229.217.133 with SMTP id hm5mr2274469qcb.258.1288985538411; Fri, 05 Nov 2010 12:32:18 -0700 (PDT) Received: from [10.20.89.255] ([38.101.196.246]) by mx.google.com with ESMTPS id t35sm1677458qco.18.2010.11.05.12.32.16 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 05 Nov 2010 12:32:17 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Apple Message framework v1081) Subject: Re: svn commit: r1031735 - /commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provider/tar/test/LargeTarTestCase.java From: Ralph Goers In-Reply-To: <20101105192607.014602388994@eris.apache.org> Date: Fri, 5 Nov 2010 12:32:15 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: References: <20101105192607.014602388994@eris.apache.org> To: dev@commons.apache.org X-Mailer: Apple Mail (2.1081) I added the 3MB file to the test-data directory, so createLargeFile = normally won't run. Are there any more changes? I'm ready to try the release again. Ralph On Nov 5, 2010, at 12:26 PM, sebb@apache.org wrote: > Author: sebb > Date: Fri Nov 5 19:26:06 2010 > New Revision: 1031735 >=20 > URL: http://svn.apache.org/viewvc?rev=3D1031735&view=3Drev > Log: > Eliminate 3GB data file by using PipedI/O Streams >=20 > Modified: > = commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provide= r/tar/test/LargeTarTestCase.java >=20 > Modified: = commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provide= r/tar/test/LargeTarTestCase.java > URL: = http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/test/java/o= rg/apache/commons/vfs/provider/tar/test/LargeTarTestCase.java?rev=3D103173= 5&r1=3D1031734&r2=3D1031735&view=3Ddiff > = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D > --- = commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provide= r/tar/test/LargeTarTestCase.java (original) > +++ = commons/proper/vfs/trunk/core/src/test/java/org/apache/commons/vfs/provide= r/tar/test/LargeTarTestCase.java Fri Nov 5 19:26:06 2010 > @@ -17,15 +17,16 @@ > package org.apache.commons.vfs.provider.tar.test; >=20 > import java.io.File; > -import java.io.FileInputStream; > import java.io.FileOutputStream; > -import java.io.InputStream; > import java.io.OutputStream; > +import java.io.PipedInputStream; > +import java.io.PipedOutputStream; > import java.util.Arrays; > import java.util.Iterator; > import java.util.List; >=20 > import junit.framework.TestCase; > + > import org.apache.commons.compress.archivers.ArchiveStreamFactory; > import org.apache.commons.compress.archivers.tar.TarArchiveEntry; > import = org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; > @@ -58,6 +59,7 @@ public class LargeTarTestCase extends Te > manager.addProvider("tgz", new TarFileProvider()); > manager.addProvider("tar", new TarFileProvider()); >=20 > + new File(baseDir).mkdir(); // if test is run standalone > createLargeFile(largeFilePath, largeFileName); > } >=20 > @@ -140,61 +142,66 @@ public class LargeTarTestCase extends Te > } >=20 > //@SuppressWarnings("unused") > - protected void createLargeFile(String path, String name) throws = Exception { > - long _1K =3D 1024; > - long _1M =3D 1024 * _1K; > - long _256M =3D 256 * _1M; > - long _512M =3D 512 * _1M; > - long _1G =3D 1024 * _1M; > + protected void createLargeFile(String path, final String name) = throws Exception { > + final long _1K =3D 1024; > + final long _1M =3D 1024 * _1K; > +// long _256M =3D 256 * _1M; > +// long _512M =3D 512 * _1M; > + final long _1G =3D 1024 * _1M; >=20 > // File size of 3 GB > - long fileSize =3D 3 * _1G; > + final long fileSize =3D 3 * _1G; >=20 > File tarGzFile =3D new File(path + name + ".tar.gz"); >=20 > if(!tarGzFile.exists()) { > - System.out.println("This test is a bit slow. It needs to write = a 3GB file to your hard drive"); > - > - // Create archive > - OutputStream outTarFileStream =3D new FileOutputStream(path + = name + ".tar"); > - > - TarArchiveOutputStream outTarStream =3D = (TarArchiveOutputStream)new ArchiveStreamFactory() > - .createArchiveOutputStream(ArchiveStreamFactory.TAR, = outTarFileStream); > - > - // Create archive contents > - TarArchiveEntry tarArchiveEntry =3D new TarArchiveEntry(name + = ".txt"); > - tarArchiveEntry.setSize(fileSize); > - > - outTarStream.putArchiveEntry(tarArchiveEntry); > - for(long i =3D 0; i < fileSize; i++) { > - outTarStream.write('a'); > - } > - > - outTarStream.closeArchiveEntry(); > - outTarStream.close(); > - > - outTarFileStream.close(); > + System.out.println("This test is a bit slow. It needs to write = 3GB of data as a compressed file (approx. 3MB) to your hard drive"); >=20 > + final PipedOutputStream outTarFileStream =3D new = PipedOutputStream(); > + PipedInputStream inTarFileStream =3D new = PipedInputStream(outTarFileStream); > + =20 > + Thread source =3D new Thread(){ > + > + public void run() { > + byte ba_1k[] =3D new byte[(int) _1K]; > + for(int i=3D0; i < ba_1k.length; i++){ > + ba_1k[i]=3D'a'; > + } > + try { > + TarArchiveOutputStream outTarStream =3D=20 > + (TarArchiveOutputStream)new = ArchiveStreamFactory() > + = .createArchiveOutputStream(ArchiveStreamFactory.TAR, outTarFileStream); > + // Create archive contents > + TarArchiveEntry tarArchiveEntry =3D new = TarArchiveEntry(name + ".txt"); > + tarArchiveEntry.setSize(fileSize); > + > + outTarStream.putArchiveEntry(tarArchiveEntry); > + for(long i =3D 0; i < fileSize; i+=3D ba_1k.length) { > + outTarStream.write(ba_1k); > + } > + outTarStream.closeArchiveEntry(); > + outTarStream.close(); > + outTarFileStream.close(); > + } catch (Exception e) { > + e.printStackTrace(); > + } > + } > + =20 > + }; > + source.start(); > + =20 > // Create compressed archive > OutputStream outGzipFileStream =3D new FileOutputStream(path + = name + ".tar.gz"); >=20 > GzipCompressorOutputStream outGzipStream =3D = (GzipCompressorOutputStream)new CompressorStreamFactory() > .createCompressorOutputStream(CompressorStreamFactory.GZIP, = outGzipFileStream); >=20 > - // Compress archive > - InputStream inTarFileStream =3D new FileInputStream(path + name = + ".tar"); > - // TODO: Change to a Piped Stream to conserve disk space > IOUtils.copy(inTarFileStream, outGzipStream); > inTarFileStream.close(); >=20 > outGzipStream.close(); > outGzipFileStream.close(); >=20 > - // Cleanup original tar > - File tarFile =3D new File(path + name + ".tar"); > - if(tarFile.exists()) { > - tarFile.delete(); > - } > } > } > } >=20 >=20 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org