Fix bug 2449 in sal-remoterpc-connector 35/13735/1
authorXin Chang <xin.chang@huawei.com>
Sat, 29 Nov 2014 07:23:15 +0000 (15:23 +0800)
committerMoiz Raja <moraja@cisco.com>
Thu, 18 Dec 2014 14:23:00 +0000 (14:23 +0000)
Regarding to Moiz's comments, replace sender from null to
ActorRef.noSender() in RpcManager.java

Register SchemeContextListener with global SchemeService and push scheme
context to RpcBroker

Change-Id: Ia941f25f7b82a8146bf412389fbea5219c76f55a
Signed-off-by: Xin Chang <xin.chang@huawei.com>
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProvider.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcBroker.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RpcManager.java

index 8b4ce31..d24ed56 100644 (file)
@@ -73,6 +73,8 @@ public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContext
                                      config.getRpcManagerName());
 
     LOG.debug("rpc manager started");
+
+    schemaService.registerSchemaContextListener(this);
   }
 
   @Override
index 2046e41..31aac92 100644 (file)
@@ -13,14 +13,17 @@ import akka.actor.Props;
 import akka.dispatch.OnComplete;
 import akka.japi.Creator;
 import akka.japi.Pair;
+
 import com.google.common.util.concurrent.FutureCallback;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.JdkFutureAdapters;
 import com.google.common.util.concurrent.ListenableFuture;
+
 import org.opendaylight.controller.cluster.common.actor.AbstractUntypedActor;
 import org.opendaylight.controller.remote.rpc.messages.ExecuteRpc;
 import org.opendaylight.controller.remote.rpc.messages.InvokeRpc;
 import org.opendaylight.controller.remote.rpc.messages.RpcResponse;
+import org.opendaylight.controller.remote.rpc.messages.UpdateSchemaContext;
 import org.opendaylight.controller.remote.rpc.registry.RpcRegistry;
 import org.opendaylight.controller.remote.rpc.utils.LatestEntryRoutingLogic;
 import org.opendaylight.controller.remote.rpc.utils.RoutingLogic;
@@ -53,7 +56,7 @@ public class RpcBroker extends AbstractUntypedActor {
     private static final Logger LOG = LoggerFactory.getLogger(RpcBroker.class);
     private final Broker.ProviderSession brokerSession;
     private final ActorRef rpcRegistry;
-    private final SchemaContext schemaContext;
+    private SchemaContext schemaContext;
     private final RemoteRpcProviderConfig config;
 
     private RpcBroker(Broker.ProviderSession brokerSession, ActorRef rpcRegistry,
@@ -75,9 +78,15 @@ public class RpcBroker extends AbstractUntypedActor {
             invokeRemoteRpc((InvokeRpc) message);
         } else if(message instanceof ExecuteRpc) {
             executeRpc((ExecuteRpc) message);
+        } else if(message instanceof UpdateSchemaContext) {
+            updateSchemaContext((UpdateSchemaContext) message);
         }
     }
 
+    private void updateSchemaContext(UpdateSchemaContext message) {
+        this.schemaContext = message.getSchemaContext();
+    }
+
     private void invokeRemoteRpc(final InvokeRpc msg) {
         if(LOG.isDebugEnabled()) {
             LOG.debug("Looking up the remote actor for rpc {}", msg.getRpc());
index a840712..fb8822d 100644 (file)
@@ -123,6 +123,7 @@ public class RpcManager extends AbstractUntypedActor {
 
   private void updateSchemaContext(UpdateSchemaContext message) {
     this.schemaContext = message.getSchemaContext();
+    rpcBroker.tell(message, ActorRef.noSender());
   }
 
   @Override