Adds flush.file.size to allow file size based rotation #671
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
See: #365
We want to be able to control the size of the files produced by the connector.
Solution
This change gets us in the vicinity of such a feature. A file size guarantee would require a major rewrite, as the current logic is based on partitions.
The file size based rotation is implemented in such a way, that we rotate all open files for a given
TopicPartitionWriter
instance, when any file has reached the configured limit.I wanted a solution that does not have to count bytes and do unnecessary serialization, thus I implemented a few wrappers around the existing OutputStreams, which allow us to access the current file size. This implies that, even with small messages, we will produce files that may be larger than configured depending on the size of the output buffers.
I'm happy to work on this more, if you all are open to this feature. For the use case I have at my company, this current version is sufficient.
Does this solution apply anywhere else?
If yes, where?
Test Strategy
Testing done:
I am running this on a Kafka Connect 7.2.4 cluster, so far no issues with String and Avro formats.