Move ClusterAdminRpcService to its own bundle 49/36849/18
authorTom Pantelis <tpanteli@brocade.com>
Tue, 29 Mar 2016 07:41:24 +0000 (03:41 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Fri, 29 Apr 2016 18:49:10 +0000 (18:49 +0000)
The ClusterAdminRpcService can't be instantiated with the clustered
datastore blueprint xml b/c it needs the binding RPC registry service so
I moved it to its own bundle.

I made the ClusterAdminProviderModule a no-op since the
ClusterAdminRpcService is now created via blueprint.

I also had to export some packages from the sal-distributed-datastore
bundle.

Change-Id: Icaf025517ed9b08a82a81310f1e5dd2ac0647559
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
13 files changed:
features/mdsal/pom.xml
features/mdsal/src/main/features/features.xml
opendaylight/md-sal/pom.xml
opendaylight/md-sal/sal-cluster-admin/pom.xml [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin/src/main/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcService.java [moved from opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcService.java with 100% similarity]
opendaylight/md-sal/sal-cluster-admin/src/main/java/org/opendaylight/controller/config/yang/config/cluster_admin_provider/ClusterAdminProviderModule.java [moved from opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_admin_provider/ClusterAdminProviderModule.java with 52% similarity]
opendaylight/md-sal/sal-cluster-admin/src/main/java/org/opendaylight/controller/config/yang/config/cluster_admin_provider/ClusterAdminProviderModuleFactory.java [moved from opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_admin_provider/ClusterAdminProviderModuleFactory.java with 100% similarity]
opendaylight/md-sal/sal-cluster-admin/src/main/resources/org/opendaylight/blueprint/cluster-admin.xml [new file with mode: 0644]
opendaylight/md-sal/sal-cluster-admin/src/main/yang/cluster-admin-service.yang [moved from opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-admin-service.yang with 93% similarity]
opendaylight/md-sal/sal-cluster-admin/src/main/yang/cluster-admin.yang [moved from opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-admin.yang with 100% similarity]
opendaylight/md-sal/sal-cluster-admin/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java [moved from opendaylight/md-sal/sal-distributed-datastore/src/test/java/org/opendaylight/controller/cluster/datastore/admin/ClusterAdminRpcServiceTest.java with 100% similarity]
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/DataPersistenceProviderMonitor.java [deleted file]
opendaylight/md-sal/sal-distributed-datastore/pom.xml

index f12e9e1..5c1a1ed 100644 (file)
       <type>cfg</type>
       <classifier>datastore</classifier>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-cluster-admin</artifactId>
+      <version>${controller.mdsal.version}</version>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.controller</groupId>
       <artifactId>sal-distributed-datastore</artifactId>
index 88a18f7..d5d06f6 100644 (file)
@@ -82,6 +82,7 @@
         <feature version='${project.version}'>odl-mdsal-broker-local</feature>
         <feature version='${project.version}'>odl-mdsal-clustering-commons</feature>
         <bundle>mvn:org.opendaylight.controller/sal-distributed-datastore/{{VERSION}}</bundle>
+        <bundle>mvn:org.opendaylight.controller/sal-cluster-admin/{{VERSION}}</bundle>
     </feature>
     <feature name ='odl-mdsal-remoterpc-connector' version='${project.version}'>
         <feature version='${project.version}'>odl-mdsal-broker-local</feature>
index 0b8e0d0..03aa18c 100644 (file)
@@ -64,6 +64,7 @@
     <!-- sal-distributed-datastore -->
     <module>sal-distributed-datastore</module>
     <module>sal-dummy-distributed-datastore</module>
+    <module>sal-cluster-admin</module>
 
     <!-- XSQL -->
     <module>sal-dom-xsql</module>
diff --git a/opendaylight/md-sal/sal-cluster-admin/pom.xml b/opendaylight/md-sal/sal-cluster-admin/pom.xml
new file mode 100644 (file)
index 0000000..7f80ea4
--- /dev/null
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>sal-parent</artifactId>
+    <version>1.4.0-SNAPSHOT</version>
+  </parent>
+  <artifactId>sal-cluster-admin</artifactId>
+  <packaging>bundle</packaging>
+
+  <dependencies>
+    <!-- Tests -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-akka-raft</artifactId>
+      <type>test-jar</type>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-distributed-datastore</artifactId>
+      <type>test-jar</type>
+      <version>1.4.0-SNAPSHOT</version>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- Akka -->
+    <dependency>
+      <groupId>com.typesafe.akka</groupId>
+      <artifactId>akka-actor_${scala.version}</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>com.typesafe.akka</groupId>
+      <artifactId>akka-testkit_${scala.version}</artifactId>
+    </dependency>
+
+    <!-- Google -->
+    <dependency>
+      <groupId>com.google.guava</groupId>
+      <artifactId>guava</artifactId>
+    </dependency>
+
+    <!-- Scala -->
+    <dependency>
+      <groupId>org.scala-lang</groupId>
+      <artifactId>scala-library</artifactId>
+    </dependency>
+
+    <!-- OpenDaylight -->
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>config-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-binding-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-akka-raft</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-distributed-datastore</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.mdsal</groupId>
+      <artifactId>yang-binding</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-common</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.commons</groupId>
+      <artifactId>commons-lang3</artifactId>
+    </dependency>
+
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <extensions>true</extensions>
+        <configuration>
+          <instructions>
+            <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
+            <Export-Package></Export-Package>
+            <Import-Package>
+                !*snappy;
+                !org.jboss.*;
+                !com.jcraft.*;
+                !*jetty*;
+                !sun.security.*;
+                *;
+            </Import-Package>
+          </instructions>
+        </configuration>
+      </plugin>
+
+      <plugin>
+        <groupId>org.jacoco</groupId>
+        <artifactId>jacoco-maven-plugin</artifactId>
+        <configuration>
+          <includes>
+            <include>org.opendaylight.controller.*</include>
+
+          </includes>
+          <excludes>
+              <exclude>org.opendaylight.controller.config.yang.config.*</exclude>
+          </excludes>
+          <check>false</check>
+        </configuration>
+        <executions>
+          <execution>
+            <id>pre-test</id>
+            <goals>
+              <goal>prepare-agent</goal>
+            </goals>
+          </execution>
+          <execution>
+            <id>post-test</id>
+            <goals>
+              <goal>report</goal>
+            </goals>
+            <phase>test</phase>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.opendaylight.yangtools</groupId>
+        <artifactId>yang-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>config</id>
+            <goals>
+              <goal>generate-sources</goal>
+            </goals>
+            <configuration>
+              <codeGenerators>
+                <generator>
+                  <codeGeneratorClass>org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator</codeGeneratorClass>
+                  <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
+                  <additionalConfiguration>
+                    <namespaceToPackage1>urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang</namespaceToPackage1>
+                  </additionalConfiguration>
+                </generator>
+                <generator>
+                  <codeGeneratorClass>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
+                  <outputBaseDir>${salGeneratorPath}</outputBaseDir>
+                </generator>
+              </codeGenerators>
+              <inspectDependencies>true</inspectDependencies>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
@@ -8,11 +8,9 @@
 
 package org.opendaylight.controller.config.yang.config.cluster_admin_provider;
 
-import com.google.common.base.Preconditions;
-import org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface;
-import org.opendaylight.controller.cluster.datastore.admin.ClusterAdminRpcService;
 import org.opendaylight.controller.config.api.DependencyResolver;
 import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.sal.common.util.NoopAutoCloseable;
 
 public class ClusterAdminProviderModule extends AbstractClusterAdminProviderModule {
     public ClusterAdminProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
@@ -25,20 +23,13 @@ public class ClusterAdminProviderModule extends AbstractClusterAdminProviderModu
     }
 
     @Override
-    public void customValidation() {
-        // add custom validation form module attributes here.
+    public boolean canReuseInstance(AbstractClusterAdminProviderModule oldModule) {
+        return true;
     }
 
     @Override
     public AutoCloseable createInstance() {
-        Preconditions.checkArgument(getConfigDataStoreDependency() instanceof DistributedDataStoreInterface,
-                "Injected config DOMStore must be an instance of DistributedDataStoreInterface");
-        Preconditions.checkArgument(getOperDataStoreDependency() instanceof DistributedDataStoreInterface,
-                "Injected operational DOMStore must be an instance of DistributedDataStoreInterface");
-        ClusterAdminRpcService service = new ClusterAdminRpcService(
-                (DistributedDataStoreInterface)getConfigDataStoreDependency(),
-                (DistributedDataStoreInterface)getOperDataStoreDependency());
-        service.start(getRpcRegistryDependency());
-        return service;
+        // The ClusterAdminRpcService is created via blueprint so return a noop here for backwards compatibility.
+        return NoopAutoCloseable.INSTANCE;
     }
 }
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-cluster-admin/src/main/resources/org/opendaylight/blueprint/cluster-admin.xml b/opendaylight/md-sal/sal-cluster-admin/src/main/resources/org/opendaylight/blueprint/cluster-admin.xml
new file mode 100644 (file)
index 0000000..85edd2e
--- /dev/null
@@ -0,0 +1,20 @@
+<?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">
+
+  <!-- ClusterAdminRpcService -->
+
+  <reference id="configDatastore" interface="org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface"
+      odl:type="distributed-config"/>
+
+  <reference id="operationalDatastore" interface="org.opendaylight.controller.cluster.datastore.DistributedDataStoreInterface"
+      odl:type="distributed-operational"/>
+
+  <bean id="clusterAdminService" class="org.opendaylight.controller.cluster.datastore.admin.ClusterAdminRpcService">
+    <argument ref="configDatastore"/>
+    <argument ref="operationalDatastore"/>
+  </bean>
+
+  <odl:rpc-implementation ref="clusterAdminService"/>
+
+</blueprint>
\ No newline at end of file
@@ -28,7 +28,7 @@ module cluster-admin-provider {
                 container config-data-store {
                     uses config:service-ref {
                         refine type {
-                            mandatory true;
+                            mandatory false;
                             config:required-identity config-dom-store-spi:config-dom-datastore;
                         }
                     }
@@ -37,7 +37,7 @@ module cluster-admin-provider {
                 container oper-data-store {
                     uses config:service-ref {
                         refine type {
-                            mandatory true;
+                            mandatory false;
                             config:required-identity operational-dom-store-spi:operational-dom-datastore;
                         }
                     }
@@ -46,7 +46,7 @@ module cluster-admin-provider {
                 container rpc-registry {
                     uses config:service-ref {
                         refine type {
-                            mandatory true;
+                            mandatory false;
                             config:required-identity mdsal:binding-rpc-registry;
                         }
                     }
diff --git a/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/DataPersistenceProviderMonitor.java b/opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/DataPersistenceProviderMonitor.java
deleted file mode 100644 (file)
index bad9fc3..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * 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.controller.cluster.datastore;
-
-import akka.japi.Procedure;
-import akka.persistence.SnapshotSelectionCriteria;
-import java.util.concurrent.CountDownLatch;
-import org.opendaylight.controller.cluster.DataPersistenceProvider;
-
-/**
- * This class is intended for testing purposes. It just triggers CountDownLatch's in each method.
- * This class really should be under src/test/java but it was problematic trying to uses it in other projects.
- */
-public class DataPersistenceProviderMonitor implements DataPersistenceProvider {
-
-    private CountDownLatch persistLatch = new CountDownLatch(1);
-    private CountDownLatch saveSnapshotLatch = new CountDownLatch(1);
-    private CountDownLatch deleteSnapshotsLatch = new CountDownLatch(1);;
-    private CountDownLatch deleteMessagesLatch = new CountDownLatch(1);;
-
-    @Override
-    public boolean isRecoveryApplicable() {
-        return false;
-    }
-
-    @Override
-    public <T> void persist(T o, Procedure<T> procedure) {
-        persistLatch.countDown();
-    }
-
-    @Override
-    public void saveSnapshot(Object o) {
-        saveSnapshotLatch.countDown();
-    }
-
-    @Override
-    public void deleteSnapshots(SnapshotSelectionCriteria criteria) {
-        deleteSnapshotsLatch.countDown();
-    }
-
-    @Override
-    public void deleteMessages(long sequenceNumber) {
-        deleteMessagesLatch.countDown();
-    }
-
-    public void setPersistLatch(CountDownLatch persistLatch) {
-        this.persistLatch = persistLatch;
-    }
-
-    public void setSaveSnapshotLatch(CountDownLatch saveSnapshotLatch) {
-        this.saveSnapshotLatch = saveSnapshotLatch;
-    }
-
-    public void setDeleteSnapshotsLatch(CountDownLatch deleteSnapshotsLatch) {
-        this.deleteSnapshotsLatch = deleteSnapshotsLatch;
-    }
-
-    public void setDeleteMessagesLatch(CountDownLatch deleteMessagesLatch) {
-        this.deleteMessagesLatch = deleteMessagesLatch;
-    }
-
-    @Override
-    public long getLastSequenceNumber() {
-        return -1;
-    }
-}
index f2719bc..8ce090e 100644 (file)
           <instructions>
             <Bundle-Name>${project.groupId}.${project.artifactId}</Bundle-Name>
             <Bundle-Activator>org.opendaylight.controller.cluster.datastore.osgi.Activator</Bundle-Activator>
-            <Export-Package></Export-Package>
+            <Export-Package>
+                org.opendaylight.controller.cluster.datastore;
+                org.opendaylight.controller.cluster.datastore.config;
+                org.opendaylight.controller.cluster.datastore.messages;
+                org.opendaylight.controller.cluster.datastore.utils;
+            </Export-Package>
             <Import-Package>
                 !*snappy;
                 !org.jboss.*;