X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=dom%2Fmdsal-dom-broker%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fmdsal%2Fdom%2Fbroker%2FDOMNotificationRouterEvent.java;h=83fe2e75d20dc8ac4076a51948de1ca6b7a1262c;hb=90b0687e0640ee23369d2ad9978628e3ff957a26;hp=ea79cae321a0842cee33c14410fd09778876598f;hpb=67d0d71b7218015f5eaf311d732a0db1dd079021;p=mdsal.git diff --git a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java index ea79cae321..83fe2e75d2 100644 --- a/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java +++ b/dom/mdsal-dom-broker/src/main/java/org/opendaylight/mdsal/dom/broker/DOMNotificationRouterEvent.java @@ -7,50 +7,46 @@ */ package org.opendaylight.mdsal.dom.broker; -import com.google.common.base.Preconditions; +import static java.util.Objects.requireNonNull; + import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.SettableFuture; -import com.lmax.disruptor.EventFactory; -import java.util.Collection; +import org.eclipse.jdt.annotation.NonNull; import org.opendaylight.mdsal.dom.api.DOMNotification; import org.opendaylight.mdsal.dom.api.DOMNotificationListener; -import org.opendaylight.yangtools.concepts.ListenerRegistration; +import org.opendaylight.yangtools.yang.common.Empty; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** - * A single notification event in the disruptor ringbuffer. These objects are reused, - * so they do have mutable state. + * A single notification event in the notification router. */ final class DOMNotificationRouterEvent { - static final EventFactory FACTORY = DOMNotificationRouterEvent::new; + private static final Logger LOG = LoggerFactory.getLogger(DOMNotificationRouterEvent.class); - private Collection> subscribers; - private DOMNotification notification; - private SettableFuture future; + private final SettableFuture future = SettableFuture.create(); + private final @NonNull DOMNotification notification; - private DOMNotificationRouterEvent() { - // Hidden on purpose, initialized in initialize() + DOMNotificationRouterEvent(final DOMNotification notification) { + this.notification = requireNonNull(notification); } - @SuppressWarnings("checkstyle:hiddenField") - ListenableFuture initialize(final DOMNotification notification, - final Collection> subscribers) { - this.notification = Preconditions.checkNotNull(notification); - this.subscribers = Preconditions.checkNotNull(subscribers); - this.future = SettableFuture.create(); - return this.future; + ListenableFuture future() { + return future; } - void deliverNotification() { - for (ListenerRegistration r : subscribers) { - final DOMNotificationListener l = r.getInstance(); - if (l != null) { - l.onNotification(notification); - } + @SuppressWarnings("checkstyle:illegalCatch") + void deliverTo(final DOMNotificationListener listener) { + try { + listener.onNotification(notification); + } catch (Exception e) { + LOG.warn("Listener {} failed during notification delivery", listener, e); + } finally { + clear(); } } - void setFuture() { - future.set(null); + void clear() { + future.set(Empty.value()); } - -} \ No newline at end of file +}