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.mdsal.dom.broker;
10 import com.google.common.base.Preconditions;
11 import com.google.common.util.concurrent.ListenableFuture;
12 import com.google.common.util.concurrent.SettableFuture;
13 import com.lmax.disruptor.EventFactory;
14 import java.util.Collection;
15 import org.opendaylight.mdsal.dom.api.DOMNotification;
16 import org.opendaylight.mdsal.dom.api.DOMNotificationListener;
17 import org.opendaylight.yangtools.concepts.ListenerRegistration;
20 * A single notification event in the disruptor ringbuffer. These objects are reused,
21 * so they do have mutable state.
23 final class DOMNotificationRouterEvent {
24 static final EventFactory<DOMNotificationRouterEvent> FACTORY = DOMNotificationRouterEvent::new;
26 private Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers;
27 private DOMNotification notification;
28 private SettableFuture<Void> future;
30 private DOMNotificationRouterEvent() {
31 // Hidden on purpose, initialized in initialize()
34 @SuppressWarnings("checkstyle:hiddenField")
35 ListenableFuture<Void> initialize(final DOMNotification notification,
36 final Collection<ListenerRegistration<? extends DOMNotificationListener>> subscribers) {
37 this.notification = Preconditions.checkNotNull(notification);
38 this.subscribers = Preconditions.checkNotNull(subscribers);
39 this.future = SettableFuture.create();
43 void deliverNotification() {
44 for (ListenerRegistration<? extends DOMNotificationListener> r : subscribers) {
45 final DOMNotificationListener l = r.getInstance();
47 l.onNotification(notification);