public class ParallelScatterZipCreator
extends java.lang.Object
ScatterZipOutputStream
instances.
Note that this class generally makes no guarantees about the order of things written to
the output file. Things that need to come in a specific order (manifests, directories)
must be handled by the client of this class, usually by writing these things to the
ZipArchiveOutputStream
before calling writeTo
on this class.
The client can supply an ExecutorService
, but for reasons of
memory model consistency, this will be shut down by this class prior to completion.
Constructor and Description |
---|
ParallelScatterZipCreator()
Create a ParallelScatterZipCreator with default threads, which is set to the number of available
processors, as defined by
Runtime.availableProcessors() |
ParallelScatterZipCreator(java.util.concurrent.ExecutorService executorService)
Create a ParallelScatterZipCreator
|
ParallelScatterZipCreator(java.util.concurrent.ExecutorService executorService,
ScatterGatherBackingStoreSupplier backingStoreSupplier)
Create a ParallelScatterZipCreator
|
Modifier and Type | Method and Description |
---|---|
void |
addArchiveEntry(ZipArchiveEntry zipArchiveEntry,
InputStreamSupplier source)
Adds an archive entry to this archive.
|
void |
addArchiveEntry(ZipArchiveEntryRequestSupplier zipArchiveEntryRequestSupplier)
Adds an archive entry to this archive.
|
java.util.concurrent.Callable<java.lang.Object> |
createCallable(ZipArchiveEntry zipArchiveEntry,
InputStreamSupplier source)
Create a callable that will compress the given archive entry.
|
java.util.concurrent.Callable<java.lang.Object> |
createCallable(ZipArchiveEntryRequestSupplier zipArchiveEntryRequestSupplier)
Create a callable that will compress archive entry supplied by
ZipArchiveEntryRequestSupplier . |
ScatterStatistics |
getStatisticsMessage()
Returns a message describing the overall statistics of the compression run
|
void |
submit(java.util.concurrent.Callable<java.lang.Object> callable)
Submit a callable for compression.
|
void |
writeTo(ZipArchiveOutputStream targetStream)
Write the contents this to the target
ZipArchiveOutputStream . |
public ParallelScatterZipCreator()
Runtime.availableProcessors()
public ParallelScatterZipCreator(java.util.concurrent.ExecutorService executorService)
executorService
- The executorService to use for parallel scheduling. For technical reasons,
this will be shut down by this class.public ParallelScatterZipCreator(java.util.concurrent.ExecutorService executorService, ScatterGatherBackingStoreSupplier backingStoreSupplier)
executorService
- The executorService to use. For technical reasons, this will be shut down
by this class.backingStoreSupplier
- The supplier of backing store which shall be usedpublic void addArchiveEntry(ZipArchiveEntry zipArchiveEntry, InputStreamSupplier source)
This method is expected to be called from a single client thread
zipArchiveEntry
- The entry to add.source
- The source input stream supplierpublic void addArchiveEntry(ZipArchiveEntryRequestSupplier zipArchiveEntryRequestSupplier)
This method is expected to be called from a single client thread
zipArchiveEntryRequestSupplier
- Should supply the entry to be added.public final void submit(java.util.concurrent.Callable<java.lang.Object> callable)
callable
- The callable to run, created by createCallable
, possibly wrapped by caller.for details of if/when to use this.
public final java.util.concurrent.Callable<java.lang.Object> createCallable(ZipArchiveEntry zipArchiveEntry, InputStreamSupplier source)
This method is expected to be called from a single client thread.
Consider usingaddArchiveEntry
, which wraps this method and submit
.
The most common use case for using createCallable
and submit
from a
client is if you want to wrap the callable in something that can be prioritized by the supplied
ExecutorService
, for instance to process large or slow files first.
Since the creation of the ExecutorService
is handled by the client, all of this is up to the client.zipArchiveEntry
- The entry to add.source
- The source input stream supplierpublic final java.util.concurrent.Callable<java.lang.Object> createCallable(ZipArchiveEntryRequestSupplier zipArchiveEntryRequestSupplier)
ZipArchiveEntryRequestSupplier
.
This method is expected to be called from a single client thread.
The same ascreateCallable(ZipArchiveEntry, InputStreamSupplier)
, but the archive entry
to be added is supplied by a ZipArchiveEntryRequestSupplier
.zipArchiveEntryRequestSupplier
- Should supply the entry to be added.createCallable(ZipArchiveEntry, InputStreamSupplier)
public void writeTo(ZipArchiveOutputStream targetStream) throws java.io.IOException, java.lang.InterruptedException, java.util.concurrent.ExecutionException
ZipArchiveOutputStream
.
It may be beneficial to write things like directories and manifest files to the targetStream before calling this method.
Calling this method will shut down the ExecutorService
used by this class. If any of the Callable
s submit(java.util.concurrent.Callable<java.lang.Object>)
ted to this instance throws an exception, the archive can not be created properly and
this method will throw an exception.
targetStream
- The ZipArchiveOutputStream
to receive the contents of the scatter streamsjava.io.IOException
- If writing failsjava.lang.InterruptedException
- If we get interruptedjava.util.concurrent.ExecutionException
- If something happens in the parallel executionpublic ScatterStatistics getStatisticsMessage()
"Copyright © 2010 - 2020 Adobe Systems Incorporated. All Rights Reserved"