2 * Copyright (c) 2015 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.api;
10 import java.util.Collection;
11 import javax.annotation.Nonnull;
12 import org.opendaylight.yangtools.concepts.ListenerRegistration;
15 * A {@link DOMService} providing access to the conceptual data tree. Interactions
16 * with the data tree are split into data producers and consumers (listeners). Each
17 * of them operate on a set of subtrees, which need to be declared at instantiation time.
19 * Returned instances are not thread-safe and expected to be used by a single thread
20 * at a time. Furthermore, producers may not be accessed from consumer callbacks
21 * unless they were specified when the listener is registered.
23 * The service maintains a loop-free topology of producers and consumers. What this means
24 * is that a consumer is not allowed to access a producer, which affects any of the
25 * subtrees it is subscribed to. This restriction is in place to ensure the system does
26 * not go into a feedback loop, where it is impossible to block either a producer or
27 * a consumer without accumulating excess work in the backlog stemming from its previous
30 * @deprecated Use {@link org.opendaylight.mdsal.dom.api.DOMDataTreeService} instead.
33 public interface DOMDataTreeService extends DOMDataTreeProducerFactory, DOMService {
35 * Register a {@link DOMDataTreeListener} instance. Once registered, the listener
36 * will start receiving changes on the selected subtrees. If the listener cannot
37 * keep up with the rate of changes, and allowRxMerges is set to true, this service
38 * is free to merge the changes, so that a smaller number of them will be reported,
39 * possibly hiding some data transitions (like flaps).
41 * If the listener wants to write into any producer, that producer has to be mentioned
42 * in the call to this method. Those producers will be bound exclusively to the
43 * registration, so that accessing them outside of this listener's callback will trigger
44 * an error. Any producers mentioned must be idle, e.g. they may not have an open
45 * transaction at the time this method is invoked.
47 * Each listener instance can be registered at most once. Implementations of this
48 * interface have to guarantee that the listener's methods will not be invoked
49 * concurrently from multiple threads.
51 * @param listener {@link DOMDataTreeListener} that is being registered
52 * @param subtrees Conceptual subtree identifier of subtrees which should be monitored
53 * for changes. May not be null or empty.
54 * @param allowRxMerges True if the backend may perform ingress state compression.
55 * @param producers {@link DOMDataTreeProducer} instances to bind to the listener.
56 * @return A listener registration. Once closed, the listener will no longer be
57 * invoked and the producers will be unbound.
58 * @throws IllegalArgumentException if subtrees is empty or the listener is already bound
59 * @throws DOMDataTreeLoopException if the registration of the listener to the specified
60 * subtrees with specified producers would form a
63 @Nonnull <T extends DOMDataTreeListener> ListenerRegistration<T> registerListener(@Nonnull T listener,
64 @Nonnull Collection<DOMDataTreeIdentifier> subtrees, boolean allowRxMerges, @Nonnull Collection<DOMDataTreeProducer> producers) throws DOMDataTreeLoopException;