Gitlab Community Edition Instance

Skip to content

StoragePool API change to use nio channels instead of streams or write-methods

Marcel Hellkamp requested to merge feature-channel-io into master

The current API to write to storage resources does not have a way to signal "I am done writing", so backing file handles must be closed after each write, or we risk file handle exhaustion. Reading is better, as it used a closable InputStream.

This patch replaces both reading and writing to storage pool resources with Readable- and WritableByteChannel based APIs. These channels are closable and can directly map to an opened FileChannel, socket or other closable resource, which can be kept open between writes if applicable.

The new API also enforces some sanity checks and restrictions to prevent common bugs. Many read, but only one write channel can be acquired, and reading is not possible while writing. The API ensures that by closing all read-channels and any write-channel as soon as a new write-channel is requested.

The old APIs are kept as deprecated default methods.

Merge request reports

Loading