Class BufferSubscriber
- java.lang.Object
-
- com.epam.reportportal.service.logs.BufferSubscriber
-
- All Implemented Interfaces:
io.reactivex.FlowableSubscriber<SaveLogRQ>,org.reactivestreams.Subscriber<SaveLogRQ>,org.reactivestreams.Subscription
public class BufferSubscriber extends java.lang.Object implements io.reactivex.FlowableSubscriber<SaveLogRQ>, org.reactivestreams.Subscription
A subscriber that buffers incomingSaveLogRQobjects until certain conditions are met, then emits them as batches to the downstream subscriber.This class implements a buffering mechanism with two boundary conditions:
- Maximum number of log items in a batch (specified by
batchMaxSize) - Maximum payload size of a batch in bytes (specified by
batchPayloadLimit)
When either of these conditions is met, the current buffer is emitted downstream as a list and a new buffer is created. This helps optimize network requests by batching multiple logs together while ensuring the batch size remains within reasonable limits.
The class is thread-safe, using a
ReentrantLockto protect access to the buffer during concurrent operations.
-
-
Constructor Summary
Constructors Constructor Description BufferSubscriber(org.reactivestreams.Subscriber<? super java.util.List<SaveLogRQ>> actual, int batchMaxSize, long batchPayloadLimit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcancel()voidonComplete()voidonError(java.lang.Throwable t)voidonNext(SaveLogRQ t)voidonSubscribe(org.reactivestreams.Subscription s)voidrequest(long n)
-
-
-
Constructor Detail
-
BufferSubscriber
public BufferSubscriber(org.reactivestreams.Subscriber<? super java.util.List<SaveLogRQ>> actual, int batchMaxSize, long batchPayloadLimit)
-
-
Method Detail
-
onSubscribe
public void onSubscribe(@Nonnull org.reactivestreams.Subscription s)
-
onNext
public void onNext(SaveLogRQ t)
- Specified by:
onNextin interfaceorg.reactivestreams.Subscriber<SaveLogRQ>
-
onError
public void onError(java.lang.Throwable t)
- Specified by:
onErrorin interfaceorg.reactivestreams.Subscriber<SaveLogRQ>
-
onComplete
public void onComplete()
- Specified by:
onCompletein interfaceorg.reactivestreams.Subscriber<SaveLogRQ>
-
request
public void request(long n)
- Specified by:
requestin interfaceorg.reactivestreams.Subscription
-
cancel
public void cancel()
- Specified by:
cancelin interfaceorg.reactivestreams.Subscription
-
-