Graylog2/graylog2-server — pull request #201 by mahijames (2013-08-29 15:30:55+00:00)
Title: Add bulk hasCapacity/insert methods

For transports that support queueing and redelivery of batches of messages (i.e. [Facebook Scribe](https://github.com/facebook/scribe/wiki)), it is advantageous to add the message batch to the ProcessBuffer atomically.

This means the plugin can fail fast if insufficient capacity is available, and exert backpressure on the transport causing it to queue messages on disk and/or back off (e.g. via Scribe's [TRY_LATER](https://github.com/facebook/scribe/wiki/Logging-Messages) response). Note that Scribe requires the batch of messages to be acknowledged as a whole, so if the batch is partially processed before a failure occurs (i.e. without atomic processing), any part of the batch which was processed will be delivered twice.

It is also slightly more efficient to acquire a sequence number for the whole batch in a single operation rather than incrementing the sequence number by one repeatedly.

This patch implements this functionality for ProcessBuffer only via a new BatchBuffer interface.