Class ThreadPooledObserver
- java.lang.Object
-
- cz.o2.proxima.direct.core.transaction.ThreadPooledObserver
-
- All Implemented Interfaces:
CommitLogObserver
,LogObserver<Offset,CommitLogObserver.OnNextContext>
@Internal public class ThreadPooledObserver extends java.lang.Object implements CommitLogObserver
-
-
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 Constructor Description ThreadPooledObserver(java.util.concurrent.ExecutorService executorService, CommitLogObserver requestObserver, int parallelism)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
onCancelled()
Notify that the processing has been canceled.void
onCompleted()
Notify that the processing has gracefully ended.boolean
onError(java.lang.Throwable error)
Called to notify there was anerror
in the commit reader.void
onIdle(CommitLogObserver.OnIdleContext context)
Called when the observer is idle.boolean
onNext(StreamElement element, CommitLogObserver.OnNextContext context)
Process next record in the commit log.void
onRepartition(CommitLogObserver.OnRepartitionContext context)
Callback to notify of automatic repartitioning.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cz.o2.proxima.direct.core.LogObserver
onException, onFatalError
-
-
-
-
Constructor Detail
-
ThreadPooledObserver
public ThreadPooledObserver(java.util.concurrent.ExecutorService executorService, CommitLogObserver requestObserver, int parallelism)
-
-
Method Detail
-
onCompleted
public void onCompleted()
Description copied from interface:LogObserver
Notify that the processing has gracefully ended.- Specified by:
onCompleted
in interfaceLogObserver<Offset,CommitLogObserver.OnNextContext>
-
onCancelled
public void onCancelled()
Description copied from interface:LogObserver
Notify that the processing has been canceled.- Specified by:
onCancelled
in interfaceLogObserver<Offset,CommitLogObserver.OnNextContext>
-
onError
public boolean onError(java.lang.Throwable error)
Description copied from interface:LogObserver
Called to notify there was anerror
in the commit reader.- Specified by:
onError
in interfaceLogObserver<Offset,CommitLogObserver.OnNextContext>
- Parameters:
error
- error caught during processing- Returns:
true
to restart processing from last committed position,false
to stop processing
-
onNext
public boolean onNext(StreamElement element, CommitLogObserver.OnNextContext context)
Description copied from interface:LogObserver
Process next record in the commit log.- Specified by:
onNext
in 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:
true
if the processing should continue,false
otherwise
-
onRepartition
public void onRepartition(CommitLogObserver.OnRepartitionContext context)
Description copied from interface:CommitLogObserver
Callback 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:
onRepartition
in interfaceCommitLogObserver
- Parameters:
context
- context of the repartition
-
onIdle
public void onIdle(CommitLogObserver.OnIdleContext context)
Description copied from interface:CommitLogObserver
Called 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:
onIdle
in interfaceCommitLogObserver
- Parameters:
context
- the context for on idle processing
-
-