Package org.apache.fluo.api.observer
Interface Observer
-
- All Known Subinterfaces:
StringObserver
- All Known Implementing Classes:
AbstractObserver
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Observer
Implemented by users to a watch aColumn
and be notified of changes to the Column via theprocess(TransactionBase, Bytes, Column)
method.In Fluo version 1.1.0 this was converted to a functional interface. This change along with the introduction of
ObserverProvider
allows Observers to be written as lambdas.- Since:
- 1.0.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
Observer.Context
Deprecated.since 1.1.0.static class
Observer.NotificationType
static class
Observer.ObservedColumn
Deprecated.since 1.1.0.
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default void
close()
Deprecated.since 1.1.0.default Observer.ObservedColumn
getObservedColumn()
Deprecated.since 1.1.0 Fluo will no longer call this method when observers are configured byFluoConfiguration.setObserverProvider(String)
.default void
init(Observer.Context context)
Deprecated.since 1.1.0.void
process(TransactionBase tx, Bytes row, Column col)
Implemented by users to process notifications on aObserver.ObservedColumn
.
-
-
-
Method Detail
-
init
@Deprecated default void init(Observer.Context context) throws Exception
Deprecated.since 1.1.0. Fluo will no longer call this method when observers are configured byFluoConfiguration.setObserverProvider(String)
. Its only called when observers are configured the old way byFluoConfiguration.addObserver(org.apache.fluo.api.config.ObserverSpecification)
Implemented by user to initialize Observer.- Parameters:
context
- Observer context- Throws:
Exception
-
process
void process(TransactionBase tx, Bytes row, Column col) throws Exception
Implemented by users to process notifications on aObserver.ObservedColumn
. If a notification occurs, this method passes the user aTransactionBase
as well as the row andColumn
where the notification occurred. The user can use theTransactionBase
to read and write to Fluo. After this method returns,TransactionBase
will be committed and closed by Fluo.- Throws:
Exception
-
getObservedColumn
@Deprecated default Observer.ObservedColumn getObservedColumn()
Deprecated.since 1.1.0 Fluo will no longer call this method when observers are configured byFluoConfiguration.setObserverProvider(String)
. Its only called when observers are configured the old way byFluoConfiguration.addObserver(org.apache.fluo.api.config.ObserverSpecification)
Implemented by user to return anObserver.ObservedColumn
that will trigger this observer. During initialization, this information is stored in zookeeper so that workers have a consistent view. If a worker loads an Observer and the information returned differs from what is in zookeeper then an exception will be thrown. It is safe to assume thatinit(Context)
will be called before this method. If the return value of the method is derived from what is passed toinit(Context)
, then the derivation process should be deterministic.
-
close
@Deprecated default void close()
Deprecated.since 1.1.0. Fluo will no longer call this method when observers are configured byFluoConfiguration.setObserverProvider(String)
. Its only called when observers are configured the old way byFluoConfiguration.addObserver(org.apache.fluo.api.config.ObserverSpecification)
Implemented by user to close resources used by Observer
-
-