32a0ad20caa1026764a9044ee68a3936ffbe4c0d
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / sal / dom / broker / DataBrokerImpl.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.sal.dom.broker;
9
10 import java.util.concurrent.atomic.AtomicLong;
11
12 import org.opendaylight.controller.md.sal.common.api.data.DataReader;
13 import org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker;
14 import org.opendaylight.controller.sal.common.DataStoreIdentifier;
15 import org.opendaylight.controller.sal.core.api.data.DataChangeListener;
16 import org.opendaylight.controller.sal.core.api.data.DataProviderService;
17 import org.opendaylight.controller.sal.core.api.data.DataValidator;
18 import org.opendaylight.controller.sal.dom.broker.impl.DataReaderRouter;
19 import org.opendaylight.yangtools.concepts.Registration;
20 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
21 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
22
23 import com.google.common.util.concurrent.MoreExecutors;
24
25 public class DataBrokerImpl extends AbstractDataBroker<InstanceIdentifier, CompositeNode, DataChangeListener> implements
26         DataProviderService, AutoCloseable {
27
28     private AtomicLong nextTransaction = new AtomicLong();
29     private final AtomicLong createdTransactionsCount = new AtomicLong();
30
31     public DataBrokerImpl() {
32         setDataReadRouter(new DataReaderRouter());
33         setExecutor(MoreExecutors.sameThreadExecutor());
34     }
35
36     public AtomicLong getCreatedTransactionsCount() {
37         return createdTransactionsCount;
38     }
39
40     @Override
41     public DataTransactionImpl beginTransaction() {
42         String transactionId = "DOM-" + nextTransaction.getAndIncrement();
43         createdTransactionsCount.getAndIncrement();
44         return new DataTransactionImpl(transactionId,this);
45     }
46
47     @Override
48     public Registration registerConfigurationReader(
49             InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader) {
50         return getDataReadRouter().registerConfigurationReader(path, reader);
51     }
52
53     @Override
54     public Registration registerOperationalReader(
55             InstanceIdentifier path, DataReader<InstanceIdentifier, CompositeNode> reader) {
56         return getDataReadRouter().registerOperationalReader(path, reader);
57     }
58
59     @Deprecated
60     @Override
61     public void addValidator(DataStoreIdentifier store, DataValidator validator) {
62         throw new UnsupportedOperationException("Deprecated");
63
64     }
65
66     @Deprecated
67     @Override
68     public void removeValidator(DataStoreIdentifier store, DataValidator validator) {
69         throw new UnsupportedOperationException("Deprecated");
70     }
71
72     @Deprecated
73     @Override
74     public void addRefresher(DataStoreIdentifier store, DataRefresher refresher) {
75         throw new UnsupportedOperationException("Deprecated");
76     }
77
78     @Deprecated
79     @Override
80     public void removeRefresher(DataStoreIdentifier store, DataRefresher refresher) {
81         throw new UnsupportedOperationException("Deprecated");
82     }
83
84     @Override
85     public void close() throws Exception {
86
87     }
88
89 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.