Custom scheme-cache-directory yang models are not replicated among
[netconf.git] / netconf / netconf-topology-singleton / src / main / java / org / opendaylight / netconf / topology / singleton / impl / actors / NetconfNodeActor.java
index 67d0b52a7c9bb668181aa3da72a6f6d020c46255..1cf7b9904eadc11d812550064b564923292b7dad 100644 (file)
@@ -5,7 +5,6 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.netconf.topology.singleton.impl.actors;
 
 import akka.actor.ActorRef;
@@ -15,7 +14,6 @@ import akka.actor.Status.Success;
 import akka.pattern.AskTimeoutException;
 import akka.util.Timeout;
 import com.google.common.base.Throwables;
-import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -30,14 +28,13 @@ import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 import org.opendaylight.controller.cluster.schema.provider.RemoteYangTextSourceProvider;
 import org.opendaylight.controller.cluster.schema.provider.impl.RemoteSchemaProvider;
 import org.opendaylight.controller.cluster.schema.provider.impl.YangTextSchemaSourceSerializationProxy;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
-import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeReadWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMDataTreeWriteTransaction;
+import org.opendaylight.mdsal.dom.api.DOMMountPointService;
+import org.opendaylight.mdsal.dom.api.DOMRpcResult;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
 import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
 import org.opendaylight.netconf.topology.singleton.impl.ProxyDOMRpcService;
 import org.opendaylight.netconf.topology.singleton.impl.ProxyYangTextSourceProvider;
@@ -56,11 +53,8 @@ import org.opendaylight.netconf.topology.singleton.messages.YangTextSchemaSource
 import org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessage;
 import org.opendaylight.netconf.topology.singleton.messages.rpc.InvokeRpcMessageReply;
 import org.opendaylight.netconf.topology.singleton.messages.transactions.EmptyResultResponse;
-import org.opendaylight.netconf.topology.singleton.messages.transactions.NewReadTransactionReply;
 import org.opendaylight.netconf.topology.singleton.messages.transactions.NewReadTransactionRequest;
-import org.opendaylight.netconf.topology.singleton.messages.transactions.NewReadWriteTransactionReply;
 import org.opendaylight.netconf.topology.singleton.messages.transactions.NewReadWriteTransactionRequest;
-import org.opendaylight.netconf.topology.singleton.messages.transactions.NewWriteTransactionReply;
 import org.opendaylight.netconf.topology.singleton.messages.transactions.NewWriteTransactionRequest;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
@@ -93,23 +87,19 @@ public class NetconfNodeActor extends AbstractUntypedActor {
     private ActorRef readTxActor;
     private List<SchemaSourceRegistration<YangTextSchemaSource>> registeredSchemas;
 
-    public static Props props(final NetconfTopologySetup setup,
-                              final RemoteDeviceId id, final SchemaSourceRegistry schemaRegistry,
-                              final SchemaRepository schemaRepository, final Timeout actorResponseWaitTime,
-                              final DOMMountPointService mountPointService) {
+    public static Props props(final NetconfTopologySetup setup, final RemoteDeviceId id,
+            final Timeout actorResponseWaitTime, final DOMMountPointService mountPointService) {
         return Props.create(NetconfNodeActor.class, () ->
-                new NetconfNodeActor(setup, id, schemaRegistry, schemaRepository, actorResponseWaitTime,
-                        mountPointService));
+                new NetconfNodeActor(setup, id, actorResponseWaitTime, mountPointService));
     }
 
     protected NetconfNodeActor(final NetconfTopologySetup setup,
-                               final RemoteDeviceId id, final SchemaSourceRegistry schemaRegistry,
-                               final SchemaRepository schemaRepository, final Timeout actorResponseWaitTime,
+                               final RemoteDeviceId id, final Timeout actorResponseWaitTime,
                                final DOMMountPointService mountPointService) {
         this.setup = setup;
         this.id = id;
-        this.schemaRegistry = schemaRegistry;
-        this.schemaRepository = schemaRepository;
+        this.schemaRegistry = setup.getSchemaResourcesDTO().getSchemaRegistry();
+        this.schemaRepository = setup.getSchemaResourcesDTO().getSchemaRepository();
         this.actorResponseWaitTime = actorResponseWaitTime;
         this.writeTxIdleTimeout = setup.getIdleTimeout();
         this.mountPointService = mountPointService;
@@ -117,7 +107,7 @@ public class NetconfNodeActor extends AbstractUntypedActor {
 
     @SuppressWarnings("checkstyle:IllegalCatch")
     @Override
-    public void handleReceive(final Object message) throws Exception {
+    public void handleReceive(final Object message) {
         LOG.debug("{}:  received message {}", id, message);
 
         if (message instanceof CreateInitialMasterActorData) { // master
@@ -125,7 +115,7 @@ public class NetconfNodeActor extends AbstractUntypedActor {
             final CreateInitialMasterActorData masterActorData = (CreateInitialMasterActorData) message;
             sourceIdentifiers = masterActorData.getSourceIndentifiers();
             this.deviceDataBroker = masterActorData.getDeviceDataBroker();
-            final DOMDataReadOnlyTransaction tx = deviceDataBroker.newReadOnlyTransaction();
+            final DOMDataTreeReadTransaction tx = deviceDataBroker.newReadOnlyTransaction();
             readTxActor = context().actorOf(ReadTransactionActor.props(tx));
             this.deviceRpc = masterActorData.getDeviceRpc();
 
@@ -156,25 +146,23 @@ public class NetconfNodeActor extends AbstractUntypedActor {
             sendYangTextSchemaSourceProxy(yangTextSchemaSourceRequest.getSourceIdentifier(), sender());
 
         } else if (message instanceof NewReadTransactionRequest) { // master
-
-            sender().tell(new NewReadTransactionReply(readTxActor), self());
-
+            sender().tell(new Success(readTxActor), self());
         } else if (message instanceof NewWriteTransactionRequest) { // master
             try {
-                final DOMDataWriteTransaction tx = deviceDataBroker.newWriteOnlyTransaction();
+                final DOMDataTreeWriteTransaction tx = deviceDataBroker.newWriteOnlyTransaction();
                 final ActorRef txActor = context().actorOf(WriteTransactionActor.props(tx, writeTxIdleTimeout));
-                sender().tell(new NewWriteTransactionReply(txActor), self());
+                sender().tell(new Success(txActor), self());
             } catch (final Exception t) {
-                sender().tell(t, self());
+                sender().tell(new Failure(t), self());
             }
 
         } else if (message instanceof NewReadWriteTransactionRequest) {
             try {
-                final DOMDataReadWriteTransaction tx = deviceDataBroker.newReadWriteTransaction();
+                final DOMDataTreeReadWriteTransaction tx = deviceDataBroker.newReadWriteTransaction();
                 final ActorRef txActor = context().actorOf(ReadWriteTransactionActor.props(tx, writeTxIdleTimeout));
-                sender().tell(new NewReadWriteTransactionReply(txActor), self());
+                sender().tell(new Success(txActor), self());
             } catch (final Exception t) {
-                sender().tell(t, self());
+                sender().tell(new Failure(t), self());
             }
         } else if (message instanceof InvokeRpcMessage) { // master
             final InvokeRpcMessage invokeRpcMessage = (InvokeRpcMessage) message;
@@ -223,6 +211,7 @@ public class NetconfNodeActor extends AbstractUntypedActor {
             @Override
             public void onSuccess(final YangTextSchemaSource yangTextSchemaSource) {
                 try {
+                    LOG.debug("{}: getSchemaSource for {} succeeded", id, sourceIdentifier);
                     sender.tell(new YangTextSchemaSourceSerializationProxy(yangTextSchemaSource), getSelf());
                 } catch (IOException e) {
                     sender.tell(new Failure(e), getSelf());
@@ -231,6 +220,7 @@ public class NetconfNodeActor extends AbstractUntypedActor {
 
             @Override
             public void onFailure(@Nonnull final Throwable throwable) {
+                LOG.debug("{}: getSchemaSource for {} failed", id, sourceIdentifier, throwable);
                 sender.tell(new Failure(throwable), getSelf());
             }
         }, MoreExecutors.directExecutor());
@@ -242,7 +232,7 @@ public class NetconfNodeActor extends AbstractUntypedActor {
         LOG.debug("{}: invokeSlaveRpc for {}, input: {} on rpc service {}", id, schemaPath, normalizedNodeMessage,
                 deviceRpc);
 
-        final CheckedFuture<DOMRpcResult, DOMRpcException> rpcResult = deviceRpc.invokeRpc(schemaPath,
+        final ListenableFuture<DOMRpcResult> rpcResult = deviceRpc.invokeRpc(schemaPath,
                 normalizedNodeMessage != null ? normalizedNodeMessage.getNode() : null);
 
         Futures.addCallback(rpcResult, new FutureCallback<DOMRpcResult>() {
@@ -297,7 +287,7 @@ public class NetconfNodeActor extends AbstractUntypedActor {
     }
 
     private void resolveSchemaContext(final SchemaContextFactory schemaContextFactory,
-            final SlaveSalFacade localSlaveSalManager, final ActorRef masterReference, int tries) {
+            final SlaveSalFacade localSlaveSalManager, final ActorRef masterReference, final int tries) {
         final ListenableFuture<SchemaContext> schemaContextFuture =
                 schemaContextFactory.createSchemaContext(sourceIdentifiers);
         Futures.addCallback(schemaContextFuture, new FutureCallback<SchemaContext>() {