@Override public Object call() throws Exception { tlScatterStreams.get().addArchiveEntry(zipArchiveEntryRequest); return null; } };
private ScatterZipOutputStream createDeferred(final ScatterGatherBackingStoreSupplier scatterGatherBackingStoreSupplier) throws IOException { final ScatterGatherBackingStore bs = scatterGatherBackingStoreSupplier.get(); // lifecycle is bound to the ScatterZipOutputStream returned final StreamCompressor sc = StreamCompressor.create(Deflater.DEFAULT_COMPRESSION, bs); //NOSONAR return new ScatterZipOutputStream(bs, sc); }
/** * Create a {@link ScatterZipOutputStream} with default compression level that is backed by a file * * @param file The file to offload compressed data into. * @return A ScatterZipOutputStream that is ready for use. * @throws FileNotFoundException if the file cannot be found */ public static ScatterZipOutputStream fileBased(final File file) throws FileNotFoundException { return fileBased(file, Deflater.DEFAULT_COMPRESSION); }
/** * Create a {@link ScatterZipOutputStream} with default compression level that is backed by a file * * @param file The file to offload compressed data into. * @return A ScatterZipOutputStream that is ready for use. * @throws FileNotFoundException if the file cannot be found */ public static ScatterZipOutputStream fileBased(final File file) throws FileNotFoundException { return fileBased(file, Deflater.DEFAULT_COMPRESSION); }
public void writeTo( ZipArchiveOutputStream targetStream ) throws IOException, ExecutionException, InterruptedException { metaInfDir.writeTo( targetStream ); manifest.writeTo( targetStream ); directories.writeTo( targetStream ); synchronousEntries.writeTo( targetStream ); parallelScatterZipCreator.writeTo( targetStream ); long startAt = System.currentTimeMillis(); targetStream.close(); zipCloseElapsed = System.currentTimeMillis() - startAt; metaInfDir.close(); manifest.close(); directories.close(); synchronousEntries.close(); }
@Override public Object call() throws Exception { tlScatterStreams.get().addArchiveEntry(zipArchiveEntryRequestSupplier.get()); return null; } };
/** * Create a {@link ScatterZipOutputStream} that is backed by a file * * @param file The file to offload compressed data into. * @param compressionLevel The compression level to use, @see #Deflater * @return A ScatterZipOutputStream that is ready for use. * @throws FileNotFoundException if the file cannot be found */ public static ScatterZipOutputStream fileBased(final File file, final int compressionLevel) throws FileNotFoundException { final ScatterGatherBackingStore bs = new FileBasedScatterGatherBackingStore(file); // lifecycle is bound to the ScatterZipOutputStream returned final StreamCompressor sc = StreamCompressor.create(compressionLevel, bs); //NOSONAR return new ScatterZipOutputStream(bs, sc); } }
dirs = ScatterZipOutputStream.fileBased(tmp);
public void writeTo(ZipArchiveOutputStream zipArchiveOutputStream) throws IOException, ExecutionException, InterruptedException { logger.fine("Writing dirs"); dirs.writeTo(zipArchiveOutputStream); dirs.close(); logger.fine("Dirs written"); scatterZipCreator.writeTo(zipArchiveOutputStream); logger.fine("Files written"); }
directories.addArchiveEntry( createZipArchiveEntryRequest( zipArchiveEntry, createInputStreamSupplier( payload ) ) ); metaInfDir.addArchiveEntry( createZipArchiveEntryRequest( zipArchiveEntry, createInputStreamSupplier( payload ) ) ); manifest.addArchiveEntry( createZipArchiveEntryRequest( zipArchiveEntry, createInputStreamSupplier( payload ) ) ); synchronousEntries.addArchiveEntry( createEntry( zipArchiveEntry, source ) );
public static ScatterZipOutputStream createDeferred( ScatterGatherBackingStoreSupplier scatterGatherBackingStoreSupplier ) throws IOException { ScatterGatherBackingStore bs = scatterGatherBackingStoreSupplier.get(); StreamCompressor sc = StreamCompressor.create( Deflater.DEFAULT_COMPRESSION, bs ); return new ScatterZipOutputStream( bs, sc ); }
/** * Write the contents this to the target {@link ZipArchiveOutputStream}. * <p> * It may be beneficial to write things like directories and manifest files to the targetStream * before calling this method. * </p> * * @param targetStream The {@link ZipArchiveOutputStream} to receive the contents of the scatter streams * @throws IOException If writing fails * @throws InterruptedException If we get interrupted * @throws ExecutionException If something happens in the parallel execution */ public void writeTo(final ZipArchiveOutputStream targetStream) throws IOException, InterruptedException, ExecutionException { // Make sure we catch any exceptions from parallel phase for (final Future<?> future : futures) { future.get(); } es.shutdown(); es.awaitTermination(1000 * 60L, TimeUnit.SECONDS); // == Infinity. We really *must* wait for this to complete // It is important that all threads terminate before we go on, ensure happens-before relationship compressionDoneAt = System.currentTimeMillis(); synchronized (streams) { for (final ScatterZipOutputStream scatterStream : streams) { scatterStream.writeTo(targetStream); scatterStream.close(); } } scatterDoneAt = System.currentTimeMillis(); }
@Override public Object call() throws Exception { tlScatterStreams.get().addArchiveEntry(zipArchiveEntryRequest); return null; } };
private ScatterZipOutputStream createDeferred(final ScatterGatherBackingStoreSupplier scatterGatherBackingStoreSupplier) throws IOException { final ScatterGatherBackingStore bs = scatterGatherBackingStoreSupplier.get(); // lifecycle is bound to the ScatterZipOutputStream returned final StreamCompressor sc = StreamCompressor.create(Deflater.DEFAULT_COMPRESSION, bs); //NOSONAR return new ScatterZipOutputStream(bs, sc); }
@Override public Object call() throws Exception { tlScatterStreams.get().addArchiveEntry(zipArchiveEntryRequestSupplier.get()); return null; } };
/** * Create a {@link ScatterZipOutputStream} that is backed by a file * * @param file The file to offload compressed data into. * @param compressionLevel The compression level to use, @see #Deflater * @return A ScatterZipOutputStream that is ready for use. * @throws FileNotFoundException if the file cannot be found */ public static ScatterZipOutputStream fileBased(final File file, final int compressionLevel) throws FileNotFoundException { final ScatterGatherBackingStore bs = new FileBasedScatterGatherBackingStore(file); // lifecycle is bound to the ScatterZipOutputStream returned final StreamCompressor sc = StreamCompressor.create(compressionLevel, bs); //NOSONAR return new ScatterZipOutputStream(bs, sc); } }
public void addEntry(ZipArchiveEntry zipArchiveEntry, InputStreamSupplier streamSupplier) throws IOException { if (zipArchiveEntry.isDirectory() && !zipArchiveEntry.isUnixSymlink()) dirs.addArchiveEntry(ZipArchiveEntryRequest.createZipArchiveEntryRequest(zipArchiveEntry, streamSupplier)); else scatterZipCreator.addArchiveEntry(zipArchiveEntry, streamSupplier); }