package org.opendaylight.controller.md.sal.dom.broker.impl;
import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
private static final Logger LOG = LoggerFactory.getLogger(DOMNotificationRouter.class);
private static final ListenableFuture<Void> NO_LISTENERS = Futures.immediateFuture(null);
private static final WaitStrategy DEFAULT_STRATEGY = PhasedBackoffWaitStrategy.withLock(1L, 30L, TimeUnit.MILLISECONDS);
- private static final EventHandler<DOMNotificationRouterEvent> DISPATCH_NOTIFICATIONS = new EventHandler<DOMNotificationRouterEvent>() {
- @Override
- public void onEvent(final DOMNotificationRouterEvent event, final long sequence, final boolean endOfBatch) throws Exception {
- event.deliverNotification();
-
- }
- };
- private static final EventHandler<DOMNotificationRouterEvent> NOTIFY_FUTURE = new EventHandler<DOMNotificationRouterEvent>() {
- @Override
- public void onEvent(final DOMNotificationRouterEvent event, final long sequence, final boolean endOfBatch) {
- event.setFuture();
- }
- };
+ private static final EventHandler<DOMNotificationRouterEvent> DISPATCH_NOTIFICATIONS =
+ (event, sequence, endOfBatch) -> event.deliverNotification();
+ private static final EventHandler<DOMNotificationRouterEvent> NOTIFY_FUTURE =
+ (event, sequence, endOfBatch) -> event.setFuture();
private final Disruptor<DOMNotificationRouterEvent> disruptor;
private final ExecutorService executor;
final ListenerRegistration<T> me = this;
synchronized (DOMNotificationRouter.this) {
- replaceListeners(ImmutableMultimap.copyOf(Multimaps.filterValues(listeners, new Predicate<ListenerRegistration<? extends DOMNotificationListener>>() {
- @Override
- public boolean apply(final ListenerRegistration<? extends DOMNotificationListener> input) {
- return input != me;
- }
- })));
+ replaceListeners(ImmutableMultimap.copyOf(Multimaps.filterValues(listeners, input -> input != me)));
}
}
};
private void notifyListenerTypesChanged(final Set<SchemaPath> typesAfter) {
final List<ListenerRegistration<DOMNotificationSubscriptionListener>> listenersAfter =ImmutableList.copyOf(subscriptionListeners.getListeners());
- executor.submit(new Runnable() {
-
- @Override
- public void run() {
- for (final ListenerRegistration<DOMNotificationSubscriptionListener> subListener : listenersAfter) {
- try {
- subListener.getInstance().onSubscriptionChanged(typesAfter);
- } catch (final Exception e) {
- LOG.warn("Uncaught exception during invoking listener {}", subListener.getInstance(), e);
- }
+ executor.submit(() -> {
+ for (final ListenerRegistration<DOMNotificationSubscriptionListener> subListener : listenersAfter) {
+ try {
+ subListener.getInstance().onSubscriptionChanged(typesAfter);
+ } catch (final Exception e) {
+ LOG.warn("Uncaught exception during invoking listener {}", subListener.getInstance(), e);
}
}
});
public <L extends DOMNotificationSubscriptionListener> ListenerRegistration<L> registerSubscriptionListener(
final L listener) {
final Set<SchemaPath> initialTypes = listeners.keySet();
- executor.submit(new Runnable() {
-
- @Override
- public void run() {
- listener.onSubscriptionChanged(initialTypes);
- }
- });
+ executor.submit(() -> listener.onSubscriptionChanged(initialTypes));
return subscriptionListeners.registerWithType(listener);
}