seperated cluster service from mappingservice.implementation 24/5724/1
authorDavid Goldberg <david.goldberg@contextream.com>
Mon, 24 Mar 2014 07:41:03 +0000 (09:41 +0200)
committerDavid Goldberg <david.goldberg@contextream.com>
Mon, 24 Mar 2014 07:45:16 +0000 (09:45 +0200)
Signed-off-by: David Goldberg <david.goldberg@contextream.com>
mappingservice/api/src/main/java/org/opendaylight/lispflowmapping/interfaces/dao/ILispDAO.java
mappingservice/clusterdao/.gitignore [new file with mode: 0644]
mappingservice/clusterdao/pom.xml [new file with mode: 0644]
mappingservice/clusterdao/src/main/java/org/opendaylight/lispflowmapping/clusterdao/Activator.java [new file with mode: 0644]
mappingservice/clusterdao/src/main/java/org/opendaylight/lispflowmapping/clusterdao/ClusterDAOService.java [moved from mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/dao/ClusterDAOService.java with 97% similarity]
mappingservice/implementation/pom.xml
mappingservice/implementation/src/main/java/org/opendaylight/lispflowmapping/implementation/Activator.java
mappingservice/integrationtest/pom.xml
mappingservice/integrationtest/src/main/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceTestHelper.java
mappingservice/integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java
mappingservice/pom.xml

index 35b6a15f6d801de49f46a745c3c0567085b2628c..452db7a1042534897756b6a6d809a9cbfe59ee7f 100644 (file)
@@ -23,17 +23,6 @@ public interface ILispDAO extends IQueryAll {
      */
     public <K> void put(K key, MappingEntry<?>... values);
 
-    /**
-     * Get a specific value from the DAO.
-     * 
-     * @param key
-     *            The key of the value to fetch
-     * @param valueKey
-     *            The value to fetch
-     * @return The value from the DAO.
-     */
-    public <K, V> V getSpecific(K key, MappingValueKey<V> valueKey);
-
     /**
      * Get a specific value from the DAO.
      * 
@@ -52,7 +41,7 @@ public interface ILispDAO extends IQueryAll {
      *            The key.
      * @return The value from the DAO.
      */
-    public <K> Map<String, ?> get(K key);
+    public <K> Map<String, Object> get(K key);
 
     /**
      * Remove an entry from the DAO
diff --git a/mappingservice/clusterdao/.gitignore b/mappingservice/clusterdao/.gitignore
new file mode 100644 (file)
index 0000000..19b1e1d
--- /dev/null
@@ -0,0 +1,2 @@
+META-INF
+*.launch
diff --git a/mappingservice/clusterdao/pom.xml b/mappingservice/clusterdao/pom.xml
new file mode 100644 (file)
index 0000000..6c8194a
--- /dev/null
@@ -0,0 +1,60 @@
+<?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.lispflowmapping</groupId>
+               <artifactId>mappingservice-parent</artifactId>
+               <version>1.1.3-SNAPSHOT</version>
+               <relativePath>..</relativePath>
+       </parent>
+       <artifactId>mappingservice.clusterdao</artifactId>
+       <packaging>bundle</packaging>
+       <scm>
+               <connection>scm:git:https://git.opendaylight.org/gerrit/p/lispflowmapping.git</connection>
+               <developerConnection>scm:git:ssh://git.opendaylight.org:29418/lispflowmapping.git</developerConnection>
+               <url>https://wiki.opendaylight.org/view/OpenDaylight_Lisp_Flow_Mapping:Main</url>
+               <tag>HEAD</tag>
+       </scm>
+       <build>
+               <plugins>
+                       <plugin>
+                               <groupId>org.apache.felix</groupId>
+                               <artifactId>maven-bundle-plugin</artifactId>
+                               <extensions>true</extensions>
+                               <configuration>
+                                       <instructions>
+                                               <Export-Package>
+                                                       org.opendaylight.lispflowmapping.clusterdao
+                                               </Export-Package>
+                                               <Import-Package>
+                                                       org.apache.felix.dm,
+                                                       org.opendaylight.controller.clustering.services,
+                                                       org.opendaylight.controller.sal.core,
+                                                       org.opendaylight.lispflowmapping.interfaces.dao, org.slf4j
+                                               </Import-Package>
+                                               <Bundle-Activator>
+                                                       org.opendaylight.lispflowmapping.clusterdao.Activator
+                                               </Bundle-Activator>
+                                               <Service-Component>
+                                               </Service-Component>
+                                       </instructions>
+                               </configuration>
+                       </plugin>
+               </plugins>
+       </build>
+       <dependencies>
+               <dependency>
+                       <groupId>org.opendaylight.controller</groupId>
+                       <artifactId>clustering.services</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.lispflowmapping</groupId>
+                       <artifactId>mappingservice.api</artifactId>
+               </dependency>
+               <dependency>
+                       <groupId>equinoxSDK381</groupId>
+                       <artifactId>org.eclipse.osgi</artifactId>
+               </dependency>
+       </dependencies>
+</project>
diff --git a/mappingservice/clusterdao/src/main/java/org/opendaylight/lispflowmapping/clusterdao/Activator.java b/mappingservice/clusterdao/src/main/java/org/opendaylight/lispflowmapping/clusterdao/Activator.java
new file mode 100644 (file)
index 0000000..8865b12
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2014 Contextream, 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.lispflowmapping.clusterdao;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.felix.dm.Component;
+import org.opendaylight.controller.clustering.services.IClusterContainerServices;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
+import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
+import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
+
+/**
+ * Main application activator class for registering the dependencies and
+ * initialising the Mapping Service application.
+ * 
+ */
+
+public class Activator extends ComponentActivatorAbstractBase {
+
+    /**
+     * Function called when the activator starts just after some initializations
+     * are done by the ComponentActivatorAbstractBase.
+     * 
+     */
+    @Override
+    public void init() {
+    }
+
+    /**
+     * Function called when the activator stops just before the cleanup done by
+     * ComponentActivatorAbstractBase
+     * 
+     */
+    @Override
+    public void destroy() {
+    }
+
+    /**
+     * Function that is used to communicate to dependency manager the list of
+     * known implementations for services inside a container
+     * 
+     * 
+     * @return An array containing all the CLASS objects that will be
+     *         instantiated in order to get an fully working implementation
+     *         Object
+     */
+    @Override
+    public Object[] getImplementations() {
+        Object[] res = { ClusterDAOService.class };
+        return res;
+    }
+
+    /**
+     * Function that is called when configuration of the dependencies is
+     * required.
+     * 
+     * @param c
+     *            dependency manager Component object, used for configuring the
+     *            dependencies exported and imported
+     * @param imp
+     *            Implementation class that is being configured, needed as long
+     *            as the same routine can configure multiple implementations
+     * @param containerName
+     *            The containerName being configured, this allow also optional
+     *            per-container different behavior if needed, usually should not
+     *            be the case though.
+     */
+    @Override
+    public void configureInstance(Component c, Object imp, String containerName) {
+        if (imp.equals(ClusterDAOService.class)) {
+            // export the service
+            Dictionary<String, String> props = new Hashtable<String, String>();
+            props.put("name", "clusterosgiservice");
+            c.setInterface(new String[] { ILispDAO.class.getName() }, props);
+            c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
+                    .setCallbacks("setClusterContainerService", "unsetClusterContainerService").setRequired(true));
+        }
+    }
+
+    /**
+     * Method which tells how many Global implementations are supported by the
+     * bundle. This way we can tune the number of components created. This
+     * components will be created ONLY at the time of bundle startup and will be
+     * destroyed only at time of bundle destruction, this is the major
+     * difference with the implementation retrieved via getImplementations where
+     * all of them are assumed to be in a container !
+     * 
+     * 
+     * @return The list of implementations the bundle will support, in Global
+     *         version
+     */
+    @Override
+    protected Object[] getGlobalImplementations() {
+        return null;
+    }
+
+    /**
+     * Configure the dependency for a given instance Global
+     * 
+     * @param c
+     *            Component assigned for this instance, this will be what will
+     *            be used for configuration
+     * @param imp
+     *            implementation to be configured
+     * @param containerName
+     *            container on which the configuration happens
+     */
+    @Override
+    protected void configureGlobalInstance(Component c, Object imp) {
+
+    }
+}
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.lispflowmapping.implementation.dao;
+package org.opendaylight.lispflowmapping.clusterdao;
 
 import java.lang.reflect.ParameterizedType;
 import java.util.EnumSet;
@@ -126,7 +126,7 @@ public class ClusterDAOService implements ILispDAO, IQueryAll {
     }
 
     @SuppressWarnings("unchecked")
-    public <K, V> V getSpecific(K key, MappingValueKey<V> valueKey) {
+    private <K, V> V getSpecific(K key, MappingValueKey<V> valueKey) {
         Map<Object, Map<String, Object>> keysToValues = getTypeMap(key);
         Map<String, Object> keyToValues = keysToValues.get(key);
         if (keyToValues == null) {
@@ -156,7 +156,7 @@ public class ClusterDAOService implements ILispDAO, IQueryAll {
         return getSpecific(key, new MappingValueKey<Object>(valueKey));
     }
 
-    public <K> Map<String, ?> get(K key) {
+    public <K> Map<String, Object> get(K key) {
         Map<Object, Map<String, Object>> keysToValues = getTypeMap(key);
         return keysToValues.get(key);
     }
@@ -198,5 +198,4 @@ public class ClusterDAOService implements ILispDAO, IQueryAll {
     public void setTimeUnit(TimeUnit timeUnit) {
         this.timeUnit = timeUnit;
     }
-
 }
index e559d9ce5c51aaf35f7d44b212d0f4ddb452126e..bb3163e013cbe5303892cba87a991163f43b98c4 100644 (file)
@@ -69,7 +69,6 @@
                                                        org.opendaylight.lispflowmapping.type,
                                                        org.opendaylight.lispflowmapping.type.lisp,
                                                        org.opendaylight.lispflowmapping.type.sbplugin,
-                                                       org.opendaylight.controller.clustering.services,
                                                        javax.crypto,
                                                        javax.crypto.spec,
                                                        org.opendaylight.controller.sal.binding.api,
                        <groupId>org.hamcrest</groupId>
                        <artifactId>hamcrest-core</artifactId>
                </dependency>
-               <dependency>
-                       <groupId>org.opendaylight.controller</groupId>
-                       <artifactId>clustering.services</artifactId>
-               </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>sal</artifactId>
index d89b49ea607a23a3aeed662994694b9ec09d39f0..6984528cc2b573913655eb20b6a1c546ee593a78 100644 (file)
@@ -12,10 +12,8 @@ import java.util.Dictionary;
 import java.util.Hashtable;
 
 import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
-import org.opendaylight.lispflowmapping.implementation.dao.ClusterDAOService;
 import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
 import org.opendaylight.lispflowmapping.interfaces.lisp.IFlowMapping;
 
@@ -56,7 +54,7 @@ public class Activator extends ComponentActivatorAbstractBase {
      */
     @Override
     public Object[] getImplementations() {
-        Object[] res = { LispMappingService.class, ClusterDAOService.class };
+        Object[] res = { LispMappingService.class };
         return res;
     }
 
@@ -86,13 +84,6 @@ public class Activator extends ComponentActivatorAbstractBase {
                     .setRequired(true));
             c.add(createServiceDependency().setService(BindingAwareBroker.class).setRequired(true)
                     .setCallbacks("setBindingAwareBroker", "unsetBindingAwareBroker"));
-        } else if (imp.equals(ClusterDAOService.class)) {
-            // export the service
-            Dictionary<String, String> props = new Hashtable<String, String>();
-            props.put("name", "clusterosgiservice");
-            c.setInterface(new String[] { ILispDAO.class.getName() }, props);
-            c.add(createContainerServiceDependency(containerName).setService(IClusterContainerServices.class)
-                    .setCallbacks("setClusterContainerService", "unsetClusterContainerService").setRequired(true));
         }
     }
 
index aa5278b6754276b938baf2aee7363ce6657eb892..022e1b0bbc804f759063c19f5ac368768e3964a0 100644 (file)
                        <artifactId>mappingservice.northbound</artifactId>
                        <version>${lispflowmapping.version}</version>
                </dependency>
+               <dependency>
+                       <groupId>org.opendaylight.lispflowmapping</groupId>
+                       <artifactId>mappingservice.clusterdao</artifactId>
+                       <version>${lispflowmapping.version}</version>
+               </dependency>
                <dependency>
                        <groupId>org.opendaylight.controller</groupId>
                        <artifactId>containermanager</artifactId>
index 4477267f382e105881b5c0cea1fd04076ed30a7d..a610874e8bc933881f393d78bfbe3d703ed3b830 100644 (file)
@@ -168,17 +168,24 @@ public class MappingServiceTestHelper {
                         .versionAsInProject(), mavenBundle("geminiweb", "org.eclipse.virgo.util.parser.manifest").versionAsInProject(),
 
                 // Our bundles
-                mavenBundle("org.opendaylight.controller", "clustering.stub").versionAsInProject(), mavenBundle("org.opendaylight.controller",
-                        "clustering.services").versionAsInProject(), mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(),
-
-                mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.yangmodel").versionAsInProject(), mavenBundle(
-                        "org.opendaylight.lispflowmapping", "mappingservice.config").versionAsInProject(), mavenBundle(
-                        "org.opendaylight.lispflowmapping", "mappingservice.api").versionAsInProject(), mavenBundle(
-                        "org.opendaylight.lispflowmapping", "mappingservice.implementation").versionAsInProject(), //
+                mavenBundle("org.opendaylight.controller", "clustering.stub").versionAsInProject(), //
+                mavenBundle("org.opendaylight.controller", "clustering.services").versionAsInProject(), //
+                mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(), //
+                mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.yangmodel").versionAsInProject(), //
+                mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.config").versionAsInProject(), //
+                mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.api").versionAsInProject(), //
+                mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.implementation").versionAsInProject(), //
                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.southbound").versionAsInProject(), //
                 mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.northbound").versionAsInProject(), //
 
                 junitBundles());
     }
 
+    public static Option mappingServiceBundlesWithClusterDAO() {
+        return new DefaultCompositeOption( //
+                mappingServiceBundles(), //
+                mavenBundle("org.opendaylight.lispflowmapping", "mappingservice.clusterdao").versionAsInProject() //
+                );
+    }
+
 }
index 507a3215abf92b9614b86ce18df3b4003b41cb50..55bfafbee829d7d4e8f25b222b2d41a792d9122b 100644 (file)
@@ -44,7 +44,7 @@ import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.opendaylight.lispflowmapping.implementation.dao.ClusterDAOService;
+import org.opendaylight.lispflowmapping.clusterdao.ClusterDAOService;
 import org.opendaylight.lispflowmapping.implementation.serializer.LispMessage;
 import org.opendaylight.lispflowmapping.implementation.serializer.MapNotifySerializer;
 import org.opendaylight.lispflowmapping.implementation.serializer.MapRegisterSerializer;
@@ -253,7 +253,7 @@ public class MappingServiceIntegrationTest {
     // Configure the OSGi container
     @Configuration
     public Option[] config() {
-        return options(MappingServiceTestHelper.mappingServiceBundles());
+        return options(MappingServiceTestHelper.mappingServiceBundlesWithClusterDAO());
     }
 
     @Test
index b3cb87048ccbff7928848e4d9839785736315710..a209f71b30d1f2c4b912a4bfa6b1009ccac913ed 100644 (file)
@@ -19,6 +19,7 @@
                <module>yangmodel</module>
                 <module>api</module>
                 <module>config</module>
+                <module>clusterdao</module>
                 <module>implementation</module>
                 <module>southbound</module>
                 <module>northbound</module>