0e673e7127f1bb27f9639960823d7c605199bb57
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / main / java / org / opendaylight / controller / cluster / databroker / ClientBackedReadWriteTransaction.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 com.google.common.util.concurrent.Futures;
13 import javax.annotation.Nullable;
14 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
15 import org.opendaylight.mdsal.common.api.ReadFailedException;
16 import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19
20 /**
21  * An implementation of {@link DOMStoreReadWriteTransaction} backed by a {@link ClientTransaction}.
22  *
23  * @author Robert Varga
24  */
25 final class ClientBackedReadWriteTransaction extends ClientBackedWriteTransaction
26         implements DOMStoreReadWriteTransaction {
27
28     ClientBackedReadWriteTransaction(final ClientTransaction delegate, @Nullable final Throwable allocationContext) {
29         super(delegate, allocationContext);
30     }
31
32     @Override
33     public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final YangInstanceIdentifier path) {
34         return Futures.makeChecked(delegate().read(path), ReadFailedException.MAPPER);
35     }
36
37     @Override
38     public CheckedFuture<Boolean, ReadFailedException> exists(final YangInstanceIdentifier path) {
39         return Futures.makeChecked(delegate().exists(path), ReadFailedException.MAPPER);
40     }
41 }