Merge "Bug 8084 - FilterContentValidator.getKeyValues creates invalid YII key values"
[netconf.git] / netconf / netconf-topology-singleton / src / main / java / org / opendaylight / netconf / topology / singleton / impl / tx / ProxyReadTransaction.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.netconf.topology.singleton.impl.tx;
10
11 import akka.actor.ActorRef;
12 import akka.actor.ActorSystem;
13 import akka.util.Timeout;
14 import com.google.common.base.Optional;
15 import com.google.common.util.concurrent.CheckedFuture;
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.netconf.sal.connect.util.RemoteDeviceId;
20 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
21 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
22
23 /**
24  * ProxyReadTransaction uses provided {@link ActorRef} to delegate method calls to master
25  * {@link org.opendaylight.netconf.topology.singleton.impl.actors.ReadTransactionActor}.
26  */
27 public class ProxyReadTransaction implements DOMDataReadOnlyTransaction {
28
29     private final ProxyReadAdapter delegate;
30
31     /**
32      * @param masterTxActor {@link org.opendaylight.netconf.topology.singleton.impl.actors.ReadTransactionActor} ref
33      * @param id            device id
34      * @param actorSystem   system
35      * @param askTimeout
36      */
37     public ProxyReadTransaction(final ActorRef masterTxActor, final RemoteDeviceId id, final ActorSystem actorSystem,
38                                 final Timeout askTimeout) {
39         delegate = new ProxyReadAdapter(masterTxActor, id, actorSystem, askTimeout);
40     }
41
42     @Override
43     public void close() {
44         delegate.close();
45     }
46
47     @Override
48     public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
49                                                                                    final YangInstanceIdentifier path) {
50         return delegate.read(store, path);
51     }
52
53     @Override
54     public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
55                                                               final YangInstanceIdentifier path) {
56         return delegate.exists(store, path);
57     }
58
59
60     @Override
61     public Object getIdentifier() {
62         return this;
63     }
64 }