@Override
public DOMDataReadOnlyTransaction newReadOnlyTransaction() {
- return new NetconfReadOnlyTransaction(actorSystem, masterDataBroker);
+ return new NetconfReadOnlyTransaction(id, actorSystem, masterDataBroker);
}
@Override
public DOMDataReadWriteTransaction newReadWriteTransaction() {
- return new ReadWriteTx(new NetconfReadOnlyTransaction(actorSystem, masterDataBroker),
- new NetconfWriteOnlyTransaction(actorSystem, masterDataBroker));
+ return new ReadWriteTx(new NetconfReadOnlyTransaction(id, actorSystem, masterDataBroker),
+ new NetconfWriteOnlyTransaction(id, actorSystem, masterDataBroker));
}
@Override
public DOMDataWriteTransaction newWriteOnlyTransaction() {
- return new NetconfWriteOnlyTransaction(actorSystem, masterDataBroker);
+ return new NetconfWriteOnlyTransaction(id, actorSystem, masterDataBroker);
}
@Override
final NetconfDeviceNotificationService notificationService = new NetconfDeviceNotificationService();
final NetconfDOMTransaction proxyDOMTransactions =
- new NetconfProxyDOMTransaction(actorSystem, masterActorRef);
+ new NetconfProxyDOMTransaction(id, actorSystem, masterActorRef);
final NetconfDOMDataBroker netconfDeviceDataBroker =
new NetconfDOMDataBroker(actorSystem, id, proxyDOMTransactions);
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import scala.concurrent.Future;
import scala.concurrent.impl.Promise.DefaultPromise;
public class NetconfMasterDOMTransaction implements NetconfDOMTransaction {
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfMasterDOMTransaction.class);
+
+ private final RemoteDeviceId id;
private final DOMDataBroker delegateBroker;
private DOMDataReadOnlyTransaction readTx;
private DOMDataWriteTransaction writeTx;
public NetconfMasterDOMTransaction(final RemoteDeviceId id,
- final SchemaContext schemaContext, final DOMRpcService rpc,
+ final SchemaContext schemaContext,
+ final DOMRpcService rpc,
final NetconfSessionPreferences netconfSessionPreferences) {
-
- delegateBroker = new NetconfDeviceDataBroker(id, schemaContext, rpc, netconfSessionPreferences);
-
- // only ever need 1 readTx since it doesnt need to be closed
- readTx = delegateBroker.newReadOnlyTransaction();
+ this(id, new NetconfDeviceDataBroker(id, schemaContext, rpc, netconfSessionPreferences));
}
- public NetconfMasterDOMTransaction(final DOMDataBroker delegateBroker) {
+ public NetconfMasterDOMTransaction(final RemoteDeviceId id, final DOMDataBroker delegateBroker) {
+ this.id = id;
this.delegateBroker = delegateBroker;
// only ever need 1 readTx since it doesnt need to be closed
@Override
public Future<Optional<NormalizedNodeMessage>> read(final LogicalDatastoreType store,
final YangInstanceIdentifier path) {
+ LOG.trace("{}: Read[{}] {} via NETCONF: {}", id, readTx.getIdentifier(), store, path);
+
final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> readFuture = readTx.read(store, path);
final DefaultPromise<Optional<NormalizedNodeMessage>> promise = new DefaultPromise<>();
@Override
public Future<Boolean> exists(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ LOG.trace("{}: Exists[{}] {} via NETCONF: {}", id, readTx.getIdentifier(), store, path);
+
final CheckedFuture<Boolean, ReadFailedException> existsFuture = readTx.exists(store, path);
final DefaultPromise<Boolean> promise = new DefaultPromise<>();
if (writeTx == null) {
writeTx = delegateBroker.newWriteOnlyTransaction();
}
+
+ LOG.trace("{}: Write[{}] {} via NETCONF: {} with payload {}", id, writeTx.getIdentifier(), store,
+ data.getIdentifier(), data.getNode());
+
writeTx.put(store, data.getIdentifier(), data.getNode());
}
if (writeTx == null) {
writeTx = delegateBroker.newWriteOnlyTransaction();
}
+
+ LOG.trace("{}: Merge[{}] {} via NETCONF: {} with payload {}", id, writeTx.getIdentifier(),store,
+ data.getIdentifier(), data.getNode());
+
writeTx.merge(store, data.getIdentifier(), data.getNode());
}
if (writeTx == null) {
writeTx = delegateBroker.newWriteOnlyTransaction();
}
+
+ LOG.trace("{}: Delete[{}} {} via NETCONF: {}", id, writeTx.getIdentifier(), store, path);
+
writeTx.delete(store, path);
}
@Override
public boolean cancel() {
+ LOG.trace("{}: Cancel[{}} via NETCONF", id, writeTx.getIdentifier());
+
return writeTx.cancel();
}
@Override
public Future<Void> submit() {
+ LOG.trace("{}: Submit[{}} via NETCONF", id, writeTx.getIdentifier());
+
final CheckedFuture<Void, TransactionCommitFailedException> submitFuture = writeTx.submit();
final DefaultPromise<Void> promise = new DefaultPromise<>();
Futures.addCallback(submitFuture, new FutureCallback<Void>() {
import akka.pattern.Patterns;
import com.google.common.base.Optional;
import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
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;
private static final Logger LOG = LoggerFactory.getLogger(NetconfProxyDOMTransaction.class);
+ private final RemoteDeviceId id;
private final ActorSystem actorSystem;
private final ActorRef masterContextRef;
- public NetconfProxyDOMTransaction(final ActorSystem actorSystem, final ActorRef masterContextRef) {
+ public NetconfProxyDOMTransaction(final RemoteDeviceId id,
+ final ActorSystem actorSystem,
+ final ActorRef masterContextRef) {
+ this.id = id;
this.actorSystem = actorSystem;
this.masterContextRef = masterContextRef;
}
final Future<Object> readScalaFuture =
Patterns.ask(masterContextRef, new ReadRequest(store, path), NetconfTopologyUtils.TIMEOUT);
+ LOG.trace("{}: Read {} via NETCONF: {}", id, store, path);
+
final DefaultPromise<Optional<NormalizedNodeMessage>> promise = new DefaultPromise<>();
readScalaFuture.onComplete(new OnComplete<Object>() {
@Override
public void onComplete(final Throwable failure, final Object success) throws Throwable {
if (failure != null) { // ask timeout
- Exception exception = new DocumentedException("Master is down. Please try again.",
- DocumentedException.ErrorType.application, DocumentedException.ErrorTag.operation_failed,
- DocumentedException.ErrorSeverity.warning);
+ Exception exception = new DocumentedException(id + ":Master is down. Please try again.",
+ ErrorType.application, ErrorTag.operation_failed,
+ ErrorSeverity.warning);
promise.failure(exception);
return;
}
final Future<Object> existsScalaFuture =
Patterns.ask(masterContextRef, new ExistsRequest(store, path), NetconfTopologyUtils.TIMEOUT);
+ LOG.trace("{}: Exists {} via NETCONF: {}", id, store, path);
+
final DefaultPromise<Boolean> promise = new DefaultPromise<>();
existsScalaFuture.onComplete(new OnComplete<Object>() {
@Override
public void onComplete(final Throwable failure, final Object success) throws Throwable {
if (failure != null) { // ask timeout
- Exception exception = new DocumentedException("Master is down. Please try again.",
- DocumentedException.ErrorType.application, DocumentedException.ErrorTag.operation_failed,
- DocumentedException.ErrorSeverity.warning);
+ Exception exception = new DocumentedException(id + ":Master is down. Please try again.",
+ ErrorType.application, ErrorTag.operation_failed,
+ ErrorSeverity.warning);
promise.failure(exception);
return;
}
@Override
public void put(final LogicalDatastoreType store, final NormalizedNodeMessage data) {
+ LOG.trace("{}: Write {} via NETCONF: {} with payload {}", id, store, data.getIdentifier(), data.getNode());
+
masterContextRef.tell(new PutRequest(store, data), ActorRef.noSender());
}
@Override
public void merge(final LogicalDatastoreType store, final NormalizedNodeMessage data) {
+ LOG.trace("{}: Merge {} via NETCONF: {} with payload {}", id, store, data.getIdentifier(), data.getNode());
+
masterContextRef.tell(new MergeRequest(store, data), ActorRef.noSender());
}
@Override
public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ LOG.trace("{}: Delete {} via NETCONF: {}", id, store, path);
+
masterContextRef.tell(new DeleteRequest(store, path), ActorRef.noSender());
}
public boolean cancel() {
final Future<Object> cancelScalaFuture =
Patterns.ask(masterContextRef, new CancelRequest(), NetconfTopologyUtils.TIMEOUT);
+
+ 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());
final Future<Object> submitScalaFuture =
Patterns.ask(masterContextRef, new SubmitRequest(), NetconfTopologyUtils.TIMEOUT);
+ LOG.trace("{}: Submit {} via NETCONF", id);
+
final DefaultPromise<Void> promise = new DefaultPromise<>();
submitScalaFuture.onComplete(new OnComplete<Object>() {
@Override
public void onComplete(final Throwable failure, final Object success) throws Throwable {
if (failure != null) { // ask timeout
- Exception exception = new DocumentedException("Master is down. Please try again.",
- DocumentedException.ErrorType.application, DocumentedException.ErrorTag.operation_failed,
- DocumentedException.ErrorSeverity.warning);
+ Exception exception = new DocumentedException(id + ":Master is down. Please try again.",
+ ErrorType.application, ErrorTag.operation_failed,
+ ErrorSeverity.warning);
promise.failure(exception);
return;
}
promise.failure((Throwable) success);
} else {
if (success instanceof SubmitFailedReply) {
- LOG.error("Transaction was not submitted.");
+ LOG.error("{}: Transaction was not submitted because already closed.", id);
}
promise.success(null);
}
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
+import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.singleton.api.NetconfDOMTransaction;
import org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import scala.concurrent.Future;
public class NetconfReadOnlyTransaction implements DOMDataReadOnlyTransaction {
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfReadOnlyTransaction.class);
+
+ private final RemoteDeviceId id;
private final NetconfDOMTransaction delegate;
private final ActorSystem actorSystem;
- public NetconfReadOnlyTransaction(final ActorSystem actorSystem, final NetconfDOMTransaction delegate) {
+ public NetconfReadOnlyTransaction(final RemoteDeviceId id,
+ final ActorSystem actorSystem,
+ final NetconfDOMTransaction delegate) {
+ this.id = id;
this.delegate = delegate;
this.actorSystem = actorSystem;
}
@Override
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
final YangInstanceIdentifier path) {
+
+ LOG.trace("{}: Read {} via NETCONF: {}", id, store, path);
+
final Future<Optional<NormalizedNodeMessage>> future = delegate.read(store, path);
final SettableFuture<Optional<NormalizedNode<?, ?>>> settableFuture = SettableFuture.create();
final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> checkedFuture;
@Override
public CheckedFuture<Boolean, ReadFailedException> exists(final LogicalDatastoreType store,
final YangInstanceIdentifier path) {
+
+ LOG.trace("{}: Exists {} via NETCONF: {}", id, store, path);
+
final Future<Boolean> existsFuture = delegate.exists(store, path);
final SettableFuture<Boolean> settableFuture = SettableFuture.create();
final CheckedFuture<Boolean, ReadFailedException> checkedFuture;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
+import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.singleton.api.NetconfDOMTransaction;
import org.opendaylight.netconf.topology.singleton.messages.NormalizedNodeMessage;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import scala.concurrent.Future;
public class NetconfWriteOnlyTransaction implements DOMDataWriteTransaction {
+ private static final Logger LOG = LoggerFactory.getLogger(NetconfWriteOnlyTransaction.class);
+
+ private final RemoteDeviceId id;
private final NetconfDOMTransaction delegate;
private final ActorSystem actorSystem;
- public NetconfWriteOnlyTransaction(final ActorSystem actorSystem, final NetconfDOMTransaction delegate) {
+ public NetconfWriteOnlyTransaction(final RemoteDeviceId id,
+ final ActorSystem actorSystem,
+ final NetconfDOMTransaction delegate) {
+ this.id = id;
this.delegate = delegate;
this.actorSystem = actorSystem;
}
@Override
public void put(final LogicalDatastoreType store, final YangInstanceIdentifier path,
final NormalizedNode<?,?> data) {
+ LOG.trace("{}: Write {} via NETCONF: {} with payload {}", id, store, path, data);
+
delegate.put(store, new NormalizedNodeMessage(path, data));
}
@Override
public void merge(final LogicalDatastoreType store, final YangInstanceIdentifier path,
final NormalizedNode<?,?> data) {
+ LOG.trace("{}: Merge {} via NETCONF: {} with payload {}", id, store, path, data);
+
delegate.merge(store, new NormalizedNodeMessage(path, data));
}
@Override
public boolean cancel() {
+ LOG.trace("{}: Cancel", id);
+
return delegate.cancel();
}
@Override
public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier path) {
+ LOG.trace("{}: Delete {} via NETCONF: {}", id, store, path);
+
delegate.delete(store, path);
}
@Override
public CheckedFuture<Void, TransactionCommitFailedException> submit() {
+ LOG.trace("{}: Submit", id);
+
final Future<Void> submit = delegate.submit();
final SettableFuture<Void> settFuture = SettableFuture.create();
final CheckedFuture<Void, TransactionCommitFailedException> checkedFuture;
@Override
public ListenableFuture<RpcResult<TransactionStatus>> commit() {
+ LOG.trace("{}: Commit", id);
+
final Future<Void> commit = delegate.submit();
final SettableFuture<RpcResult<TransactionStatus>> settFuture = SettableFuture.create();
commit.onComplete(new OnComplete<Void>() {
doReturn(readTx).when(delegateDataBroker).newReadOnlyTransaction();
final NetconfDOMTransaction masterDOMTransactions =
- new NetconfMasterDOMTransaction(delegateDataBroker);
+ new NetconfMasterDOMTransaction(remoteDeviceId, delegateDataBroker);
masterDataBroker =
new NetconfDOMDataBroker(system, remoteDeviceId, masterDOMTransactions);
// Create slave data broker for testing proxy
final NetconfDOMTransaction proxyDOMTransactions =
- new NetconfProxyDOMTransaction(system, masterRef);
+ new NetconfProxyDOMTransaction(remoteDeviceId, system, masterRef);
slaveDataBroker = new NetconfDOMDataBroker(system, remoteDeviceId, proxyDOMTransactions);
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
doReturn(readTx).when(delegateDataBroker).newReadOnlyTransaction();
final NetconfDOMTransaction masterDOMTransactions =
- new NetconfMasterDOMTransaction(delegateDataBroker);
+ new NetconfMasterDOMTransaction(remoteDeviceId, delegateDataBroker);
masterDataBroker =
new NetconfDOMDataBroker(system, remoteDeviceId, masterDOMTransactions);
// Create slave data broker for testing proxy
final NetconfDOMTransaction proxyDOMTransactions =
- new NetconfProxyDOMTransaction(system, masterRef);
+ new NetconfProxyDOMTransaction(remoteDeviceId, system, masterRef);
slaveDataBroker = new NetconfDOMDataBroker(system, remoteDeviceId, proxyDOMTransactions);