b160d5b0764865ae99401e8390ac4ec9b70a0b21
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / DOMBrokerReadWriteTransaction.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.util.concurrent.FluentFuture;
12 import java.util.Map;
13 import java.util.Optional;
14 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
15 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
16 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
17 import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionFactory;
18 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
19 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
20
21 public class DOMBrokerReadWriteTransaction extends AbstractDOMBrokerWriteTransaction<DOMStoreReadWriteTransaction>
22         implements DOMDataTreeReadWriteTransaction {
23
24     /**
25      * Constructs an instance.
26      *
27      * @param identifier identifier of transaction.
28      * @param storeTxFactories the backing transaction store factories
29      */
30     protected DOMBrokerReadWriteTransaction(Object identifier,
31             Map<LogicalDatastoreType, ? extends DOMStoreTransactionFactory>  storeTxFactories,
32             final AbstractDOMTransactionFactory<?> commitImpl) {
33         super(identifier, storeTxFactories, commitImpl);
34     }
35
36     @Override
37     public FluentFuture<Optional<NormalizedNode<?,?>>> read(final LogicalDatastoreType store,
38             final YangInstanceIdentifier path) {
39         return getSubtransaction(store).read(path);
40     }
41
42     @Override
43     public FluentFuture<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
44         return getSubtransaction(store).exists(path);
45     }
46
47     @Override
48     protected DOMStoreReadWriteTransaction createTransaction(LogicalDatastoreType key) {
49         return getTxFactory(key).newReadWriteTransaction();
50     }
51
52     @Override
53     public void close() {
54         cancel();
55     }
56 }

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