Class CommitLogObservers.ForwardingObserver
- java.lang.Object
-
- cz.o2.proxima.direct.core.commitlog.CommitLogObservers.ForwardingObserver
-
- All Implemented Interfaces:
CommitLogObserver,LogObserver<Offset,CommitLogObserver.OnNextContext>
- Enclosing class:
- CommitLogObservers
public static class CommitLogObservers.ForwardingObserver extends java.lang.Object implements CommitLogObserver
A @{link LogObserver} that delegates calls to underlying delegate. Useful for overriding specific methods before passing to delegate.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface cz.o2.proxima.direct.core.commitlog.CommitLogObserver
CommitLogObserver.OffsetCommitter, CommitLogObserver.OnIdleContext, CommitLogObserver.OnNextContext, CommitLogObserver.OnRepartitionContext
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedForwardingObserver(CommitLogObserver delegate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidonCancelled()Notify that the processing has been canceled.voidonCompleted()Notify that the processing has gracefully ended.booleanonError(java.lang.Throwable error)Called to notify there was anerrorin the commit reader.booleanonException(java.lang.Exception exception)Called to notify there was anexceptionin the commit reader.booleanonFatalError(java.lang.Error error)Called to notify there was anerrorin the commit reader.voidonIdle(CommitLogObserver.OnIdleContext context)Called when the observer is idle.booleanonNext(StreamElement element, CommitLogObserver.OnNextContext context)Process next record in the commit log.voidonRepartition(CommitLogObserver.OnRepartitionContext context)Callback to notify of automatic repartitioning.
-
-
-
Constructor Detail
-
ForwardingObserver
protected ForwardingObserver(CommitLogObserver delegate)
-
-
Method Detail
-
onRepartition
public void onRepartition(CommitLogObserver.OnRepartitionContext context)
Description copied from interface:CommitLogObserverCallback to notify of automatic repartitioning. This method is always called first before anyLogObserver.onNext(cz.o2.proxima.core.storage.StreamElement, ContextT)call happens.- Specified by:
onRepartitionin interfaceCommitLogObserver- Parameters:
context- context of the repartition
-
onIdle
public void onIdle(CommitLogObserver.OnIdleContext context)
Description copied from interface:CommitLogObserverCalled when the observer is idle. Note that the definition of idle is commit-log dependent and it even might NOT be called at all, if the commit log guarantees that as long as there are *any* data flowing in, thenLogObserver.onNext(cz.o2.proxima.core.storage.StreamElement, ContextT)will be called eventually.Typical example of commit log with no need to call
CommitLogObserver.onIdle(cz.o2.proxima.direct.core.commitlog.CommitLogObserver.OnIdleContext)is google PubSub, having virtually single shared partition which loads balances incoming data.- Specified by:
onIdlein interfaceCommitLogObserver- Parameters:
context- the context for on idle processing
-
onCompleted
public void onCompleted()
Description copied from interface:LogObserverNotify that the processing has gracefully ended.- Specified by:
onCompletedin interfaceLogObserver<Offset,CommitLogObserver.OnNextContext>
-
onCancelled
public void onCancelled()
Description copied from interface:LogObserverNotify that the processing has been canceled.- Specified by:
onCancelledin interfaceLogObserver<Offset,CommitLogObserver.OnNextContext>
-
onError
public boolean onError(java.lang.Throwable error)
Description copied from interface:LogObserverCalled to notify there was anerrorin the commit reader.- Specified by:
onErrorin interfaceLogObserver<Offset,CommitLogObserver.OnNextContext>- Parameters:
error- error caught during processing- Returns:
trueto restart processing from last committed position,falseto stop processing
-
onException
public boolean onException(java.lang.Exception exception)
Description copied from interface:LogObserverCalled to notify there was anexceptionin the commit reader. There is no guarantee this method gets called, ifLogObserver.onError(Throwable)is overridden.- Specified by:
onExceptionin interfaceLogObserver<Offset,CommitLogObserver.OnNextContext>- Parameters:
exception- exception caught during processing- Returns:
trueto restart processing from last committed position,falseto stop processing
-
onFatalError
public boolean onFatalError(java.lang.Error error)
Description copied from interface:LogObserverCalled to notify there was anerrorin the commit reader. There is no guarantee this method gets called, ifLogObserver.onError(Throwable)is overridden.- Specified by:
onFatalErrorin interfaceLogObserver<Offset,CommitLogObserver.OnNextContext>- Parameters:
error- error caught during processing- Returns:
trueto restart processing from last committed position,falseto stop processing
-
onNext
public boolean onNext(StreamElement element, CommitLogObserver.OnNextContext context)
Description copied from interface:LogObserverProcess next record in the commit log.- Specified by:
onNextin interfaceLogObserver<Offset,CommitLogObserver.OnNextContext>- Parameters:
element- the element written to the commit logcontext- a context that the application must use to confirm processing of the element. If the application fails to do so, the result is undefined.- Returns:
trueif the processing should continue,falseotherwise
-
-