...
ByteBufferPool(size) - constructor with maximum number of bytes to allocate by all buffers together.
Using buffers only of size of power of 2 simplifies maintenance of the buffers and search. Internal structure to use:
...
...
In case of encryption 2 buffers will be required. First one as usual will be used for keeping serialized entry, and the second one will be for storing encrypted data from the first buffer. After encryption the first buffer will be returned back to the pool. The second buffer will go to the partition queue.
Note: Avoid deadlock when processing large objects not fitting into pool size.
Compression is done after encryption (if enabled). This can remain in the same thread (part/trans thread).
Compression output is a sequence of buffers which can't be reordered. Compression per partition can't be done in 2 threads simultaneously.
The size of required buffer isn't known while requesting buffer from pool. It is preferable to use medium size buffers. And it is ok to get a bit smaller buffer for this, fill it, send it to queue and request another medium size buffer from pool.
...
Once dump creating is over, all resources will be cleaned.
In case of error the whole execution will stop. Resuming creating dump isn't considered, the only option is to rerun creating dump.
What happens if a dump entry doesn't fit into pool size?
Is the order of entries in dump important? Is it acceptable to write ver 3 (from trans thread) before ver 2 (by par thread) ?
HeapByteBuffer or DirectByteBuffer ?
Is there a protection against simultaneous dump creation ? Do we need one?