cadb61a4607417c7c422dddf0bfe12c82ad4d404
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / ShardedDOMStoreReadTransaction.java
1 /*
2  * Copyright (c) 2016 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.cluster.databroker;
9
10 import com.google.common.base.Optional;
11 import com.google.common.util.concurrent.CheckedFuture;
12 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
13 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
14 import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17
18 /**
19  * Proxy implementation of {@link DOMStoreReadTransaction}. It routes all requests to the backing
20  * {@link ClientTransaction}. This class is not final to allow further subclassing by
21  * {@link ShardedDOMStoreReadWriteTransaction}.
22  *
23  * @author Robert Varga
24  */
25 class ShardedDOMStoreReadTransaction extends AbstractShardedTransaction implements DOMStoreReadTransaction {
26     ShardedDOMStoreReadTransaction(final ClientTransaction tx) {
27         super(tx);
28     }
29
30     @Override
31     public final void close() {
32         transaction().abort();
33     }
34
35     @Override
36     public final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
37         return transaction().read(path);
38     }
39
40     @Override
41     public final CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
42         return transaction().exists(path);
43     }
44 }