private void emitLargeEvent(byte[] eventBytes) { byte[] buffer = acquireBuffer(); int bufferOffset = batchingStrategy.writeBatchStart(buffer); System.arraycopy(eventBytes, 0, buffer, bufferOffset, eventBytes.length); bufferOffset += eventBytes.length; bufferOffset = batchingStrategy.writeBatchEnd(buffer, bufferOffset); if (sendWithRetries(buffer, bufferOffset, 1, true)) { buffersToReuse.add(buffer); approximateBuffersToReuseCount.incrementAndGet(); } else { limitFailedBuffersSize(); failedBuffers.addLast(new FailedBuffer(buffer, bufferOffset, 1)); approximateFailedBuffersCount.incrementAndGet(); } }
private void tryEmitAndDrainAllFailedBuffers() { for (FailedBuffer failedBuffer; (failedBuffer = failedBuffers.pollFirst()) != null; ) { sendWithRetries(failedBuffer.buffer, failedBuffer.length, failedBuffer.eventCount, false); approximateFailedBuffersCount.decrementAndGet(); } }
int bufferEndOffset = batchingStrategy.writeBatchEnd(batch.buffer, bufferWatermark); if (sendWithRetries(batch.buffer, bufferEndOffset, eventCount, true)) { buffersToReuse.add(batch.buffer); approximateBuffersToReuseCount.incrementAndGet();
int bufferEndOffset = batchingStrategy.writeBatchEnd(batch.buffer, bufferWatermark); if (sendWithRetries(batch.buffer, bufferEndOffset, eventCount, true)) { buffersToReuse.add(batch.buffer); approximateBuffersToReuseCount.incrementAndGet();
private void tryEmitOneFailedBuffer() { FailedBuffer failedBuffer = failedBuffers.peekFirst(); if (failedBuffer != null) { if (sendWithRetries(failedBuffer.buffer, failedBuffer.length, failedBuffer.eventCount, false)) { // Remove from the queue of failed buffer. failedBuffers.pollFirst(); approximateFailedBuffersCount.decrementAndGet(); // Don't add the failed buffer back to the buffersToReuse queue here, because in a situation when we were not // able to emit events for a while we don't have a way to discard buffers that were used to accumulate events // during that period, if they are added back to buffersToReuse. For instance it may result in having 100 // buffers in rotation even if we need just 2. } } }
private void emitLargeEvent(byte[] eventBytes) { byte[] buffer = acquireBuffer(); int bufferOffset = batchingStrategy.writeBatchStart(buffer); System.arraycopy(eventBytes, 0, buffer, bufferOffset, eventBytes.length); bufferOffset += eventBytes.length; bufferOffset = batchingStrategy.writeBatchEnd(buffer, bufferOffset); if (sendWithRetries(buffer, bufferOffset, 1, true)) { buffersToReuse.add(buffer); approximateBuffersToReuseCount.incrementAndGet(); } else { limitFailedBuffersSize(); failedBuffers.addLast(new FailedBuffer(buffer, bufferOffset, 1)); approximateFailedBuffersCount.incrementAndGet(); } }
private void tryEmitAndDrainAllFailedBuffers() { for (FailedBuffer failedBuffer; (failedBuffer = failedBuffers.pollFirst()) != null; ) { sendWithRetries(failedBuffer.buffer, failedBuffer.length, failedBuffer.eventCount, false); approximateFailedBuffersCount.decrementAndGet(); } }
private void tryEmitOneFailedBuffer() { FailedBuffer failedBuffer = failedBuffers.peekFirst(); if (failedBuffer != null) { if (sendWithRetries(failedBuffer.buffer, failedBuffer.length, failedBuffer.eventCount, false)) { // Remove from the queue of failed buffer. failedBuffers.pollFirst(); approximateFailedBuffersCount.decrementAndGet(); // Don't add the failed buffer back to the buffersToReuse queue here, because in a situation when we were not // able to emit events for a while we don't have a way to discard buffers that were used to accumulate events // during that period, if they are added back to buffersToReuse. For instance it may result in having 100 // buffers in rotation even if we need just 2. } } }