Class QueuedNotificationManager<L,N>
java.lang.Object
org.opendaylight.yangtools.concepts.AbstractIdentifiable<String,String>
org.opendaylight.yangtools.concepts.AbstractSimpleIdentifiable<String>
org.opendaylight.yangtools.util.concurrent.IdentityQueuedNotificationManager<L,N>
org.opendaylight.yangtools.util.concurrent.QueuedNotificationManager<L,N>
- All Implemented Interfaces:
Identifiable<String>
,NotificationManager<L,
N>
This class is pessimistic about listener type and uses identity mapping for comparing them. This is defensive versus
reused objects, maintaining semantics. This may not always be intended, for example if L
is a String
which is being dynamically determined. In that case we do not want to use identity, but equality, as otherwise
the caller is forced to use String.intern()
-- leading to interning in lookup, which is absolutely
unnecessary. In such use cases, use EqualityQueuedNotificationManager
instead.
- Author:
- Thomas Pantelis
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic <L,
N> QueuedNotificationManager <L, N> create
(@NonNull Executor executor, @NonNull QueuedNotificationManager.BatchedInvoker<L, N> listenerInvoker, int maxQueueCapacity, @NonNull String name) Create a new notification manager.final Executor
Returns theExecutor
to used for notification tasks.final int
Returns the maximum listener queue capacity.Return anQueuedNotificationManagerMXBean
tied to this instance.final void
submitNotification
(L listener, N notification) Submits a notification to be queued and dispatched to the given listener.final void
submitNotifications
(L listener, @Nullable Iterable<N> notifications) Submits notifications to be queued and dispatched to the given listener.Methods inherited from class org.opendaylight.yangtools.concepts.AbstractIdentifiable
addToStringAttributes, getIdentifier, toString
-
Method Details
-
create
public static <L,N> QueuedNotificationManager<L,N> create(@NonNull Executor executor, @NonNull QueuedNotificationManager.BatchedInvoker<L, N> listenerInvoker, int maxQueueCapacity, @NonNull String name) Create a new notification manager.- Parameters:
executor
- theExecutor
to use for notification taskslistenerInvoker
- theQueuedNotificationManager.BatchedInvoker
to use for invoking listenersmaxQueueCapacity
- the capacity of each listener queuename
- the name of this instance for logging info
-
getExecutor
Returns theExecutor
to used for notification tasks. -
getMaxQueueCapacity
public final int getMaxQueueCapacity()Returns the maximum listener queue capacity. -
getMXBean
Return anQueuedNotificationManagerMXBean
tied to this instance.- Returns:
- An QueuedNotificationManagerMXBean object.
-
submitNotification
Description copied from interface:NotificationManager
Submits a notification to be queued and dispatched to the given listener.Note: This method may block if the listener queue is currently full.
- Specified by:
submitNotification
in interfaceNotificationManager<T,
L> - Parameters:
listener
- the listener to notifynotification
- the notification to dispatch
-
submitNotifications
Description copied from interface:NotificationManager
Submits notifications to be queued and dispatched to the given listener.Note: This method may block if the listener queue is currently full.
- Specified by:
submitNotifications
in interfaceNotificationManager<T,
L> - Parameters:
listener
- the listener to notifynotifications
- the notifications to dispatch
-