Fix checkstyle issues in module sal-dom-broker
[controller.git] / opendaylight / md-sal / sal-dom-broker / src / main / java / org / opendaylight / controller / md / sal / dom / broker / impl / legacy / sharded / adapter / ShardedDOMDataBrokerDelegatingReadTransaction.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
9 package org.opendaylight.controller.md.sal.dom.broker.impl.legacy.sharded.adapter;
10
11 import static com.google.common.base.Preconditions.checkNotNull;
12
13 import com.google.common.base.Optional;
14 import com.google.common.util.concurrent.CheckedFuture;
15 import com.google.common.util.concurrent.Futures;
16 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
17 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
18 import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
19 import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
21 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
22
23 /**
24  * Read transaction that delegates calls to {@link org.opendaylight.mdsal.dom.broker.ShardedDOMReadTransactionAdapter},
25  * which in turn translates calls to shard aware implementation of
26  * {@link org.opendaylight.mdsal.dom.api.DOMDataTreeService}.
27  *
28  * <p>
29  * Since reading data distributed on different subshards is not guaranteed to
30  * return all relevant data, we cannot guarantee it neither. Best effort is to
31  * return all data we get from first initial data change event received.
32  */
33 class ShardedDOMDataBrokerDelegatingReadTransaction implements DOMDataReadOnlyTransaction {
34     private final DOMDataTreeReadTransaction delegateTx;
35     private final Object txIdentifier;
36
37     ShardedDOMDataBrokerDelegatingReadTransaction(final Object txIdentifier,
38                                                          final DOMDataTreeReadTransaction delegateTx) {
39         this.delegateTx = checkNotNull(delegateTx);
40         this.txIdentifier = checkNotNull(txIdentifier);
41     }
42
43     @Override
44     public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
45                                                                                    final YangInstanceIdentifier path) {
46         return Futures.makeChecked(
47                 delegateTx.read(LegacyShardedDOMDataBrokerAdapterUtils.translateDataStoreType(store), path),
48                 ReadFailedException.MAPPER);
49     }
50
51     @Override
52     public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
53                                                               final YangInstanceIdentifier path) {
54         return Futures.makeChecked(
55                 delegateTx.exists(LegacyShardedDOMDataBrokerAdapterUtils.translateDataStoreType(store), path),
56                 ReadFailedException.MAPPER);
57     }
58
59     @Override
60     public Object getIdentifier() {
61         return txIdentifier;
62     }
63
64     @Override
65     public void close() {
66         delegateTx.close();
67     }
68 }

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