@Stable public class RetryableLogObserver extends java.lang.Object implements LogObserver
LogObserver which is able to retry the observation on error. The number of retries is
configurable.LogObserver.OffsetCommitter, LogObserver.OnIdleContext, LogObserver.OnNextContext, LogObserver.OnRepartitionContext| Modifier and Type | Field and Description |
|---|---|
private LogObserver |
delegate
Underlying log observer.
|
private int |
maxRetries
Maximal number of retries.
|
private java.lang.String |
name
Name of the consumer.
|
private int |
numFailures
Current number of failures in a row.
|
| Modifier | Constructor and Description |
|---|---|
private |
RetryableLogObserver(java.lang.String name,
int maxRetries,
LogObserver delegate) |
| Modifier and Type | Method and Description |
|---|---|
static RetryableLogObserver |
of(java.lang.String name,
int numRetries,
LogObserver observer)
Create online retryable log observer.
|
void |
onCancelled()
Notify that the processing has been canceled.
|
void |
onCompleted()
Notify that the processing has gracefully ended.
|
boolean |
onError(java.lang.Throwable throwable)
Called to notify there was an {@link Throwable error) in the commit reader.
|
void |
onIdle(LogObserver.OnIdleContext context)
Called when the observer is idle.
|
boolean |
onNext(StreamElement ingest,
LogObserver.OnNextContext context)
Process next record in the commit log.
|
void |
onRepartition(LogObserver.OnRepartitionContext context)
Callback to notify of automatic repartitioning.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitonException, onFatalErrorprivate final int maxRetries
private final java.lang.String name
private int numFailures
private final LogObserver delegate
private RetryableLogObserver(java.lang.String name,
int maxRetries,
LogObserver delegate)
public static RetryableLogObserver of(java.lang.String name, int numRetries, LogObserver observer)
name - name of the consumernumRetries - number of allowed successive failuresobserver - observer of datapublic final boolean onNext(StreamElement ingest, LogObserver.OnNextContext context)
LogObserveronNext in interface LogObserveringest - the ingested data written to the commit logcontext - a context that the application must use to confirm processing of the ingest. If
the application fails to do so, the result is undefined.true if the processing should continue, false otherwisepublic boolean onError(java.lang.Throwable throwable)
LogObserveronError in interface LogObserverthrowable - error caught during processingtrue to restart processing from last committed position, false to stop
processingpublic void onCompleted()
LogObserveronCompleted in interface LogObserverpublic void onCancelled()
LogObserveronCancelled in interface LogObserverpublic void onRepartition(LogObserver.OnRepartitionContext context)
LogObserverLogObserver.onNext(cz.o2.proxima.storage.StreamElement, cz.o2.proxima.direct.commitlog.LogObserver.OnNextContext) call happens.onRepartition in interface LogObservercontext - context of the repartitionpublic void onIdle(LogObserver.OnIdleContext context)
LogObserverLogObserver.onNext(cz.o2.proxima.storage.StreamElement, cz.o2.proxima.direct.commitlog.LogObserver.OnNextContext) will be called eventually.
Typical example of commit log with no need to call LogObserver.onIdle(cz.o2.proxima.direct.commitlog.LogObserver.OnIdleContext) is google PubSub, having
virtually single shared partition which loads balances incoming data.
onIdle in interface LogObservercontext - the context for on idle processingCopyright © 2017–2021. All rights reserved.