Add blueprint wiring to sal-remoterpc-connector 52/35852/23
authorTom Pantelis <tpanteli@brocade.com>
Sun, 6 Mar 2016 04:38:19 +0000 (23:38 -0500)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 13 Apr 2016 11:03:34 +0000 (11:03 +0000)
Change-Id: I23877888fd49e7dbe4568a7b7a51409589d5ff63
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/config/yang/config/remote_rpc_connector/RemoteRPCBrokerModule.java
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/RemoteRpcProviderConfig.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/java/org/opendaylight/controller/remote/rpc/RemoteRpcProviderFactory.java
opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/org/opendaylight/blueprint/remote-rpc.xml [new file with mode: 0644]

index c68503c0fa313bbbd48a3d3cd5538f489acaeaf3..4ada10a88735d1ebc632d1cbd37208eedd474b81 100644 (file)
@@ -9,6 +9,8 @@
 package org.opendaylight.controller.config.yang.config.remote_rpc_connector;
 
 import akka.actor.ActorSystem;
+import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
+import org.opendaylight.controller.remote.rpc.RemoteRpcProvider;
 import org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig;
 import org.opendaylight.controller.remote.rpc.RemoteRpcProviderFactory;
 import org.opendaylight.controller.sal.core.api.Broker;
@@ -44,7 +46,10 @@ public class RemoteRPCBrokerModule extends org.opendaylight.controller.config.ya
                 .mailboxCapacity(getBoundedMailboxCapacity())
                 .build();
 
-        return RemoteRpcProviderFactory.createInstance(broker, bundleContext, actorSystem, config);
+        RemoteRpcProvider rpcProvider = RemoteRpcProviderFactory.createInstance((DOMRpcProviderService)broker,
+                actorSystem, config);
+        broker.registerProvider(rpcProvider);
+        return rpcProvider;
     }
 
     public void setBundleContext(BundleContext bundleContext) {
index bdfdfc2832c45fecc4fe0680e44a768569c62811..80aebd1918a33e5fa588ec13348e11a4515f32e3 100644 (file)
@@ -37,7 +37,8 @@ public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContext
 
   private ListenerRegistration<SchemaContextListener> schemaListenerRegistration;
   private final ActorSystem actorSystem;
-  private Broker.ProviderSession brokerSession;
+  private SchemaService schemaService;
+  private DOMRpcService rpcService;
   private SchemaContext schemaContext;
   private ActorRef rpcManager;
   private final RemoteRpcProviderConfig config;
@@ -51,6 +52,14 @@ public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContext
     this.config = Preconditions.checkNotNull(config);
   }
 
+  public void setRpcService(DOMRpcService rpcService) {
+      this.rpcService = rpcService;
+  }
+
+  public void setSchemaService(SchemaService schemaService) {
+      this.schemaService = schemaService;
+  }
+
   @Override
   public void close() throws Exception {
     if (schemaListenerRegistration != null) {
@@ -61,7 +70,8 @@ public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContext
 
   @Override
   public void onSessionInitiated(final Broker.ProviderSession session) {
-    brokerSession = session;
+    schemaService = session.getService(SchemaService.class);
+    rpcService = session.getService(DOMRpcService.class);
     start();
   }
 
@@ -70,11 +80,9 @@ public class RemoteRpcProvider implements AutoCloseable, Provider, SchemaContext
     return null;
   }
 
-  private void start() {
+  public void start() {
     LOG.info("Starting remote rpc service...");
 
-    final SchemaService schemaService = brokerSession.getService(SchemaService.class);
-    final DOMRpcService rpcService = brokerSession.getService(DOMRpcService.class);
     schemaContext = schemaService.getGlobalContext();
     rpcManager = actorSystem.actorOf(RpcManager.props(schemaContext,
             rpcProvisionRegistry, rpcService, config), config.getRpcManagerName());
index 995b1d5172553f234e6602a11ccb236c19bf0d50..cb5097d24e40f5a73fd675835519b22c7957cec4 100644 (file)
@@ -82,6 +82,15 @@ public class RemoteRpcProviderConfig extends CommonConfig {
         return cachedGossipTickInterval;
     }
 
+    /**
+     * This is called via blueprint xml as the builder pattern can't be used.
+     */
+    public static RemoteRpcProviderConfig newInstance(String actorSystemName, boolean metricCaptureEnabled,
+            int mailboxCapacity) {
+        return new Builder(actorSystemName).metricCaptureEnabled(metricCaptureEnabled).
+                mailboxCapacity(mailboxCapacity).build();
+    }
+
     public static class Builder extends CommonConfig.Builder<Builder>{
 
         public Builder(String actorSystemName){
index af36b8afc9b982b82fbb389111fb70821bd52aa6..c6ec928ea70d5b8a3e3a4d7cf24f5d0a9230527d 100644 (file)
@@ -10,16 +10,11 @@ package org.opendaylight.controller.remote.rpc;
 
 import akka.actor.ActorSystem;
 import org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService;
-import org.opendaylight.controller.sal.core.api.Broker;
-import org.osgi.framework.BundleContext;
 
 public class RemoteRpcProviderFactory {
-    public static RemoteRpcProvider createInstance(final Broker broker, final BundleContext bundleContext,
+    public static RemoteRpcProvider createInstance(final DOMRpcProviderService rpcProviderService,
             final ActorSystem actorSystem, final RemoteRpcProviderConfig config) {
 
-        final RemoteRpcProvider rpcProvider = new RemoteRpcProvider(actorSystem, (DOMRpcProviderService) broker, config);
-
-        broker.registerProvider(rpcProvider);
-        return rpcProvider;
+        return new RemoteRpcProvider(actorSystem, rpcProviderService, config);
     }
 }
diff --git a/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/org/opendaylight/blueprint/remote-rpc.xml b/opendaylight/md-sal/sal-remoterpc-connector/src/main/resources/org/opendaylight/blueprint/remote-rpc.xml
new file mode 100644 (file)
index 0000000..453c252
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
+           xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0"
+           xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
+    odl:restart-dependents-on-updates="true" odl:use-default-for-reference-types="true">
+
+  <cm:property-placeholder persistent-id="org.opendaylight.controller.remoterpc" update-strategy="none">
+    <cm:default-properties>
+      <cm:property name="enable-metric-capture" value="false"/>
+      <cm:property name="bounded-mailbox-capacity" value="1000"/>
+    </cm:default-properties>
+  </cm:property-placeholder>
+
+  <reference id="actorSystemProvider" interface="org.opendaylight.controller.cluster.ActorSystemProvider" />
+  <reference id="schemaService" interface="org.opendaylight.controller.sal.core.api.model.SchemaService" />
+  <reference id="domRpcService" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcService"/>
+  <reference id="domRpcRegistry" interface="org.opendaylight.controller.md.sal.dom.api.DOMRpcProviderService"/>
+
+  <bean id="actorSystem" factory-ref="actorSystemProvider" factory-method="getActorSystem"/>
+
+  <bean id="remoteRpcProviderConfig" class="org.opendaylight.controller.remote.rpc.RemoteRpcProviderConfig"
+          factory-method="newInstance">
+    <argument>
+      <bean factory-ref="actorSystem" factory-method="name"/>
+    </argument>
+    <argument value="${enable-metric-capture}"/>
+    <argument value="${bounded-mailbox-capacity}"/>
+  </bean>
+
+  <bean id="remoteRpcProvider" class="org.opendaylight.controller.remote.rpc.RemoteRpcProviderFactory"
+          factory-method="createInstance" init-method="start" destroy-method="close">
+    <argument ref="domRpcRegistry"/>
+    <argument ref="actorSystem"/>
+    <argument ref="remoteRpcProviderConfig"/>
+    <property name="schemaService" ref="schemaService"/>
+    <property name="rpcService" ref="domRpcService"/>
+  </bean>
+
+</blueprint>