import akka.actor.ActorSystem;
import akka.dispatch.OnComplete;
import akka.pattern.Patterns;
+import akka.util.Timeout;
import com.google.common.base.Optional;
import com.google.common.base.Throwables;
import org.opendaylight.controller.config.util.xml.DocumentedException;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.singleton.api.NetconfDOMTransaction;
-import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologyUtils;
import org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage;
import org.opendaylight.netconf.topology.singleton.messages.transactions.CancelRequest;
import org.opendaylight.netconf.topology.singleton.messages.transactions.DeleteRequest;
private final RemoteDeviceId id;
private final ActorSystem actorSystem;
private final ActorRef masterContextRef;
+ private final Timeout actorResponseWaitTime;
public NetconfProxyDOMTransaction(final RemoteDeviceId id,
final ActorSystem actorSystem,
- final ActorRef masterContextRef) {
+ final ActorRef masterContextRef,
+ final Timeout actorResponseWaitTime) {
this.id = id;
this.actorSystem = actorSystem;
this.masterContextRef = masterContextRef;
+ this.actorResponseWaitTime = actorResponseWaitTime;
}
@Override
// node.
LOG.debug("{}: Requesting leader {} to open new transaction", id, masterContextRef);
final Future<Object> openTxFuture =
- Patterns.ask(masterContextRef, new OpenTransaction(), NetconfTopologyUtils.TIMEOUT);
+ Patterns.ask(masterContextRef, new OpenTransaction(), actorResponseWaitTime);
try {
// we have to wait here so we can see if tx can be opened
- Await.result(openTxFuture, NetconfTopologyUtils.TIMEOUT.duration());
+ Await.result(openTxFuture, actorResponseWaitTime.duration());
LOG.debug("{}: New transaction opened successfully", id);
} catch (final Exception e) {
LOG.error("{}: Failed to open new transaction", id, e);
final YangInstanceIdentifier path) {
final Future<Object> readScalaFuture =
- Patterns.ask(masterContextRef, new ReadRequest(store, path), NetconfTopologyUtils.TIMEOUT);
+ Patterns.ask(masterContextRef, new ReadRequest(store, path), actorResponseWaitTime);
LOG.trace("{}: Read {} via NETCONF: {}", id, store, path);
@Override
public Future<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
final Future<Object> existsScalaFuture =
- Patterns.ask(masterContextRef, new ExistsRequest(store, path), NetconfTopologyUtils.TIMEOUT);
+ Patterns.ask(masterContextRef, new ExistsRequest(store, path), actorResponseWaitTime);
LOG.trace("{}: Exists {} via NETCONF: {}", id, store, path);
@Override
public boolean cancel() {
final Future<Object> cancelScalaFuture =
- Patterns.ask(masterContextRef, new CancelRequest(), NetconfTopologyUtils.TIMEOUT);
+ Patterns.ask(masterContextRef, new CancelRequest(), actorResponseWaitTime);
LOG.trace("{}: Cancel {} via NETCONF", id);
try {
// here must be Await because AsyncWriteTransaction do not return future
- return (boolean) Await.result(cancelScalaFuture, NetconfTopologyUtils.TIMEOUT.duration());
+ return (boolean) Await.result(cancelScalaFuture, actorResponseWaitTime.duration());
} catch (Exception e) {
return false;
}
@Override
public Future<Void> submit() {
final Future<Object> submitScalaFuture =
- Patterns.ask(masterContextRef, new SubmitRequest(), NetconfTopologyUtils.TIMEOUT);
+ Patterns.ask(masterContextRef, new SubmitRequest(), actorResponseWaitTime);
LOG.trace("{}: Submit {} via NETCONF", id);