64d79cb637ce51e4d4b208fc20527e93c8c28593
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / DOMBrokerReadOnlyTransaction.java
1 /*
2  * Copyright (c) 2015 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
9 package org.opendaylight.controller.cluster.databroker;
10
11 import com.google.common.base.Optional;
12 import com.google.common.util.concurrent.CheckedFuture;
13 import java.util.Map;
14 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
15 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
16 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
17 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
18 import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionFactory;
19 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
20 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
21
22 public class DOMBrokerReadOnlyTransaction
23     extends AbstractDOMBrokerTransaction<DOMStoreReadTransaction>
24         implements DOMDataReadOnlyTransaction {
25     /**
26      * Creates new composite Transactions.
27      *
28      * @param identifier Identifier of transaction.
29      */
30     protected DOMBrokerReadOnlyTransaction(Object identifier, Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory> storeTxFactories) {
31         super(identifier, storeTxFactories);
32     }
33
34     @Override
35     public CheckedFuture<Optional<NormalizedNode<?,?>>, ReadFailedException> read(
36             final LogicalDatastoreType store, final YangInstanceIdentifier path) {
37         return getSubtransaction(store).read(path);
38     }
39
40     @Override
41     public CheckedFuture<Boolean, ReadFailedException> exists(
42             final LogicalDatastoreType store,
43             final YangInstanceIdentifier path) {
44         return getSubtransaction(store).exists(path);
45     }
46
47     @Override
48     public void close() {
49         closeSubtransactions();
50     }
51
52     @Override
53     protected DOMStoreReadTransaction createTransaction(LogicalDatastoreType key) {
54         return getTxFactory(key).newReadOnlyTransaction();
55     }
56
57
58 }

©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.