for (final ScatterZipOutputStream scatterStream : streams) { scatterStream.writeTo(targetStream); scatterStream.close();
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(); }
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"); }
/** * 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(); }