Merge "Enabling Remote RPC Router module in ODL distribution."
authorTony Tkacik <ttkacik@cisco.com>
Wed, 5 Mar 2014 09:16:37 +0000 (09:16 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 5 Mar 2014 09:16:37 +0000 (09:16 +0000)
opendaylight/distribution/opendaylight/pom.xml
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/02-clustering.xml [new file with mode: 0644]
opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/03-toaster-sample.xml [moved from opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/02-toaster-sample.xml with 100% similarity]
opendaylight/md-sal/pom.xml
opendaylight/md-sal/remoterpc-routingtable/implementation/pom.xml
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/impl/SchemaAwareRpcBroker.java
opendaylight/md-sal/sal-remoterpc-connector/implementation/pom.xml
opendaylight/md-sal/sal-remoterpc-connector/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/remote/rpc/ZeroMQServerModule.java

index 79b9cce..38dc454 100644 (file)
           <artifactId>restconf-client-impl</artifactId>
         </dependency>
 
+        <!-- clustering -->
+        <dependency>
+          <groupId>org.opendaylight.controller</groupId>
+          <artifactId>remoterpc-routingtable.implementation</artifactId>
+          <version>${mdsal.version}</version>
+        </dependency>
+        <dependency>
+          <groupId>org.opendaylight.controller</groupId>
+          <artifactId>sal-remoterpc-connector</artifactId>
+          <version>${mdsal.version}</version>
+        </dependency>
+
         <!-- config-->
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
diff --git a/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/02-clustering.xml b/opendaylight/distribution/opendaylight/src/main/resources/configuration/initial/02-clustering.xml
new file mode 100644 (file)
index 0000000..7853b86
--- /dev/null
@@ -0,0 +1,27 @@
+<snapshot>
+    <configuration>
+        <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+            <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+                <module>
+                   <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">prefix:remote-zeromq-rpc-server</type>
+                   <name>remoter</name>
+                   <port xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">5666</port>
+                   <dom-broker xmlns="urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc">
+                       <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom">prefix:dom-broker-osgi-registry</type>
+                       <name>dom-broker</name>
+                   </dom-broker>
+               </module>
+            </modules>
+            <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+            </services>
+        </data>
+    </configuration>
+
+    <required-capabilities>
+       <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&amp;revision=2013-10-28</capability>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:impl?module=opendaylight-sal-dom-broker-impl&amp;revision=2013-10-28</capability>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&amp;revision=2013-10-28</capability>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:remote:rpc?module=odl-sal-dom-rpc-remote-cfg&amp;revision=2013-10-28</capability>
+    </required-capabilities>
+</snapshot>
+
index 6cc06ba..d05e8b0 100644 (file)
         <!-- Compability Packages -->
         <module>compatibility</module>
 
-       <!-- Clustering
-       <module>remoterpc-routingtable/implementation</module>
+       <!-- Clustering -->
+             <module>remoterpc-routingtable/implementation</module>
         <module>sal-remoterpc-connector/implementation</module>
-        <module>clustered-data-store/implementation</module>
+        <!--module>clustered-data-store/implementation</module>
         -->
         
     </modules>
index dedd318..ccff37c 100644 (file)
@@ -5,7 +5,7 @@
     <parent>
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>sal-parent</artifactId>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.1-SNAPSHOT</version>
         <relativePath>../..</relativePath>
     </parent>
     <scm>
@@ -16,7 +16,6 @@
     </scm>
 
     <artifactId>remoterpc-routingtable.implementation</artifactId>
-    <version>0.4.1-SNAPSHOT</version>
     <packaging>bundle</packaging>
 
     <build>
@@ -49,7 +48,8 @@
                             org.eclipse.osgi.framework.console,
                             org.osgi.framework,
                             javax.transaction,
-                            com.google.common.base
+                            com.google.common.base,
+                            com.google.common.collect
                         </Import-Package>
                         <Bundle-Activator>
                             org.opendaylight.controller.sal.connector.remoterpc.impl.Activator
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>sal-connector-api</artifactId>
-            <version>1.0-SNAPSHOT</version>
+            <version>${project.version}</version>
         </dependency>
 
         <dependency>
             <groupId>org.opendaylight.controller</groupId>
             <artifactId>clustering.services</artifactId>
-            <version>0.5.0-SNAPSHOT</version>
+            <version>${clustering.services.version}</version>
         </dependency>
 
 
index 22319ab..598361c 100644 (file)
@@ -43,6 +43,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Optional;
+import com.google.common.collect.FluentIterable;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 
 public class SchemaAwareRpcBroker implements RpcRouter, Identifiable<String>, RoutedRpcDefaultImplementation {
@@ -53,7 +55,7 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable<String>, Ro
             "2013-07-09", "context-reference");
     private final ListenerRegistry<RpcRegistrationListener> rpcRegistrationListeners = new ListenerRegistry<>();
     private final ListenerRegistry<RouteChangeListener<RpcRoutingContext, InstanceIdentifier>> routeChangeListeners = new ListenerRegistry<>();
-    
+
 
     private final String identifier;
     private final ConcurrentMap<QName, RpcImplementation> implementations = new ConcurrentHashMap<>();
@@ -280,24 +282,26 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable<String>, Ro
         }
     }
 
-    private static class RoutedRpcSelector implements RpcImplementation, AutoCloseable, Identifiable<QName> {
+    private static class RoutedRpcSelector implements RpcImplementation, AutoCloseable, Identifiable<RpcRoutingContext> {
 
         private final RoutedRpcStrategy strategy;
         private final Set<QName> supportedRpcs;
+        private final RpcRoutingContext identifier;
         private RpcImplementation defaultDelegate;
         private final ConcurrentMap<InstanceIdentifier, RoutedRpcRegImpl> implementations = new ConcurrentHashMap<>();
-        private SchemaAwareRpcBroker router;
+        private final SchemaAwareRpcBroker router;
 
         public RoutedRpcSelector(RoutedRpcStrategy strategy, SchemaAwareRpcBroker router) {
             super();
             this.strategy = strategy;
             supportedRpcs = ImmutableSet.of(strategy.getIdentifier());
+            identifier = RpcRoutingContext.create(strategy.context, strategy.getIdentifier());
             this.router = router;
         }
 
         @Override
-        public QName getIdentifier() {
-            return strategy.getIdentifier();
+        public RpcRoutingContext getIdentifier() {
+            return identifier;
         }
 
         @Override
@@ -382,7 +386,7 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable<String>, Ro
             RoutedRpcRegistration {
 
         private final QName type;
-        private RoutedRpcSelector router;
+        private final RoutedRpcSelector router;
 
         public RoutedRpcRegImpl(QName rpcType, RpcImplementation implementation, RoutedRpcSelector routedRpcSelector) {
             super(implementation);
@@ -424,13 +428,13 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable<String>, Ro
                 routeListener.getInstance().onRouteChange(change);
             } catch (Exception e) {
                 LOG.error("Unhandled exception during invoking onRouteChange for {}",routeListener.getInstance(),e);
-                
+
             }
         }
-        
+
     }
 
-    
+
 
     private void notifyPathWithdrawal(QName context,QName identifier, InstanceIdentifier path) {
         RpcRoutingContext contextWrapped = RpcRoutingContext.create(context, identifier);
@@ -443,10 +447,31 @@ public class SchemaAwareRpcBroker implements RpcRouter, Identifiable<String>, Ro
             }
         }
     }
-    
+
     @Override
     public <L extends RouteChangeListener<RpcRoutingContext, InstanceIdentifier>> ListenerRegistration<L> registerRouteChangeListener(
             L listener) {
-        return routeChangeListeners.registerWithType(listener);
+        ListenerRegistration<L> reg = routeChangeListeners.registerWithType(listener);
+        RouteChange<RpcRoutingContext, InstanceIdentifier> initial = createInitialRouteChange();
+        try {
+        listener.onRouteChange(initial);
+        } catch (Exception e) {
+            LOG.error("Unhandled exception during sending initial route change event {} to {}",initial,listener);
+        }
+        return reg;
+    }
+
+    private RouteChange<RpcRoutingContext, InstanceIdentifier> createInitialRouteChange() {
+        FluentIterable<RoutedRpcSelector> rpcSelectors = FluentIterable.from(implementations.values()).filter(RoutedRpcSelector.class);
+
+
+        ImmutableMap.Builder<RpcRoutingContext, Set<InstanceIdentifier>> announcements = ImmutableMap.builder();
+        ImmutableMap.Builder<RpcRoutingContext, Set<InstanceIdentifier>> removals = ImmutableMap.builder();
+        for (RoutedRpcSelector routedRpcSelector : rpcSelectors) {
+            final RpcRoutingContext context = routedRpcSelector.getIdentifier();
+            final Set<InstanceIdentifier> paths = ImmutableSet.copyOf(routedRpcSelector.implementations.keySet());
+            announcements.put(context, paths);
+        }
+        return RoutingUtils.change(announcements.build(), removals.build());
     }
 }
index ae31c23..9a8f149 100644 (file)
@@ -6,7 +6,7 @@
         <groupId>org.opendaylight.controller</groupId>
         <artifactId>sal-parent</artifactId>
         <relativePath>../..</relativePath>
-        <version>1.0-SNAPSHOT</version>
+        <version>1.1-SNAPSHOT</version>
     </parent>
 
     <artifactId>sal-remoterpc-connector</artifactId>
@@ -14,8 +14,8 @@
 
   <properties>
     <zeromq.version>0.3.1</zeromq.version>
-    <jackson.version>2.3.0</jackson.version>
     <stax.version>1.0.1</stax.version>
+    <yang.jmx.plugin>0.2.4-SNAPSHOT</yang.jmx.plugin>
   </properties>
 
   <dependencies>
@@ -38,8 +38,7 @@
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>remoterpc-routingtable.implementation</artifactId>
-      <!-- TODO: fix the version. Why is it not MD Sal project version?-->
-      <version>0.4.1-SNAPSHOT</version>
+      <version>${project.version}</version>
     </dependency>
 
     <!-- AD Sal -->
                     <instructions>
                         <Import-Package>
                             *,
+                            com.google.common.collect,
                             !org.codehaus.enunciate.jaxrs
                         </Import-Package>
                         <Export-Package>
                     <dependency>
                         <groupId>org.opendaylight.controller</groupId>
                         <artifactId>yang-jmx-generator-plugin</artifactId>
-                        <version>0.2.3-SNAPSHOT</version>
+                        <version>${yang.jmx.plugin}</version>
                     </dependency>
                     <dependency>
                         <groupId>org.opendaylight.yangtools</groupId>
                         <artifactId>maven-sal-api-gen-plugin</artifactId>
-                       <version>${yangtools.version}</version>
+                                   <version>${yangtools.version}</version>
                         <type>jar</type>
                     </dependency>
                 </dependencies>
index d874381..f55566a 100644 (file)
@@ -13,44 +13,46 @@ import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry;
 import org.osgi.framework.BundleContext;
 
 /**
-*
-*/
-public final class ZeroMQServerModule extends org.opendaylight.controller.config.yang.md.sal.remote.rpc.AbstractZeroMQServerModule
- {
+ *
+ */
+public final class ZeroMQServerModule
+    extends org.opendaylight.controller.config.yang.md.sal.remote.rpc.AbstractZeroMQServerModule {
+
+  private static final Integer ZEROMQ_ROUTER_PORT = 5554;
+  private BundleContext bundleContext;
+
+  public ZeroMQServerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+                            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+    super(identifier, dependencyResolver);
+  }
 
-    private static final Integer ZEROMQ_ROUTER_PORT = 5554;
-    private BundleContext bundleContext;
+  public ZeroMQServerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+                            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+                            ZeroMQServerModule oldModule, java.lang.AutoCloseable oldInstance) {
 
-    public ZeroMQServerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
+    super(identifier, dependencyResolver, oldModule, oldInstance);
+  }
 
-    public ZeroMQServerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
-            ZeroMQServerModule oldModule, java.lang.AutoCloseable oldInstance) {
+  @Override
+  protected void customValidation() {
+    // Add custom validation for module attributes here.
+  }
 
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
+  @Override
+  public java.lang.AutoCloseable createInstance() {
 
-    @Override
-    protected void customValidation(){
-        // Add custom validation for module attributes here.
-    }
+    Broker broker = getDomBrokerDependency();
 
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        
-        Broker broker = getDomBrokerDependency();
+    final int port = getPort() != null ? getPort() : ZEROMQ_ROUTER_PORT;
 
-        final int port = getPort() != null ? getPort() : ZEROMQ_ROUTER_PORT;
+    ServerImpl serverImpl = new ServerImpl(port);
 
-        ServerImpl serverImpl = new ServerImpl(port);
-        
-        ClientImpl clientImpl = new ClientImpl();
+    ClientImpl clientImpl = new ClientImpl();
 
     RoutingTableProvider provider = new RoutingTableProvider(bundleContext);//,serverImpl);
 
-
-    facade.setRoutingTableProvider(provider );
+    RemoteRpcProvider facade = new RemoteRpcProvider(serverImpl, clientImpl);
+    facade.setRoutingTableProvider(provider);
     facade.setContext(bundleContext);
     facade.setRpcProvisionRegistry((RpcProvisionRegistry) broker);
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.