Merge "Wired ClusteredDataStore with Configuration Subsytem"
authorEd Warnicke <eaw@cisco.com>
Sun, 1 Dec 2013 18:13:32 +0000 (18:13 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Sun, 1 Dec 2013 18:13:32 +0000 (18:13 +0000)
17 files changed:
opendaylight/distribution/opendaylight/pom.xml
opendaylight/md-sal/clustered-data-store/implementation/pom.xml
opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/cluster/store/ClusteredDataStoreImplModule.java [new file with mode: 0644]
opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/cluster/store/ClusteredDataStoreImplModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/ClusteredDataStore.java
opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/Activator.java [deleted file]
opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/ClusteredDataStoreImpl.java
opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/ClusteredDataStoreManager.java
opendaylight/md-sal/clustered-data-store/implementation/src/main/yang/odl-sal-dom-clustered-store-cfg.yang [new file with mode: 0644]
opendaylight/md-sal/clustered-data-store/implementation/src/test/java/org/opendaylight/controller/datastore/internal/ActivatorTest.java [deleted file]
opendaylight/md-sal/clustered-data-store/implementation/src/test/java/org/opendaylight/controller/datastore/internal/ClusteredDataStoreImplTest.java
opendaylight/md-sal/clustered-data-store/implementation/src/test/java/org/opendaylight/controller/datastore/internal/ClusteredDataStoreManagerTest.java
opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml
opendaylight/md-sal/clustered-data-store/integrationtest/src/test/java/org/opendaylight/controller/datastore/ClusteredDataStoreIT.java
opendaylight/md-sal/clustered-data-store/integrationtest/src/test/resources/controller.config [new file with mode: 0644]
opendaylight/md-sal/clustered-data-store/integrationtest/src/test/resources/logback.xml
opendaylight/md-sal/sal-dom-broker/src/main/java/org/opendaylight/controller/sal/dom/broker/SchemaServiceImpl.java

index d1b1e736365aaff9ed9aad9ebcafee77083b58a4..9ce668da85a63dd0145daac62a34574a4a8d4054 100644 (file)
           <version>0.1.1-SNAPSHOT</version>
         </dependency>
 
+        <dependency>
+          <groupId>org.opendaylight.controller</groupId>
+          <artifactId>clustered-datastore-implementation</artifactId>
+          <version>0.4.1-SNAPSHOT</version>
+        </dependency>
+
+
         <!-- config-->
         <dependency>
           <groupId>org.opendaylight.controller</groupId>
index a3d11d0374cade2eec78f10440700d3b262754dd..07ff98b9c521324536efdb292d425d933de8332e 100644 (file)
 <?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.0-SNAPSHOT</version>
-      <relativePath>../..</relativePath>
-  </parent>
-  <scm>
-    <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
-    <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
-    <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
-    <tag>HEAD</tag>
-  </scm>
+    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.0-SNAPSHOT</version>
+        <relativePath>../..</relativePath>
+    </parent>
+    <scm>
+        <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+        <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
+        <tag>HEAD</tag>
+    </scm>
 
-  <artifactId>clustered-datastore-implementation</artifactId>
-  <version>0.4.1-SNAPSHOT</version>
-  <packaging>bundle</packaging>
+    <artifactId>clustered-datastore-implementation</artifactId>
+    <version>0.4.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
 
-  <build>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.felix</groupId>
-        <artifactId>maven-bundle-plugin</artifactId>
-        <version>${bundle.plugin.version}</version>
-        <extensions>true</extensions>
-        <configuration>
-          <instructions>
-            <Export-Package>
-              org.opendaylight.controller.datastore
-            </Export-Package>
-            <Import-Package>
-              javax.xml.bind.annotation,
-              org.opendaylight.controller.sal.core,
-              org.opendaylight.controller.sal.utils,
-              org.opendaylight.controller.sal.packet,
-              org.opendaylight.controller.sal.topology,
-              org.opendaylight.controller.clustering.services,
-              org.opendaylight.controller.md.sal.common.api.data,
-              org.opendaylight.controller.sal.common.util,
-              org.opendaylight.yangtools.yang.binding,
-              org.osgi.service.component,
-              org.slf4j,
-              org.apache.felix.dm,
-              org.apache.commons.lang3.builder,
-              org.apache.commons.lang3.tuple,
-              org.eclipse.osgi.framework.console,
-              org.osgi.framework,
-              com.google.common.base
-            </Import-Package>
-            <Bundle-Activator>
-              org.opendaylight.controller.datastore.internal.Activator
-            </Bundle-Activator>
-          </instructions>
-          <manifestLocation>${project.basedir}/META-INF</manifestLocation>
-        </configuration>
-      </plugin>
-    </plugins>
-  </build>
-  <dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>${bundle.plugin.version}</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                    </instructions>
+                    <manifestLocation>${project.basedir}/META-INF</manifestLocation>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+                <version>0.5.9-SNAPSHOT</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>generate-sources</goal>
+                        </goals>
+                        <configuration>
+                            <codeGenerators>
+                                <generator>
+                                    <codeGeneratorClass>
+                                        org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+                                    </codeGeneratorClass>
+                                    <outputBaseDir>${project.build.directory}/generated-sources/config</outputBaseDir>
+                                    <additionalConfiguration>
+                                        <namespaceToPackage1>
+                                            urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang
+                                        </namespaceToPackage1>
+                                    </additionalConfiguration>
+                                </generator>
+                            </codeGenerators>
+                            <inspectDependencies>true</inspectDependencies>
+                        </configuration>
+                    </execution>
+                </executions>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.opendaylight.controller</groupId>
+                        <artifactId>yang-jmx-generator-plugin</artifactId>
+                        <version>0.2.3-SNAPSHOT</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
 
-    <dependency>
-      <groupId>com.google.guava</groupId>
-      <artifactId>guava</artifactId>
-    </dependency>
-    <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>sal-common-api</artifactId>
-        <version>1.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal-common-util</artifactId>
-      <version>1.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal</artifactId>
-      <version>0.5.1-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>clustering.services</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
-    </dependency>
-    <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>equinoxSDK381</groupId>
-      <artifactId>org.eclipse.osgi</artifactId>
-      <version>3.8.1.v20120830-144521</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.yangtools</groupId>
-      <artifactId>yang-binding</artifactId>
-    </dependency>
-  </dependencies>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-core-api</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common-util</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-api</artifactId>
+            <version>0.2.3-SNAPSHOT</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal</artifactId>
+            <version>0.5.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>clustering.services</artifactId>
+            <version>0.4.1-SNAPSHOT</version>
+        </dependency>
+        <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.opendaylight.yangtools</groupId>
+            <artifactId>yang-binding</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-data-api</artifactId>
+        </dependency>
+
+    </dependencies>
 </project>
diff --git a/opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/cluster/store/ClusteredDataStoreImplModule.java b/opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/cluster/store/ClusteredDataStoreImplModule.java
new file mode 100644 (file)
index 0000000..5038cae
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+* Generated file
+
+* Generated from: yang module name: odl-sal-dom-clustered-store-cfg  yang module local name: dom-clustered-store-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 27 17:09:17 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.dom.cluster.store;
+
+import org.opendaylight.controller.datastore.internal.ClusteredDataStoreManager;
+import org.osgi.framework.BundleContext;
+
+/**
+*
+*/
+public final class ClusteredDataStoreImplModule extends org.opendaylight.controller.config.yang.md.sal.dom.cluster.store.AbstractClusteredDataStoreImplModule
+{
+
+    private BundleContext bundleContext;
+
+    public ClusteredDataStoreImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public ClusteredDataStoreImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, ClusteredDataStoreImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void validate(){
+        super.validate();
+        // Add custom validation for module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        ClusteredDataStoreManager manager = new ClusteredDataStoreManager();
+        manager.setContext(bundleContext);
+        manager.start();
+        return manager;
+    }
+
+    public void setBundleContext(BundleContext bundleContext) {
+        this.bundleContext = bundleContext;
+    }
+}
diff --git a/opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/cluster/store/ClusteredDataStoreImplModuleFactory.java b/opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/config/yang/md/sal/dom/cluster/store/ClusteredDataStoreImplModuleFactory.java
new file mode 100644 (file)
index 0000000..8a926eb
--- /dev/null
@@ -0,0 +1,40 @@
+/**
+* Generated file
+
+* Generated from: yang module name: odl-sal-dom-clustered-store-cfg  yang module local name: dom-clustered-store-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Nov 27 17:09:17 CET 2013
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.md.sal.dom.cluster.store;
+
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.DynamicMBeanWithInstance;
+import org.opendaylight.controller.config.spi.Module;
+import org.osgi.framework.BundleContext;
+
+/**
+*
+*/
+public class ClusteredDataStoreImplModuleFactory extends org.opendaylight.controller.config.yang.md.sal.dom.cluster.store.AbstractClusteredDataStoreImplModuleFactory
+{
+
+    @Override
+    public Module createModule(String instanceName, DependencyResolver dependencyResolver, BundleContext bundleContext) {
+        ClusteredDataStoreImplModule module = 
+        (ClusteredDataStoreImplModule) super.createModule(instanceName, dependencyResolver, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+    
+    @Override
+    public Module createModule(String instanceName, DependencyResolver dependencyResolver,
+            DynamicMBeanWithInstance old, BundleContext bundleContext) throws Exception {
+        ClusteredDataStoreImplModule module = 
+                (ClusteredDataStoreImplModule) super.createModule(instanceName, dependencyResolver, old, bundleContext);
+        module.setBundleContext(bundleContext);
+        return module;
+    }
+
+}
index 0a577ad999ac2a660da158ddbf78550bc1bdecf5..1aecb967f14fbfb1b0949db83e1a5e7a7676c84b 100644 (file)
@@ -12,7 +12,11 @@ package org.opendaylight.controller.datastore;
 
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
 import org.opendaylight.controller.md.sal.common.api.data.DataReader;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.controller.sal.core.api.data.DataStore;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+
+public interface ClusteredDataStore extends DataStore {
+
 
-public interface ClusteredDataStore extends DataReader<InstanceIdentifier<? extends Object>, Object>, DataCommitHandler<InstanceIdentifier<? extends Object>,Object> {
 }
diff --git a/opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/Activator.java b/opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/Activator.java
deleted file mode 100644 (file)
index c94355d..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-
-/*
- * Copyright (c) 2013 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.datastore.internal;
-
-import org.apache.felix.dm.Component;
-import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
-import org.opendaylight.controller.datastore.ClusteredDataStore;
-import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Set;
-
-public class Activator extends ComponentActivatorAbstractBase {
-    protected static final Logger logger = LoggerFactory
-            .getLogger(Activator.class);
-
-
-    @Override
-    protected Object[] getGlobalImplementations(){
-       logger.debug("Calling getGlobalImplementations to return:", ClusteredDataStoreManager.class);
-        return new Object[] {
-            ClusteredDataStoreManager.class
-        };
-    }
-
-
-    @Override
-    protected void configureGlobalInstance(Component c, Object imp){
-        if (imp.equals(ClusteredDataStoreManager.class)) {
-            Dictionary<String, Set<String>> props = new Hashtable<String, Set<String>>();
-
-            c.setInterface(new String[] { ClusteredDataStore.class.getName() }, props);
-            logger.debug("configureGlobalInstance adding dependency:", IClusterGlobalServices.class);
-            
-            c.add(createServiceDependency().setService(
-                    IClusterGlobalServices.class).setCallbacks(
-                    "setClusterGlobalServices",
-                    "unsetClusterGlobalServices").setRequired(true));
-
-        }
-    }
-
-
-}
index 18b98925637cb1c2d5fc9dbfd39a8c0a72001a48..5449c839f5082e7be1ff6321f886e4965789db68 100644 (file)
@@ -10,6 +10,7 @@
 package org.opendaylight.controller.datastore.internal;
 
 import com.google.common.base.Preconditions;
+
 import org.opendaylight.controller.clustering.services.CacheConfigException;
 import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
@@ -17,9 +18,12 @@ import org.opendaylight.controller.clustering.services.IClusterServices;
 import org.opendaylight.controller.datastore.ClusteredDataStore;
 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
 import org.opendaylight.controller.sal.common.util.Rpcs;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.util.Collections;
 import java.util.EnumSet;
@@ -35,54 +39,74 @@ public class ClusteredDataStoreImpl implements ClusteredDataStore {
     public static final String OPERATIONAL_DATA_CACHE = "clustered_data_store.operational_data_cache";
     public static final String CONFIGURATION_DATA_CACHE = "clustered_data_store.configuration_data_cache";
 
-    private final ConcurrentMap operationalDataCache;
-    private final ConcurrentMap configurationDataCache;
+    private final ConcurrentMap<InstanceIdentifier, CompositeNode> operationalDataCache;
+    private final ConcurrentMap<InstanceIdentifier, CompositeNode> configurationDataCache;
+
+    private Logger logger = LoggerFactory.getLogger(ClusteredDataStoreImpl.class);
 
-    public ClusteredDataStoreImpl(IClusterGlobalServices clusterGlobalServices) throws CacheExistException, CacheConfigException {
+    public ClusteredDataStoreImpl(IClusterGlobalServices clusterGlobalServices) throws CacheConfigException {
+        logger.info("Constructing clustered data store");
         Preconditions.checkNotNull(clusterGlobalServices, "clusterGlobalServices cannot be null");
 
         operationalDataCache = getOrCreateCache(clusterGlobalServices, OPERATIONAL_DATA_CACHE);
 
-        if(operationalDataCache == null){
-            Preconditions.checkNotNull(operationalDataCache, "operationalDataCache cannot be null");
-        }
+        Preconditions.checkNotNull(operationalDataCache, "operationalDataCache cannot be null");
 
         configurationDataCache = getOrCreateCache(clusterGlobalServices, CONFIGURATION_DATA_CACHE);
 
-        if(configurationDataCache == null){
-            Preconditions.checkNotNull(configurationDataCache, "configurationDataCache cannot be null");
-        }
-
+        Preconditions.checkNotNull(configurationDataCache, "configurationDataCache cannot be null");
     }
 
     @Override
-    public DataCommitTransaction<InstanceIdentifier<? extends Object>, Object> requestCommit(DataModification<InstanceIdentifier<? extends Object>, Object> modification) {
+    public DataCommitTransaction<InstanceIdentifier, CompositeNode> requestCommit(DataModification<InstanceIdentifier, CompositeNode> modification) {
         return new ClusteredDataStoreTransaction(modification);
     }
 
     @Override
-    public Object readOperationalData(InstanceIdentifier<? extends Object> path) {
+    public CompositeNode readOperationalData(InstanceIdentifier path) {
         Preconditions.checkNotNull(path, "path cannot be null");
         return operationalDataCache.get(path);
     }
 
     @Override
-    public Object readConfigurationData(InstanceIdentifier<? extends Object> path) {
+    public boolean containsConfigurationPath(InstanceIdentifier path) {
+        return configurationDataCache.containsKey(path);
+    }
+    
+    @Override
+    public boolean containsOperationalPath(InstanceIdentifier path) {
+        return operationalDataCache.containsKey(path);
+    }
+    
+    @Override
+    public Iterable<InstanceIdentifier> getStoredConfigurationPaths() {
+        return configurationDataCache.keySet();
+    }
+    
+    @Override
+    public Iterable<InstanceIdentifier> getStoredOperationalPaths() {
+        return operationalDataCache.keySet();
+    }
+    
+    
+    
+    @Override
+    public CompositeNode readConfigurationData(InstanceIdentifier path) {
         Preconditions.checkNotNull(path, "path cannot be null");
         return configurationDataCache.get(path);
     }
 
     private RpcResult<Void> finish(final ClusteredDataStoreTransaction transaction) {
-      final DataModification<InstanceIdentifier<? extends Object>,Object> modification = transaction.getModification();
+      final DataModification<InstanceIdentifier,CompositeNode> modification = transaction.getModification();
 
       this.configurationDataCache.putAll(modification.getUpdatedConfigurationData());
       this.operationalDataCache.putAll(modification.getUpdatedOperationalData());
 
-      for (final InstanceIdentifier<? extends Object> removal : modification.getRemovedConfigurationData()) {
+      for (final InstanceIdentifier removal : modification.getRemovedConfigurationData()) {
         this.configurationDataCache.remove(removal);
       }
 
-      for (final InstanceIdentifier<? extends Object> removal : modification.getRemovedOperationalData()) {
+      for (final InstanceIdentifier removal : modification.getRemovedOperationalData()) {
         this.operationalDataCache.remove(removal  );
       }
 
@@ -109,17 +133,17 @@ public class ClusteredDataStoreImpl implements ClusteredDataStore {
         return cache;
     }
 
-    private class ClusteredDataStoreTransaction implements DataCommitTransaction<InstanceIdentifier<? extends Object>, Object> {
-        private final DataModification<InstanceIdentifier<? extends Object>,Object> modification;
+    private class ClusteredDataStoreTransaction implements DataCommitTransaction<InstanceIdentifier, CompositeNode> {
+        private final DataModification<InstanceIdentifier,CompositeNode> modification;
 
-        public ClusteredDataStoreTransaction(DataModification<InstanceIdentifier<? extends Object>,Object> modification){
+        public ClusteredDataStoreTransaction(DataModification<InstanceIdentifier,CompositeNode> modification){
             Preconditions.checkNotNull(modification, "modification cannot be null");
 
             this.modification = modification;
         }
 
         @Override
-        public DataModification<InstanceIdentifier<? extends Object>, Object> getModification() {
+        public DataModification<InstanceIdentifier, CompositeNode> getModification() {
             return this.modification;
         }
 
index e6acdb0c3be0a0221c63a014bf11d7bcaeeb00ce..b0a099ff90e0e26f1fd408f6574c718529673590 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-
-
 package org.opendaylight.controller.datastore.internal;
 
+import java.util.Hashtable;
+
 import com.google.common.base.Preconditions;
-import org.apache.felix.dm.Component;
+
 import org.opendaylight.controller.clustering.services.CacheConfigException;
-import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
 import org.opendaylight.controller.datastore.ClusteredDataStore;
 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+import org.osgi.util.tracker.ServiceTrackerCustomizer;
 
-public class ClusteredDataStoreManager implements ClusteredDataStore {
+public class ClusteredDataStoreManager implements //
+        ClusteredDataStore, //
+        ServiceTrackerCustomizer<IClusterGlobalServices, IClusterGlobalServices>, //
+        AutoCloseable {
 
-    private ClusteredDataStoreImpl clusteredDataStore = null;
+    private ClusteredDataStore clusteredDataStore = null;
     private IClusterGlobalServices clusterGlobalServices = null;
+    private BundleContext context;
+
+    private ServiceReference<IClusterGlobalServices> firstClusterGlobalReference;
+    private ServiceTracker<IClusterGlobalServices, IClusterGlobalServices> clusterTracker;
 
     @Override
-    public DataCommitTransaction<InstanceIdentifier<? extends Object>, Object> requestCommit(DataModification<InstanceIdentifier<? extends Object>, Object> modification) {
+    public DataCommitTransaction<InstanceIdentifier, CompositeNode> requestCommit(
+            DataModification<InstanceIdentifier, CompositeNode> modification) {
         Preconditions.checkState(clusteredDataStore != null, "clusteredDataStore cannot be null");
         return clusteredDataStore.requestCommit(modification);
     }
 
     @Override
-    public Object readOperationalData(InstanceIdentifier<? extends Object> path) {
+    public CompositeNode readOperationalData(InstanceIdentifier path) {
         Preconditions.checkState(clusteredDataStore != null, "clusteredDataStore cannot be null");
         return clusteredDataStore.readOperationalData(path);
     }
 
     @Override
-    public Object readConfigurationData(InstanceIdentifier<? extends Object> path) {
+    public CompositeNode readConfigurationData(InstanceIdentifier path) {
         Preconditions.checkState(clusteredDataStore != null, "clusteredDataStore cannot be null");
         return clusteredDataStore.readConfigurationData(path);
     }
 
+    public Iterable<InstanceIdentifier> getStoredConfigurationPaths() {
+        Preconditions.checkState(clusteredDataStore != null, "clusteredDataStore cannot be null");
+        return clusteredDataStore.getStoredConfigurationPaths();
+    }
+
+    public Iterable<InstanceIdentifier> getStoredOperationalPaths() {
+        Preconditions.checkState(clusteredDataStore != null, "clusteredDataStore cannot be null");
+        return clusteredDataStore.getStoredOperationalPaths();
+    }
 
-    public void setClusterGlobalServices(IClusterGlobalServices clusterGlobalServices){
+    public boolean containsConfigurationPath(InstanceIdentifier path) {
+        Preconditions.checkState(clusteredDataStore != null, "clusteredDataStore cannot be null");
+        return clusteredDataStore.containsConfigurationPath(path);
+    }
+
+    public boolean containsOperationalPath(InstanceIdentifier path) {
+        Preconditions.checkState(clusteredDataStore != null, "clusteredDataStore cannot be null");
+        return clusteredDataStore.containsOperationalPath(path);
+    }
+
+    public void setClusterGlobalServices(IClusterGlobalServices clusterGlobalServices) {
         this.clusterGlobalServices = clusterGlobalServices;
+        try {
+            // Adding creation of the clustered data store in its own method
+            // to make the method unit testable
+            clusteredDataStore = createClusteredDataStore();
+        } catch (CacheConfigException e) {
+            throw new IllegalStateException("could not construct clusteredDataStore");
+        }
     }
 
-    public void unsetClusterGlobalServices(IClusterGlobalServices clusterGlobalServices){
-        this.clusterGlobalServices = null;
-        this.clusteredDataStore = null;
+    @Override
+    public IClusterGlobalServices addingService(ServiceReference<IClusterGlobalServices> reference) {
+        if (clusterGlobalServices == null) {
+            setClusterGlobalServices(context.getService(reference));
+            return clusterGlobalServices;
+        }
+        return null;
+    }
+
+    @Override
+    public void modifiedService(ServiceReference<IClusterGlobalServices> reference, IClusterGlobalServices service) {
+
+    }
+
+    @Override
+    public void removedService(ServiceReference<IClusterGlobalServices> reference, IClusterGlobalServices service) {
+        if (clusterGlobalServices == service) {
+            clusterGlobalServices = null;
+            clusteredDataStore = null;
+        }
     }
 
+    public BundleContext getContext() {
+        return context;
+    }
 
+    public void setContext(BundleContext context) {
+        this.context = context;
+    }
+    
+    
     /**
      * Function called by the dependency manager when all the required
      * dependencies are satisfied
-     *
+     * 
      */
-    void init(Component c) {
-        try {
-               //Adding creation of the clustered data store in its own method to make the method unit testable
-            clusteredDataStore = createClusteredDataStore(c);
-        } catch (CacheExistException e) {
-            throw new IllegalStateException("could not construct clusteredDataStore");
-        } catch (CacheConfigException e) {
-            throw new IllegalStateException("could not construct clusteredDataStore");
+    public void start() {
+        if (context != null) {
+            clusterTracker = new ServiceTracker<>(context, IClusterGlobalServices.class, this);
+            clusterTracker.open();
+            
+            context.registerService(ClusteredDataStore.class, this, new Hashtable<String,Object>());
         }
     }
-    protected ClusteredDataStoreImpl createClusteredDataStore(Component c) throws CacheExistException,CacheConfigException{
-       return  new ClusteredDataStoreImpl(clusterGlobalServices);
+
+    protected ClusteredDataStore createClusteredDataStore() throws CacheConfigException {
+        return new ClusteredDataStoreImpl(clusterGlobalServices);
+    }
+
+    @Override
+    public void close() throws Exception {
+        clusterTracker.close();
     }
 }
diff --git a/opendaylight/md-sal/clustered-data-store/implementation/src/main/yang/odl-sal-dom-clustered-store-cfg.yang b/opendaylight/md-sal/clustered-data-store/implementation/src/main/yang/odl-sal-dom-clustered-store-cfg.yang
new file mode 100644 (file)
index 0000000..95a26d7
--- /dev/null
@@ -0,0 +1,29 @@
+module odl-sal-dom-clustered-store-cfg {
+       yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:cluster:store";
+    prefix "binding-impl";
+
+       import config { prefix config; revision-date 2013-04-05; }
+       import opendaylight-md-sal-dom {prefix sal;}
+
+    description
+        "Service definition for MD-SAL Clustered Store.";
+    revision "2013-10-28" {
+        description
+            "Initial revision";
+    }
+
+    identity dom-clustered-store-impl {
+        base config:module-type;
+        config:provided-service sal:dom-data-store;
+        config:java-name-prefix ClusteredDataStoreImpl;
+    }
+
+    augment "/config:modules/config:module/config:state" {
+        case dom-clustered-store-impl {
+            when "/config:modules/config:module/config:type = 'dom-clustered-store-impl'";
+        }
+    }
+    
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/clustered-data-store/implementation/src/test/java/org/opendaylight/controller/datastore/internal/ActivatorTest.java b/opendaylight/md-sal/clustered-data-store/implementation/src/test/java/org/opendaylight/controller/datastore/internal/ActivatorTest.java
deleted file mode 100644 (file)
index 5ced9d9..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-
-/*
- * Copyright (c) 2013 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.datastore.internal;
-
-import org.apache.felix.dm.Component;
-import org.apache.felix.dm.ServiceDependency;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
-
-import static junit.framework.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
-public class ActivatorTest {
-
-       private static  ServiceDependency serviceDependency;
-       
-       @BeforeClass 
-       public static void initialize(){
-               serviceDependency = mock(ServiceDependency.class);
-       }
-       
-       private class ActivatorTestImpl extends Activator{
-                protected ServiceDependency createServiceDependency() {
-                       return ActivatorTest.serviceDependency;
-                   }
-       }
-       
-    @Test
-    public void construct(){
-        assertNotNull(new Activator());
-    }
-    
-    @Test
-    public void construct_OnInvokeOfGlobalImpl_ShouldReturnNotNullObject(){
-        Activator activator = new Activator();
-        
-        assertNotNull(activator.getGlobalImplementations());
-        assertEquals(ClusteredDataStoreManager.class,activator.getGlobalImplementations()[0]);
-    }
-    
-    @Test
-    public void construct_OnInvokeOfConfigGlobalInstance_ShouldNotThrowAnyExceptions(){
-       Activator activator = new ActivatorTestImpl();
-       
-       Component c = mock(Component.class);
-       Object clusterDataStoreMgr = ClusteredDataStoreManager.class;
-       
-       when(serviceDependency.setService(IClusterGlobalServices.class)).thenReturn(serviceDependency);
-       when(serviceDependency.setCallbacks("setClusterGlobalServices",
-                    "unsetClusterGlobalServices")).thenReturn(serviceDependency);
-       when(serviceDependency.setRequired(true)).thenReturn(serviceDependency);
-       
-       
-       activator.configureGlobalInstance(c, clusterDataStoreMgr);
-       
-       
-    }
-    
-}
index d7ae4bf2e5d18797f092acb274dab972bd90bbd1..0323df6e2dca6c4b9f77ed56cb6aa16119b9e00c 100644 (file)
@@ -9,7 +9,8 @@ import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
 import org.opendaylight.controller.clustering.services.IClusterServices;
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler;
 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 
 import java.util.EnumSet;
 import java.util.Map;
@@ -127,9 +128,9 @@ public class ClusteredDataStoreImplTest {
 
         IClusterGlobalServices mockClusterGlobalServices = createClusterGlobalServices();
 
-        ConcurrentMap mockOperationalDataCache = mock(ConcurrentMap.class);
+        ConcurrentMap<InstanceIdentifier, CompositeNode> mockOperationalDataCache = mock(ConcurrentMap.class);
 
-        Object valueObject = mock(Object.class);
+        CompositeNode valueObject = mock(CompositeNode.class);
 
         when(mockOperationalDataCache.get(path)).thenReturn(valueObject);
 
@@ -176,9 +177,9 @@ public class ClusteredDataStoreImplTest {
 
         IClusterGlobalServices mockClusterGlobalServices = createClusterGlobalServices();
 
-        ConcurrentMap mockConfigurationDataCache = mock(ConcurrentMap.class);
+        ConcurrentMap<InstanceIdentifier, CompositeNode> mockConfigurationDataCache = mock(ConcurrentMap.class);
 
-        Object valueObject = mock(Object.class);
+        CompositeNode valueObject = mock(CompositeNode.class);
 
         when(mockConfigurationDataCache.get(path)).thenReturn(valueObject);
 
@@ -223,7 +224,7 @@ public class ClusteredDataStoreImplTest {
         when(mockModification.getUpdatedConfigurationData()).thenReturn(configurationData);
         when(mockModification.getUpdatedOperationalData()).thenReturn(operationalData);
 
-        DataCommitHandler.DataCommitTransaction<InstanceIdentifier<? extends Object>, Object> transaction = store.requestCommit(mockModification);
+        DataCommitHandler.DataCommitTransaction<InstanceIdentifier, CompositeNode> transaction = store.requestCommit(mockModification);
 
         transaction.finish();
 
@@ -252,7 +253,7 @@ public class ClusteredDataStoreImplTest {
         when(mockModification.getUpdatedConfigurationData()).thenReturn(configurationData);
         when(mockModification.getUpdatedOperationalData()).thenReturn(operationalData);
 
-        DataCommitHandler.DataCommitTransaction<InstanceIdentifier<? extends Object>, Object> transaction = store.requestCommit(mockModification);
+        DataCommitHandler.DataCommitTransaction<InstanceIdentifier, CompositeNode> transaction = store.requestCommit(mockModification);
 
         transaction.rollback();
 
index 5609134a1a672c4c7eda1e3e3928ab1ca4af75da..10f9622c7ae981ea5e095f59789e2596d20f7cba 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
  *
@@ -9,6 +8,8 @@
 
 package org.opendaylight.controller.datastore.internal;
 
+import java.util.concurrent.ConcurrentHashMap;
+
 import org.apache.felix.dm.Component;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -17,7 +18,8 @@ import org.opendaylight.controller.clustering.services.CacheExistException;
 import org.opendaylight.controller.clustering.services.IClusterGlobalServices;
 import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 
 import static junit.framework.Assert.assertNotNull;
 import static org.junit.Assert.assertEquals;
@@ -29,103 +31,78 @@ import static org.mockito.Mockito.spy;
 import static org.mockito.Mockito.when;
 
 public class ClusteredDataStoreManagerTest {
-       
-       private  static ClusteredDataStoreManager clusteredDSMgr = null;
-       private IClusterGlobalServices icClusterGlbServices =  mock(IClusterGlobalServices.class);
-        
-       @BeforeClass
-       public static void construct(){
-               clusteredDSMgr = new ClusteredDataStoreManager();
+
+    private static ClusteredDataStoreManager clusteredDSMgr = null;
+    private IClusterGlobalServices icClusterGlbServices = mock(IClusterGlobalServices.class);
+
+    @BeforeClass
+    public static void construct() {
+        clusteredDSMgr = new ClusteredDataStoreManager();
         assertNotNull(clusteredDSMgr);
-       }
-        
-       @Test
-       public void construct_OnSetClusterGlobalServices_AssertNoException(){
-               icClusterGlbServices =  mock(IClusterGlobalServices.class);
-                
-               clusteredDSMgr.setClusterGlobalServices(icClusterGlbServices);
-        }
-        
-        @Test
-        public void construct_OnUnSetClusterGlobalServices_AssertNoException(){
-                IClusterGlobalServices icClusterGlbServices =  mock(IClusterGlobalServices.class);
-                
-                clusteredDSMgr.unsetClusterGlobalServices(icClusterGlbServices);
-        }
-        
-        @Test
-        public void construct_init_AssertNoException() throws CacheExistException,CacheConfigException{
-                ClusteredDataStoreImpl clusteredDSImpl =  mock(ClusteredDataStoreImpl.class);
-                
-                ClusteredDataStoreManager clusteredDSManager = spy(new ClusteredDataStoreManager());
-                doReturn(clusteredDSImpl).when(clusteredDSManager).createClusteredDataStore(any(Component.class));
-                Component c = mock(Component.class);
-                
-                clusteredDSManager.init(c);
-        }
-        
-        @Test(expected = IllegalStateException.class)
-        public void construct_init_AssertCacheExistException() throws CacheExistException,CacheConfigException{
-                ClusteredDataStoreManager clusteredDSManager = spy(new ClusteredDataStoreManager());
-                doThrow(CacheExistException.class).when(clusteredDSManager).createClusteredDataStore(any(Component.class));
-                Component c = mock(Component.class);
-                
-                clusteredDSManager.init(c);
-        }
-        
-        @Test(expected = IllegalStateException.class)
-        public void construct_init_AssertCacheConfigException() throws CacheExistException,CacheConfigException{
-                ClusteredDataStoreManager clusteredDSManager = spy(new ClusteredDataStoreManager());
-                doThrow(CacheConfigException.class).when(clusteredDSManager).createClusteredDataStore(any(Component.class));
-                Component c = mock(Component.class);
-                
-                clusteredDSManager.init(c);
-        }
-        
-        @Test
-        public void construct_readOperationalData_AssertNoException() throws CacheExistException,CacheConfigException{
-                ClusteredDataStoreImpl clusteredDSImpl =  mock(ClusteredDataStoreImpl.class);
-                
-                ClusteredDataStoreManager clusteredDSManager = spy(new ClusteredDataStoreManager());
-                doReturn(clusteredDSImpl).when(clusteredDSManager).createClusteredDataStore(any(Component.class));
-                Component c = mock(Component.class);
-                
-                clusteredDSManager.init(c);
-                
-                Object o = mock(Object.class);
-                
-                when(clusteredDSImpl.readOperationalData(any(InstanceIdentifier.class))).thenReturn(o);
-                assertEquals(o,clusteredDSManager.readOperationalData(any(InstanceIdentifier.class)));
-        }
-        
-        
-        @Test
-        public void construct_readConfigurationData_AssertNoException() throws CacheExistException,CacheConfigException{
-                ClusteredDataStoreImpl clusteredDSImpl =  mock(ClusteredDataStoreImpl.class);
-                
-                ClusteredDataStoreManager clusteredDSManager = spy(new ClusteredDataStoreManager());
-                doReturn(clusteredDSImpl).when(clusteredDSManager).createClusteredDataStore(any(Component.class));
-                Component c = mock(Component.class);
-                
-                clusteredDSManager.init(c);
-                Object o = mock(Object.class);
-                
-                when(clusteredDSImpl.readConfigurationData(any(InstanceIdentifier.class))).thenReturn(o);
-                assertEquals(o,clusteredDSManager.readConfigurationData(any(InstanceIdentifier.class)));
-        }
-        
-        @Test
-        public void construct_requestCommit_AssertNoException() throws CacheExistException,CacheConfigException{
-                ClusteredDataStoreImpl clusteredDSImpl =  mock(ClusteredDataStoreImpl.class);
-                
-                ClusteredDataStoreManager clusteredDSManager = spy(new ClusteredDataStoreManager());
-                doReturn(clusteredDSImpl).when(clusteredDSManager).createClusteredDataStore(any(Component.class));
-                Component c = mock(Component.class);
-                
-                clusteredDSManager.init(c);
-                DataCommitTransaction dataCommitTransaction = mock(DataCommitTransaction.class);
-                
-                when(clusteredDSImpl.requestCommit(any(DataModification.class))).thenReturn(dataCommitTransaction);
-                assertEquals(dataCommitTransaction,clusteredDSManager.requestCommit(any(DataModification.class)));
-        }
+    }
+
+    @Test
+    public void construct_OnSetClusterGlobalServices_AssertNoException() {
+        doReturn(new ConcurrentHashMap<InstanceIdentifier, CompositeNode>()).when(icClusterGlbServices).getCache(ClusteredDataStoreImpl.CONFIGURATION_DATA_CACHE);
+        doReturn(new ConcurrentHashMap<InstanceIdentifier, CompositeNode>()).when(icClusterGlbServices).getCache(ClusteredDataStoreImpl.OPERATIONAL_DATA_CACHE);
+        clusteredDSMgr.setClusterGlobalServices(icClusterGlbServices);
+    }
+
+    @Test
+    public void construct_init_AssertNoException() throws CacheExistException, CacheConfigException {
+        ClusteredDataStoreImpl clusteredDSImpl = mock(ClusteredDataStoreImpl.class);
+
+        ClusteredDataStoreManager clusteredDSManager = spy(new ClusteredDataStoreManager());
+        doReturn(clusteredDSImpl).when(clusteredDSManager).createClusteredDataStore();
+        clusteredDSManager.start();
+    }
+
+
+    @Test
+    public void construct_readOperationalData_AssertNoException() throws CacheExistException, CacheConfigException {
+        ClusteredDataStoreImpl clusteredDSImpl = mock(ClusteredDataStoreImpl.class);
+
+        ClusteredDataStoreManager clusteredDSManager = spy(new ClusteredDataStoreManager());
+        doReturn(clusteredDSImpl).when(clusteredDSManager).createClusteredDataStore();
+        Component c = mock(Component.class);
+        
+        clusteredDSManager.start();
+        clusteredDSManager.setClusterGlobalServices(icClusterGlbServices);
+        CompositeNode o = mock(CompositeNode.class);
+
+        when(clusteredDSImpl.readOperationalData(any(InstanceIdentifier.class))).thenReturn(o);
+        assertEquals(o, clusteredDSManager.readOperationalData(any(InstanceIdentifier.class)));
+    }
+
+    @Test
+    public void construct_readConfigurationData_AssertNoException() throws CacheExistException, CacheConfigException {
+        ClusteredDataStoreImpl clusteredDSImpl = mock(ClusteredDataStoreImpl.class);
+
+        ClusteredDataStoreManager clusteredDSManager = spy(new ClusteredDataStoreManager());
+        doReturn(clusteredDSImpl).when(clusteredDSManager).createClusteredDataStore();
+        Component c = mock(Component.class);
+
+        clusteredDSManager.start();
+        clusteredDSManager.setClusterGlobalServices(icClusterGlbServices);
+        
+        CompositeNode o = mock(CompositeNode.class);
+
+        when(clusteredDSImpl.readConfigurationData(any(InstanceIdentifier.class))).thenReturn(o);
+        assertEquals(o, clusteredDSManager.readConfigurationData(any(InstanceIdentifier.class)));
+    }
+
+    @Test
+    public void construct_requestCommit_AssertNoException() throws CacheExistException, CacheConfigException {
+        ClusteredDataStoreImpl clusteredDSImpl = mock(ClusteredDataStoreImpl.class);
+
+        ClusteredDataStoreManager clusteredDSManager = spy(new ClusteredDataStoreManager());
+        doReturn(clusteredDSImpl).when(clusteredDSManager).createClusteredDataStore();
+        IClusterGlobalServices globalServices = mock(IClusterGlobalServices.class);
+        clusteredDSManager.setClusterGlobalServices(globalServices);
+        clusteredDSManager.start();
+        DataCommitTransaction dataCommitTransaction = mock(DataCommitTransaction.class);
+
+        when(clusteredDSImpl.requestCommit(any(DataModification.class))).thenReturn(dataCommitTransaction);
+        assertEquals(dataCommitTransaction, clusteredDSManager.requestCommit(any(DataModification.class)));
+    }
 }
index 9615decbe9fed710acc0c6674ec0eff3d020ee9d..968f87a40200c1bbf86ef7a196f92b8d96f9e8f4 100644 (file)
 <?xml version="1.0" encoding="UTF-8"?>
 <project
-  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
-  xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.opendaylight.controller</groupId>
-    <artifactId>commons.integrationtest</artifactId>
-    <version>0.5.1-SNAPSHOT</version>
-    <relativePath>../../../commons/integrationtest</relativePath>
-  </parent>
-  <scm>
-    <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
-    <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
-    <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
-  </scm>
-
-  <artifactId>clustered-datastore.integrationtest</artifactId>
-  <version>0.4.0-SNAPSHOT</version>
-  <dependencies>
-
-      <dependency>
-        <groupId>com.google.guava</groupId>
-        <artifactId>guava</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal-common-api</artifactId>
-          <version>1.0-SNAPSHOT</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>sal-common-util</artifactId>
-        <version>1.0-SNAPSHOT</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>sal-common-impl</artifactId>
-        <version>1.0-SNAPSHOT</version>
-      </dependency>
-      <dependency>
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
         <groupId>org.opendaylight.controller</groupId>
-        <artifactId>sal-binding-broker-impl</artifactId>
-        <version>1.0-SNAPSHOT</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>sal</artifactId>
+        <artifactId>commons.integrationtest</artifactId>
         <version>0.5.1-SNAPSHOT</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.controller</groupId>
-        <artifactId>clustering.services</artifactId>
-        <version>0.4.1-SNAPSHOT</version>
-      </dependency>
-      <dependency>
-        <groupId>org.opendaylight.yangtools</groupId>
-        <artifactId>yang-binding</artifactId>
-      </dependency>
-
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>protocol_plugins.stub</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
-    </dependency>
-     <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>sal.implementation</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>containermanager</artifactId>
-      <version>0.5.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>containermanager.it.implementation</artifactId>
-      <version>0.5.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>clustering.stub</artifactId>
-      <version>0.4.0-SNAPSHOT</version>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller</groupId>
-      <artifactId>clustered-datastore-implementation</artifactId>
-      <version>0.4.1-SNAPSHOT</version>
-    </dependency>
+        <relativePath>../../../commons/integrationtest</relativePath>
+    </parent>
+    <scm>
+        <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+        <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+        <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main</url>
+    </scm>
 
-      <dependency>
-          <groupId>org.opendaylight.controller</groupId>
-          <artifactId>sal-common</artifactId>
-          <version>1.0-SNAPSHOT</version>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.yangtools</groupId>
-          <artifactId>yang-common</artifactId>
-      </dependency>
-      <dependency>
-          <groupId>org.opendaylight.yangtools</groupId>
-          <artifactId>concepts</artifactId>
-          <version>0.1.1-SNAPSHOT</version>
-      </dependency>
-      <dependency>
-       <groupId>org.mockito</groupId>
-       <artifactId>mockito-all</artifactId>
-       <version>1.9.5</version>
-       <scope>test</scope>
-      </dependency>
-      <dependency>
-          <groupId>org.osgi</groupId>
-          <artifactId>org.osgi.core</artifactId>
-          <version>5.0.0</version>
-      </dependency>
+    <artifactId>clustered-datastore.integrationtest</artifactId>
+    <version>0.4.0-SNAPSHOT</version>
+    <dependencies>
 
-</dependencies>
-  <properties>
-    <!-- Sonar jacoco plugin to get integration test coverage info -->
-    <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
-    <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
-  </properties>
-  <build>
-    <pluginManagement>
-      <plugins>
-        <plugin>
-          <groupId>org.jacoco</groupId>
-          <artifactId>jacoco-maven-plugin</artifactId>
-          <version>0.5.3.201107060350</version>
-        </plugin>
-      </plugins>
-    </pluginManagement>
-    <plugins>
-      <plugin>
-        <groupId>org.jacoco</groupId>
-        <artifactId>jacoco-maven-plugin</artifactId>
-        <version>0.5.3.201107060350</version>
-        <configuration>
-          <destFile>../implementation/target/jacoco-it.exec</destFile>
-          <includes>org.opendaylight.controller.*</includes>
-        </configuration>
-        <executions>
-          <execution>
-            <id>pre-test</id>
-            <goals>
-              <goal>prepare-agent</goal>
-            </goals>
-          </execution>
-          <execution>
-            <id>post-test</id>
-            <configuration>
-              <skip>true</skip>
-            </configuration>
-          </execution>
-        </executions>
-      </plugin>
-    </plugins>
-  </build>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-it</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common-api</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common-util</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common-impl</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-broker-impl</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal</artifactId>
+            <version>0.5.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>clustering.services</artifactId>
+            <version>0.4.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-binding</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
+            <artifactId>antlr4-runtime-osgi-nohead</artifactId>
+            <version>4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>protocol_plugins.stub</artifactId>
+            <version>0.4.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal.implementation</artifactId>
+            <version>0.4.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>containermanager</artifactId>
+            <version>0.5.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>containermanager.it.implementation</artifactId>
+            <version>0.5.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>clustering.stub</artifactId>
+            <version>0.4.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>clustered-datastore-implementation</artifactId>
+            <version>0.4.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
+            <artifactId>xtend-lib-osgi</artifactId>
+            <version>2.4.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-broker-impl</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-native</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-netconf-connector</artifactId>
+            <version>${netconf.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>yang-store-impl</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>logback-config</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-persister-impl</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-persister-file-adapter</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>netconf-impl</artifactId>
+            <version>${netconf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>netconf-client</artifactId>
+            <version>${netconf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>concepts</artifactId>
+            <version>0.1.1-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-data-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.mockito</groupId>
+            <artifactId>mockito-all</artifactId>
+            <version>1.9.5</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-manager</artifactId>
+            <version>0.2.3-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-management</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
+            <artifactId>antlr4-runtime-osgi-nohead</artifactId>
+            <version>4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
+            <artifactId>xtend-lib-osgi</artifactId>
+            <version>2.4.3</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-broker-impl</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-container-native</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-junit4</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-netconf-connector</artifactId>
+            <version>${netconf.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>yang-store-impl</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>logback-config</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-persister-impl</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-persister-file-adapter</artifactId>
+            <version>${config.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>netconf-impl</artifactId>
+            <version>${netconf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>netconf-client</artifactId>
+            <version>${netconf.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.ops4j.pax.exam</groupId>
+            <artifactId>pax-exam-link-mvn</artifactId>
+            <version>${exam.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>equinoxSDK381</groupId>
+            <artifactId>org.eclipse.osgi</artifactId>
+            <version>3.8.1.v20120830-144521</version>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>log4j-over-slf4j</artifactId>
+            <version>1.7.2</version>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <version>1.0.9</version>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <version>1.0.9</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-service</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>config-manager</artifactId>
+            <version>0.2.3-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-management</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.thirdparty</groupId>
+            <artifactId>antlr4-runtime-osgi-nohead</artifactId>
+            <version>4.0</version>
+        </dependency>
+    </dependencies>
+    <properties>
+        <!-- Sonar jacoco plugin to get integration test coverage info -->
+        <sonar.jacoco.reportPath>../implementation/target/jacoco.exec</sonar.jacoco.reportPath>
+        <sonar.jacoco.itReportPath>../implementaiton/target/jacoco-it.exec</sonar.jacoco.itReportPath>
+    </properties>
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.jacoco</groupId>
+                    <artifactId>jacoco-maven-plugin</artifactId>
+                    <version>0.5.3.201107060350</version>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+        <plugins>
+            <plugin>
+                <groupId>org.jacoco</groupId>
+                <artifactId>jacoco-maven-plugin</artifactId>
+                <version>0.5.3.201107060350</version>
+                <configuration>
+                    <destFile>../implementation/target/jacoco-it.exec</destFile>
+                    <includes>org.opendaylight.controller.*</includes>
+                </configuration>
+                <executions>
+                    <execution>
+                        <id>pre-test</id>
+                        <goals>
+                            <goal>prepare-agent</goal>
+                        </goals>
+                    </execution>
+                    <execution>
+                        <id>post-test</id>
+                        <configuration>
+                            <skip>true</skip>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
 </project>
index e5861ab3c0af825806bd8951684dcf4f1a7a0250..c2fe5f5da4b5adda673107c5eeea7b5e1605e597 100644 (file)
@@ -8,16 +8,18 @@
 
 package org.opendaylight.controller.datastore;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.junit.Before;
+import org.junit.Assert;
 import org.junit.Test;
 import org.junit.runner.RunWith;
+import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.controller.test.sal.binding.it.TestHelper;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.util.Filter;
 import org.ops4j.pax.exam.util.PathUtils;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
@@ -27,38 +29,37 @@ import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
 import static junit.framework.Assert.assertNotNull;
 import static junit.framework.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 import static org.ops4j.pax.exam.CoreOptions.junitBundles;
 import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
 import static org.ops4j.pax.exam.CoreOptions.options;
 import static org.ops4j.pax.exam.CoreOptions.systemPackages;
 import static org.ops4j.pax.exam.CoreOptions.systemProperty;
 
-import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler.DataCommitTransaction;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.controller.md.sal.common.api.data.DataModification;
-import static org.mockito.Mockito.mock;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-
 @RunWith(PaxExam.class)
 public class ClusteredDataStoreIT {
-    private Logger log = LoggerFactory
-            .getLogger(ClusteredDataStoreIT.class);
+    private Logger log = LoggerFactory.getLogger(ClusteredDataStoreIT.class);
     // get the OSGI bundle context
     @Inject
     private BundleContext bc;
     @Inject
+    @Filter(timeout=60*1000)
     private ClusteredDataStore clusteredDS;
+
     // Configure the OSGi container
     @Configuration
     public Option[] config() {
         return options(
                 //
                 systemProperty("logback.configurationFile").value(
-                        "file:" + PathUtils.getBaseDir()
-                                + "/src/test/resources/logback.xml"),
+                        "file:" + PathUtils.getBaseDir() + "/src/test/resources/logback.xml"),
                 // To start OSGi console for inspection remotely
                 systemProperty("osgi.console").value("2401"),
                 // Set the systemPackages (used by clustering)
@@ -74,66 +75,56 @@ public class ClusteredDataStoreIT {
                 mavenBundle("equinoxSDK381", "org.apache.felix.gogo.shell").versionAsInProject(),
                 // List logger bundles
                 mavenBundle("org.slf4j", "slf4j-api").versionAsInProject(),
-                mavenBundle("org.slf4j", "log4j-over-slf4j")
-                        .versionAsInProject(),
-                mavenBundle("ch.qos.logback", "logback-core")
-                        .versionAsInProject(),
-                mavenBundle("ch.qos.logback", "logback-classic")
-                        .versionAsInProject(),
+                mavenBundle("org.slf4j", "log4j-over-slf4j").versionAsInProject(),
+                mavenBundle("ch.qos.logback", "logback-core").versionAsInProject(),
+                mavenBundle("ch.qos.logback", "logback-classic").versionAsInProject(),
                 // needed by statisticsmanager
-                mavenBundle("org.opendaylight.controller", "containermanager")
-                    .versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "containermanager.it.implementation")
-                    .versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "clustering.services")
-                    .versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "clustering.stub")
-                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "containermanager").versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "containermanager.it.implementation").versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "clustering.services").versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "clustering.stub").versionAsInProject(),
 
                 // List all the bundles on which the test case depends
-                mavenBundle("org.opendaylight.controller", "sal")
-                    .versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "sal.implementation")
-                    .versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "protocol_plugins.stub")
-                    .versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "sal").versionAsInProject(),
+                TestHelper.baseModelBundles(),
+                TestHelper.configMinumumBundles(),
+                TestHelper.bindingIndependentSalBundles(),
+                TestHelper.bindingAwareSalBundles(),
+                TestHelper.mdSalCoreBundles(),
+                mavenBundle("org.opendaylight.controller", "config-api").versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "sal.implementation").versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "protocol_plugins.stub").versionAsInProject(),
 
-                //clustered-data-store-implementation dependencies
-                mavenBundle("com.google.guava", "guava")
-                    .versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "sal-common-api")
-                    .versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "sal-common-util")
-                    .versionAsInProject(),
-                mavenBundle("org.opendaylight.controller", "sal-common-impl")
-                    .versionAsInProject(),
-                mavenBundle("org.opendaylight.yangtools", "yang-binding")
-                    .versionAsInProject(),
+                // sal-common-impl
+                mavenBundle("org.eclipse.xtend", "org.eclipse.xtend.lib").versionAsInProject(),
+                mavenBundle("org.eclipse.xtext", "org.eclipse.xtext.xbase.lib").versionAsInProject(),
 
+                // clustered-data-store-implementation dependencies
+                mavenBundle("com.google.guava", "guava").versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "sal-core-api").versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "sal-common-api").versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "sal-common-util").versionAsInProject(),
+                mavenBundle("org.opendaylight.controller", "sal-common-impl").versionAsInProject(),
+                mavenBundle("org.opendaylight.yangtools", "yang-model-api").versionAsInProject(),
+                mavenBundle("org.opendaylight.yangtools", "yang-binding").versionAsInProject(),
 
-                //sal-common-api dependencies
-                mavenBundle("org.opendaylight.controller", "sal-common")
-                    .versionAsInProject(),
-                mavenBundle("org.opendaylight.yangtools", "yang-common")
-                    .versionAsInProject(),
-                mavenBundle("org.opendaylight.yangtools", "concepts")
-                    .versionAsInProject(),
-                mavenBundle("org.osgi", "org.osgi.core")
-                    .versionAsInProject(),
-                //adding new maven bundles
-                mavenBundle("org.mockito", "mockito-all")
-                    .versionAsInProject(),
+                // sal-common-api dependencies
+                mavenBundle("org.opendaylight.controller", "sal-common").versionAsInProject(),
+                mavenBundle("org.opendaylight.yangtools", "yang-common").versionAsInProject(),
+                mavenBundle("org.opendaylight.yangtools", "concepts").versionAsInProject(),
+                mavenBundle("org.osgi", "org.osgi.core").versionAsInProject(),
+                // adding new maven bundles
+                mavenBundle("org.mockito", "mockito-all").versionAsInProject(),
+
+                // yang-data-api
+                mavenBundle("org.opendaylight.yangtools", "yang-data-api").versionAsInProject(),
 
                 // needed by hosttracker
-                mavenBundle("org.opendaylight.controller", "clustered-datastore-implementation")
-                        .versionAsInProject(),
-                mavenBundle("org.jboss.spec.javax.transaction",
-                        "jboss-transaction-api_1.1_spec").versionAsInProject(),
-                mavenBundle("org.apache.commons", "commons-lang3")
-                        .versionAsInProject(),
-                mavenBundle("org.apache.felix",
-                        "org.apache.felix.dependencymanager")
-                        .versionAsInProject(), junitBundles());
+                mavenBundle("org.opendaylight.controller", "clustered-datastore-implementation").versionAsInProject(),
+                mavenBundle("org.jboss.spec.javax.transaction", "jboss-transaction-api_1.1_spec").versionAsInProject(),
+                mavenBundle("org.apache.commons", "commons-lang3").versionAsInProject(),
+                mavenBundle("org.apache.felix", "org.apache.felix.dependencymanager").versionAsInProject(),
+                junitBundles());
     }
 
     private String stateToString(int state) {
@@ -151,137 +142,119 @@ public class ClusteredDataStoreIT {
         }
     }
 
-    @Before
-    public void areWeReady() {
-        assertNotNull(bc);
-        boolean debugit = false;
-        Bundle b[] = bc.getBundles();
-        for (int i = 0; i < b.length; i++) {
-            int state = b[i].getState();
-            if (state != Bundle.ACTIVE && state != Bundle.RESOLVED) {
-                log.debug("Bundle:" + b[i].getSymbolicName() + " state:"
-                          + stateToString(state));
-                debugit = true;
-            }
-        }
-        if (debugit) {
-            log.debug("Do some debugging because some bundle is "
-                      + "unresolved");
-        }
-    }
-
     @Test
-    public void testBundleContextClusteredDS_NotNull() throws Exception{
+    public void testBundleContextClusteredDS_NotNull() throws Exception {
         ServiceReference serviceReference = bc.getServiceReference(ClusteredDataStore.class);
         ClusteredDataStore store = ClusteredDataStore.class.cast(bc.getService(serviceReference));
         assertNotNull(store);
     }
 
     @Test
-    public void testInjected_ClusteredDS_NotNull(){
+    public void testInjected_ClusteredDS_NotNull() {
         assertNotNull(clusteredDS);
     }
 
     @Test
-    public void requestCommit_readConfigurationData_ShouldVerifyDataAndNoException(){
+    public void requestCommit_readConfigurationData_ShouldVerifyDataAndNoException() {
         DataModification dataModification = mock(DataModification.class);
         HashMap map = new HashMap();
         List list = new ArrayList();
         list.add("key");
-        InstanceIdentifier key = new InstanceIdentifier(list,String.class);
-        map.put(key, "value");
+        InstanceIdentifier key = new InstanceIdentifier(list);
+        map.put(key, mock(CompositeNode.class));
         when(dataModification.getUpdatedConfigurationData()).thenReturn(map);
         DataCommitTransaction dataCommitTrans = clusteredDS.requestCommit(dataModification);
         dataCommitTrans.finish();
-        String value = (String)clusteredDS.readConfigurationData(key);
-        assertEquals("value",value);
+        Object value = clusteredDS.readConfigurationData(key);
+        Assert.assertNotNull(value);
     }
 
     @Test(expected = NullPointerException.class)
-    public void requestCommit_ShouldThrowException(){
+    public void requestCommit_ShouldThrowException() {
         DataModification dataModification = null;
         DataCommitTransaction dataCommitTrans = clusteredDS.requestCommit(dataModification);
         dataCommitTrans.finish();
     }
 
     @Test
-    public void requestCommit_readOperationalData_ShouldVerifyDataAndNoException(){
+    public void requestCommit_readOperationalData_ShouldVerifyDataAndNoException() {
         DataModification dataModification = mock(DataModification.class);
         HashMap map = new HashMap();
         List list = new ArrayList();
         list.add("key");
-        InstanceIdentifier key = new InstanceIdentifier(list,String.class);
-        map.put(key, "value");
+        InstanceIdentifier key = new InstanceIdentifier(list);
+        map.put(key, mock(CompositeNode.class));
         when(dataModification.getUpdatedOperationalData()).thenReturn(map);
         DataCommitTransaction dataCommitTrans = clusteredDS.requestCommit(dataModification);
         dataCommitTrans.finish();
-        String value = (String)clusteredDS.readOperationalData(key);
-        assertEquals("value",value);
+        Object value = clusteredDS.readOperationalData(key);
+        Assert.assertNotNull(value);
     }
 
     @Test
-    public void requestCommit_readConfigurationData_NonExistingKey_ShouldVerifyNoMappedValueAndNoException(){
+    public void requestCommit_readConfigurationData_NonExistingKey_ShouldVerifyNoMappedValueAndNoException() {
         DataModification dataModification = mock(DataModification.class);
         HashMap map = new HashMap();
         List list = new ArrayList();
         list.add("key");
-        InstanceIdentifier key = new InstanceIdentifier(list,String.class);
+        InstanceIdentifier key = new InstanceIdentifier(list);
         map.put(key, "value");
         when(dataModification.getUpdatedConfigurationData()).thenReturn(map);
         DataCommitTransaction dataCommitTrans = clusteredDS.requestCommit(dataModification);
         dataCommitTrans.finish();
         list = new ArrayList();
         list.add("key1");
-        InstanceIdentifier key1 = new InstanceIdentifier(list,String.class);
+        InstanceIdentifier key1 = new InstanceIdentifier(list);
 
-        String value = (String)clusteredDS.readConfigurationData(key1);
+        Object value = clusteredDS.readConfigurationData(key1);
         assertNull(value);
     }
 
     @Test
-    public void requestCommit_readOperationalData_NonExistingKey_ShouldVerifyNoMappedValueAndNoException(){
+    public void requestCommit_readOperationalData_NonExistingKey_ShouldVerifyNoMappedValueAndNoException() {
         DataModification dataModification = mock(DataModification.class);
         HashMap map = new HashMap();
         List list = new ArrayList();
         list.add("key");
-        InstanceIdentifier key = new InstanceIdentifier(list,String.class);
-        map.put(key, "value");
+        InstanceIdentifier key = new InstanceIdentifier(list);
+        map.put(key, mock(CompositeNode.class));
         when(dataModification.getUpdatedOperationalData()).thenReturn(map);
         DataCommitTransaction dataCommitTrans = clusteredDS.requestCommit(dataModification);
         dataCommitTrans.finish();
         list = new ArrayList();
         list.add("key1");
-        InstanceIdentifier key1 = new InstanceIdentifier(list,String.class);
+        InstanceIdentifier key1 = new InstanceIdentifier(list);
 
-        String value = (String)clusteredDS.readOperationalData(key1);
+        Object value = clusteredDS.readOperationalData(key1);
         assertNull(value);
     }
 
     @Test(expected = NullPointerException.class)
-    public void requestCommit_readConfigurationData_WithNullPathShouldThrowException(){
+    public void requestCommit_readConfigurationData_WithNullPathShouldThrowException() {
         DataModification dataModification = mock(DataModification.class);
         HashMap map = new HashMap();
         List list = new ArrayList();
         list.add("key");
-        InstanceIdentifier key = new InstanceIdentifier(list,String.class);
+        InstanceIdentifier key = new InstanceIdentifier(list);
         map.put(key, "value");
         when(dataModification.getUpdatedConfigurationData()).thenReturn(map);
         DataCommitTransaction dataCommitTrans = clusteredDS.requestCommit(dataModification);
         dataCommitTrans.finish();
-        String value = (String)clusteredDS.readConfigurationData(null);
+        Object value = clusteredDS.readConfigurationData(null);
     }
 
     @Test(expected = NullPointerException.class)
-    public void requestCommit_readOperationalData_WithNullPathShouldThrowException(){
+    public void requestCommit_readOperationalData_WithNullPathShouldThrowException() {
         DataModification dataModification = mock(DataModification.class);
         HashMap map = new HashMap();
         List list = new ArrayList();
         list.add("key");
-        InstanceIdentifier key = new InstanceIdentifier(list,String.class);
+        InstanceIdentifier key = new InstanceIdentifier(list);
         map.put(key, "value");
         when(dataModification.getOriginalOperationalData()).thenReturn(map);
         DataCommitTransaction dataCommitTrans = clusteredDS.requestCommit(dataModification);
         dataCommitTrans.finish();
-        String value = (String)clusteredDS.readOperationalData(null);
+        Object value = clusteredDS.readOperationalData(null);
     }
+
 }
diff --git a/opendaylight/md-sal/clustered-data-store/integrationtest/src/test/resources/controller.config b/opendaylight/md-sal/clustered-data-store/integrationtest/src/test/resources/controller.config
new file mode 100644 (file)
index 0000000..e49ba67
--- /dev/null
@@ -0,0 +1,23 @@
+//START OF CONFIG-LAST
+<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:dom:cluster:store">prefix:dom-clustered-store-impl</type>
+        <name>cluster-data-store</name>
+    </module>
+</modules>
+</data>
+
+
+//END OF SNAPSHOT
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom:cluster:store?module=odl-sal-dom-clustered-store-cfg&revision=2013-10-28
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&revision=2013-10-28
+urn:opendaylight:params:xml:ns:yang:controller:config?module=config&revision=2013-04-05
+urn:ietf:params:netconf:capability:candidate:1.0
+urn:ietf:params:xml:ns:yang:ietf-netconf-monitoring?module=ietf-netconf-monitoring&revision=2010-10-04
+urn:ietf:params:xml:ns:yang:rpc-context?module=rpc-context&revision=2013-06-17
+urn:ietf:params:xml:ns:yang:ietf-inet-types?module=ietf-inet-types&revision=2010-09-24
+urn:ietf:params:netconf:capability:rollback-on-error:1.0
+urn:ietf:params:xml:ns:yang:ietf-yang-types?module=ietf-yang-types&revision=2010-09-24
+urn:opendaylight:params:xml:ns:yang:controller:md:sal:common?module=opendaylight-md-sal-common&revision=2013-10-28
+//END OF CONFIG
index 2d63ce57448f88b77a39b1bcb0525b9721c08370..50983e22cfd8885e8e1f6680bbe074c22cd59ec2 100644 (file)
@@ -7,7 +7,7 @@
     </encoder>
   </appender>
 
-  <root level="error">
+  <root level="info">
     <appender-ref ref="STDOUT" />
   </root>
 </configuration>
index efbd81c615f8d8218a6a8ad2a2c422db91c85a30..a6c1c508aaa7327b7a008975dd50aa9c3b09ae9a 100644 (file)
@@ -146,7 +146,7 @@ public class SchemaServiceImpl implements //
 
     private synchronized boolean tryToUpdateState(Collection<URL> changedURLs, Multimap<Bundle, URL> proposedNewState,
             boolean adding) {
-        Preconditions.checkArgument(changedURLs.size() > 0, "No change can occur when no URLs are changed");
+        Preconditions.checkArgument(!changedURLs.isEmpty(), "No change can occur when no URLs are changed");
 
         try {
             // consistent state
@@ -165,8 +165,8 @@ public class SchemaServiceImpl implements //
         } catch (Exception e) {
             // inconsistent state
             logger.debug(
-                    "SchemaService is falling back on last consistent state containing {}, inconsistent yang files {}, reason {}",
-                    consistentBundlesToYangURLs, inconsistentBundlesToYangURLs, e.toString());
+                    "SchemaService is falling back on last consistent state containing {}, inconsistent yang files {}",
+                    consistentBundlesToYangURLs, inconsistentBundlesToYangURLs, e);
             return false;
         }
     }
@@ -224,8 +224,9 @@ public class SchemaServiceImpl implements //
             // system bundle might have config-api on classpath &&
             // config-api contains yang files =>
             // system bundle might contain yang files from that bundle
-            if (bundle.getBundleId() == 0)
+            if (bundle.getBundleId() == 0) {
                 return bundle;
+            }
 
             Enumeration<URL> enumeration = bundle.findEntries("META-INF/yang", "*.yang", false);
             if (enumeration != null && enumeration.hasMoreElements()) {