Class AbstractAsyncDataTreeChangeListener<T extends org.opendaylight.yangtools.yang.binding.DataObject>
- java.lang.Object
-
- org.opendaylight.serviceutils.tools.mdsal.listener.AbstractAsyncDataTreeChangeListener<T>
-
- Type Parameters:
T
- type of the data object the listener is registered to.
- All Implemented Interfaces:
AutoCloseable
,EventListener
,org.opendaylight.mdsal.binding.api.DataTreeChangeListener<T>
,ChainableDataTreeChangeListener<T>
@Deprecated public abstract class AbstractAsyncDataTreeChangeListener<T extends org.opendaylight.yangtools.yang.binding.DataObject> extends Object
Deprecated.Uselistener-api
instead.Abstract class providing some common functionality to specific listeners. This listener launches the received notifications by using anExecutorService
.The
ExecutorService
passed to the constructor will depend on the use case. Here we have some examples:- If the listener is fast enough and non-blocking: MoreExecutors.directExecutor might be used, or even better, just use the
AbstractSyncDataTreeChangeListener
.- If the listener is heavy or could be blocked: use a multi-threaded executor. We recommend using one of the factory methods in
SpecialExecutors
. You could and probably should share such an Executor among several listeners in your project.- If the listener needs to preserve the order of notifications, then (only) use a single thread executor typically an
org.opendaylight.infrautils.utils.concurrent.Executors#newSingleThreadExecutor(String, org.slf4j.Logger)
.- If there are multiple listeners: they could even share an Executor as the ones in
SpecialExecutors
,Subclasses are also encouraged to, in addition to passing the ExecutorService for use in production (by Blueprint wiring) based on above via super(), expose a public constructor letting tests specify an alternative ExecutorService; this is useful e.g. to inject infrautils' AwaitableExecutorService for testing.
- Author:
- David Suárez (david.suarez.fuentes@gmail.com)
-
-
Constructor Summary
Constructors Constructor Description AbstractAsyncDataTreeChangeListener(org.opendaylight.mdsal.binding.api.DataBroker dataBroker, org.opendaylight.mdsal.binding.api.DataTreeIdentifier<T> dataTreeIdentifier, ExecutorService executorService)
Deprecated.AbstractAsyncDataTreeChangeListener(org.opendaylight.mdsal.binding.api.DataBroker dataBroker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> instanceIdentifier, ExecutorService executorService)
Deprecated.AbstractAsyncDataTreeChangeListener(org.opendaylight.mdsal.binding.api.DataBroker dataBroker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> instanceIdentifier, ExecutorService executorService, MetricProvider metricProvider)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Default Methods Deprecated Methods Modifier and Type Method Description default void
add(@NonNull org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> instanceIdentifier, @NonNull T newDataObject)
Deprecated.Invoked when a new data object is added.void
add(T newDataObject)
Deprecated.void
addAfterListener(org.opendaylight.mdsal.binding.api.DataTreeChangeListener<T> listener)
Adds a "chained" DataTreeChangeListener, to whichDataTreeChangeListener.onDataTreeChanged(java.util.Collection)
calls are forwarded AFTER having been processed by this DataTreeChangeListener.void
addBeforeListener(org.opendaylight.mdsal.binding.api.DataTreeChangeListener<T> listener)
Adds a "chained" DataTreeChangeListener, to whichDataTreeChangeListener.onDataTreeChanged(java.util.Collection)
calls are forwarded BEFORE having been processed by this DataTreeChangeListener.void
close()
protected org.opendaylight.mdsal.binding.api.DataBroker
getDataBroker()
protected org.opendaylight.serviceutils.tools.mdsal.listener.DataStoreMetrics
getDataStoreMetrics()
protected ExecutorService
getExecutorService()
Deprecated.Returns the ExecutorService provided when constructing this instance.default void
onDataTreeChanged(@NonNull Collection<org.opendaylight.mdsal.binding.api.DataTreeModification<T>> changes, org.opendaylight.serviceutils.tools.mdsal.listener.DataStoreMetrics dataStoreMetrics)
Deprecated.Default method invoked upon data tree change, in turn it calls the appropriate method (add, update, remove) depending on the type of change.void
onDataTreeChanged(Collection<org.opendaylight.mdsal.binding.api.DataTreeModification<T>> collection)
Deprecated.void
register()
default void
remove(@NonNull org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> instanceIdentifier, @NonNull T removedDataObject)
Deprecated.Invoked when the data object has been removed.void
remove(T removedDataObject)
Deprecated.default void
update(@NonNull org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> instanceIdentifier, @NonNull T originalDataObject, @NonNull T updatedDataObject)
Deprecated.Invoked when there is a change in the data object.void
update(T originalDataObject, T updatedDataObject)
Deprecated.
-
-
-
Constructor Detail
-
AbstractAsyncDataTreeChangeListener
public AbstractAsyncDataTreeChangeListener(org.opendaylight.mdsal.binding.api.DataBroker dataBroker, org.opendaylight.mdsal.binding.api.DataTreeIdentifier<T> dataTreeIdentifier, ExecutorService executorService)
Deprecated.
-
AbstractAsyncDataTreeChangeListener
public AbstractAsyncDataTreeChangeListener(org.opendaylight.mdsal.binding.api.DataBroker dataBroker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> instanceIdentifier, ExecutorService executorService)
Deprecated.
-
AbstractAsyncDataTreeChangeListener
public AbstractAsyncDataTreeChangeListener(org.opendaylight.mdsal.binding.api.DataBroker dataBroker, org.opendaylight.mdsal.common.api.LogicalDatastoreType datastoreType, org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> instanceIdentifier, ExecutorService executorService, MetricProvider metricProvider)
Deprecated.
-
-
Method Detail
-
onDataTreeChanged
public final void onDataTreeChanged(Collection<org.opendaylight.mdsal.binding.api.DataTreeModification<T>> collection)
Deprecated.
-
getExecutorService
protected ExecutorService getExecutorService()
Deprecated.Returns the ExecutorService provided when constructing this instance. If the subclass owns the ExecutorService, it should be shut down when closing the listener using this getter.- Returns:
- executor service
-
addBeforeListener
public void addBeforeListener(org.opendaylight.mdsal.binding.api.DataTreeChangeListener<T> listener)
Description copied from interface:ChainableDataTreeChangeListener
Adds a "chained" DataTreeChangeListener, to whichDataTreeChangeListener.onDataTreeChanged(java.util.Collection)
calls are forwarded BEFORE having been processed by this DataTreeChangeListener.If an asychronous DataTreeChangeListener supports chaining, it must forward the onDataTreeChanged() call BEFORE event are submitted to its async executor for processing.
- Specified by:
addBeforeListener
in interfaceChainableDataTreeChangeListener<T extends org.opendaylight.yangtools.yang.binding.DataObject>
- Parameters:
listener
- the chained DataTreeChangeListener to invoke after this one
-
addAfterListener
public void addAfterListener(org.opendaylight.mdsal.binding.api.DataTreeChangeListener<T> listener)
Description copied from interface:ChainableDataTreeChangeListener
Adds a "chained" DataTreeChangeListener, to whichDataTreeChangeListener.onDataTreeChanged(java.util.Collection)
calls are forwarded AFTER having been processed by this DataTreeChangeListener.If an asychronous DataTreeChangeListener supports chaining, it must forward the onDataTreeChanged() call ONLY AFTER its async executor processed the event.
- Specified by:
addAfterListener
in interfaceChainableDataTreeChangeListener<T extends org.opendaylight.yangtools.yang.binding.DataObject>
- Parameters:
listener
- the chained DataTreeChangeListener to invoke after this one
-
register
@PostConstruct public void register()
-
getDataBroker
protected org.opendaylight.mdsal.binding.api.DataBroker getDataBroker()
-
getDataStoreMetrics
protected org.opendaylight.serviceutils.tools.mdsal.listener.DataStoreMetrics getDataStoreMetrics()
-
close
@PreDestroy public void close()
- Specified by:
close
in interfaceAutoCloseable
-
add
@Deprecated public void add(T newDataObject)
Deprecated.
-
remove
@Deprecated public void remove(T removedDataObject)
Deprecated.
-
update
@Deprecated public void update(T originalDataObject, T updatedDataObject)
Deprecated.
-
onDataTreeChanged
public default void onDataTreeChanged(@NonNull Collection<org.opendaylight.mdsal.binding.api.DataTreeModification<T>> changes, org.opendaylight.serviceutils.tools.mdsal.listener.DataStoreMetrics dataStoreMetrics)
Deprecated.Default method invoked upon data tree change, in turn it calls the appropriate method (add, update, remove) depending on the type of change.- Parameters:
changes
- collection of changesdataStoreMetrics
- data store metrics
-
add
public default void add(@NonNull org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> instanceIdentifier, @NonNull T newDataObject)
Deprecated.Invoked when a new data object is added.- Parameters:
instanceIdentifier
- instance id for this data objectnewDataObject
- newly added object
-
remove
public default void remove(@NonNull org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> instanceIdentifier, @NonNull T removedDataObject)
Deprecated.Invoked when the data object has been removed.- Parameters:
instanceIdentifier
- instance id for this data objectremovedDataObject
- existing object being removed
-
update
public default void update(@NonNull org.opendaylight.yangtools.yang.binding.InstanceIdentifier<T> instanceIdentifier, @NonNull T originalDataObject, @NonNull T updatedDataObject)
Deprecated.Invoked when there is a change in the data object.- Parameters:
instanceIdentifier
- instance id for this data objectoriginalDataObject
- existing object being modifiedupdatedDataObject
- modified data object
-
-