2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.controller.md.sal.dom.broker.impl;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import com.google.common.util.concurrent.SettableFuture;
14 import com.lmax.disruptor.EventFactory;
15 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
16 import java.util.Collection;
17 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
18 import org.opendaylight.controller.md.sal.dom.api.DOMNotificationListener;
19 import org.opendaylight.yangtools.concepts.ListenerRegistration;
20 import org.slf4j.Logger;
21 import org.slf4j.LoggerFactory;
24 * A single notification event in the disruptor ringbuffer. These objects are reused,
25 * so they do have mutable state.
27 @Deprecated(forRemoval = true)
28 final class DOMNotificationRouterEvent {
29 private static final Logger LOG = LoggerFactory.getLogger(DOMNotificationRouterEvent.class);
30 public static final EventFactory<DOMNotificationRouterEvent> FACTORY = DOMNotificationRouterEvent::new;
32 private Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers;
33 private DOMNotification notification;
34 private SettableFuture<Void> future;
36 private DOMNotificationRouterEvent() {
37 // Hidden on purpose, initialized in initialize()
40 @SuppressWarnings("checkstyle:hiddenField")
41 ListenableFuture<Void> initialize(final DOMNotification notification,
42 final Collection<ListenerRegistration<? extends DOMNotificationListener>>
44 this.notification = requireNonNull(notification);
45 this.subscribers = requireNonNull(subscribers);
46 this.future = SettableFuture.create();
50 void deliverNotification() {
51 LOG.trace("Start delivery of notification {}", notification);
52 for (ListenerRegistration<? extends DOMNotificationListener> r : subscribers) {
53 final DOMNotificationListener listener = r.getInstance();
54 LOG.trace("Notifying listener {}", listener);
55 listener.onNotification(notification);
56 LOG.trace("Listener notification completed");
58 LOG.trace("Delivery completed");
61 @SuppressFBWarnings(value = "NP_NONNULL_PARAM_VIOLATION", justification = "Void is the only allowed value")