/** * Adds an archive entry to this archive. * <p> * This method is expected to be called from a single client thread * </p> * * @param zipArchiveEntry The entry to add. * @param source The source input stream supplier */ public void addArchiveEntry(final ZipArchiveEntry zipArchiveEntry, final InputStreamSupplier source) { submit(createCallable(zipArchiveEntry, source)); }
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(); }
/** * Creates a new {@code ConcurrentJarCreator} instance. * <p> * {@code ConcurrentJarCreator} creates zip files using several concurrent threads. * Entries that are already zip file could be just stored or compressed again.</p> * * @param compressAddedZips Indicates if entries that are zip files should be compressed. * If set to {@code false} entries that are zip files will be added using * {@link ZipEntry#STORED} method. * If set to {@code true} entries that are zip files will be added using * the compression method indicated by the {@code ZipArchiveEntry} passed * to {@link #addArchiveEntry(ZipArchiveEntry, InputStreamSupplier, boolean)}. * The compression method for all entries that are not zip files will not be changed * regardless of the value of this parameter * @param nThreads The number of concurrent thread used to create the archive * * @throws IOException */ public ConcurrentJarCreator( boolean compressAddedZips, int nThreads ) throws IOException { this.compressAddedZips = compressAddedZips; ScatterGatherBackingStoreSupplier defaultSupplier = new DeferredSupplier( 100000000 / nThreads ); directories = createDeferred( defaultSupplier ); manifest = createDeferred( defaultSupplier ); metaInfDir = createDeferred( defaultSupplier ); synchronousEntries = createDeferred( defaultSupplier ); parallelScatterZipCreator = new ParallelScatterZipCreator( Executors.newFixedThreadPool( nThreads ), defaultSupplier ); }
parallelScatterZipCreator.addArchiveEntry( createEntrySupplier( zipArchiveEntry, source ) );
/** * Returns a message describing the overall statistics of the compression run * * @return A string */ public String getStatisticsMessage() { return parallelScatterZipCreator.getStatisticsMessage() + " Zip Close: " + zipCloseElapsed + "ms"; }
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"); }
scatterZipCreator = new ParallelScatterZipCreator(Executors.newFixedThreadPool(numConnections)); } catch (NoSuchAlgorithmException | KeyManagementException e) { logger.warning("Aint gonna work");
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); }
/** * Adds an archive entry to this archive. * <p> * This method is expected to be called from a single client thread * </p> * * @param zipArchiveEntryRequestSupplier Should supply the entry to be added. * @since 1.13 */ public void addArchiveEntry(final ZipArchiveEntryRequestSupplier zipArchiveEntryRequestSupplier) { submit(createCallable(zipArchiveEntryRequestSupplier)); }
/** * Adds an archive entry to this archive. * <p> * This method is expected to be called from a single client thread * </p> * * @param zipArchiveEntryRequestSupplier Should supply the entry to be added. * @since 1.13 */ public void addArchiveEntry(final ZipArchiveEntryRequestSupplier zipArchiveEntryRequestSupplier) { submit(createCallable(zipArchiveEntryRequestSupplier)); }
/** * Adds an archive entry to this archive. * <p> * This method is expected to be called from a single client thread * </p> * * @param zipArchiveEntry The entry to add. * @param source The source input stream supplier */ public void addArchiveEntry(final ZipArchiveEntry zipArchiveEntry, final InputStreamSupplier source) { submit(createCallable(zipArchiveEntry, source)); }