From c9145dde459fde278597191e702366a3604c98d9 Mon Sep 17 00:00:00 2001 From: Moiz Raja Date: Tue, 5 Nov 2013 12:18:43 -0800 Subject: [PATCH] Initial commit for the ClusteredDataStore The ClusteredDataStore provides a mechanism for the MD-SAL Broker to share data across a cluster. It can be used by other components/services as well to share data. The ClusteredDataStore will use the ClusteringServices interface to create a cache and read/write data to it. This only includes the structure of the project. Moved clustered data store within md-sal Change-Id: I37b24c8a91e6dc69815566bc0acd6dde561cbc29 Signed-off-by: Moiz Raja --- .../implementation/pom.xml | 90 +++++++++++++ .../datastore/internal/Activator.java | 22 ++++ .../internal/ClusteredDataStore.java | 23 ++++ .../datastore/internal/ActivatorTest.java | 13 ++ .../internal/ClusteredDataStoreTest.java | 12 ++ .../integrationtest/pom.xml | 104 +++++++++++++++ .../datastore/ClusteredDataStoreIT.java | 118 ++++++++++++++++++ .../src/test/resources/logback.xml | 13 ++ opendaylight/md-sal/pom.xml | 5 + 9 files changed, 400 insertions(+) create mode 100644 opendaylight/md-sal/clustered-data-store/implementation/pom.xml create mode 100644 opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/Activator.java create mode 100644 opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/ClusteredDataStore.java create mode 100644 opendaylight/md-sal/clustered-data-store/implementation/src/test/java/org/opendaylight/controller/datastore/internal/ActivatorTest.java create mode 100644 opendaylight/md-sal/clustered-data-store/implementation/src/test/java/org/opendaylight/controller/datastore/internal/ClusteredDataStoreTest.java create mode 100644 opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml create mode 100644 opendaylight/md-sal/clustered-data-store/integrationtest/src/test/java/org/opendaylight/controller/datastore/ClusteredDataStoreIT.java create mode 100644 opendaylight/md-sal/clustered-data-store/integrationtest/src/test/resources/logback.xml diff --git a/opendaylight/md-sal/clustered-data-store/implementation/pom.xml b/opendaylight/md-sal/clustered-data-store/implementation/pom.xml new file mode 100644 index 0000000000..f822ac5d38 --- /dev/null +++ b/opendaylight/md-sal/clustered-data-store/implementation/pom.xml @@ -0,0 +1,90 @@ + + + 4.0.0 + + org.opendaylight.controller + sal-parent + 1.0-SNAPSHOT + ../.. + + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main + HEAD + + + clustered-datastore-implementation + 0.4.1-SNAPSHOT + bundle + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + + + + 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.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 + + + org.opendaylight.controller.datastore.internal.Activator + + + ${project.basedir}/META-INF + + + + + + + org.opendaylight.controller + sal-common-api + 1.0-SNAPSHOT + + + org.opendaylight.controller + sal + 0.5.1-SNAPSHOT + + + org.opendaylight.controller + clustering.services + 0.4.1-SNAPSHOT + + + junit + junit + test + + + equinoxSDK381 + org.eclipse.osgi + 3.8.1.v20120830-144521 + + + org.opendaylight.yangtools + yang-binding + + + 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 new file mode 100644 index 0000000000..101da7ffa3 --- /dev/null +++ b/opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/Activator.java @@ -0,0 +1,22 @@ + +/* + * 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.opendaylight.controller.sal.core.ComponentActivatorAbstractBase; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class Activator extends ComponentActivatorAbstractBase { + protected static final Logger logger = LoggerFactory + .getLogger(Activator.class); + + + +} diff --git a/opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/ClusteredDataStore.java b/opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/ClusteredDataStore.java new file mode 100644 index 0000000000..7c25b14ea3 --- /dev/null +++ b/opendaylight/md-sal/clustered-data-store/implementation/src/main/java/org/opendaylight/controller/datastore/internal/ClusteredDataStore.java @@ -0,0 +1,23 @@ +package org.opendaylight.controller.datastore.internal; + +import org.opendaylight.controller.md.sal.common.api.data.DataCommitHandler; +import org.opendaylight.controller.md.sal.common.api.data.DataModification; +import org.opendaylight.controller.md.sal.common.api.data.DataReader; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; + +public class ClusteredDataStore implements DataReader, Object>, DataCommitHandler,Object> { + @Override + public DataCommitTransaction, Object> requestCommit(DataModification, Object> modification) { + return null; + } + + @Override + public Object readOperationalData(InstanceIdentifier path) { + return null; + } + + @Override + public Object readConfigurationData(InstanceIdentifier path) { + return null; + } +} 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 new file mode 100644 index 0000000000..d36e9baf2c --- /dev/null +++ b/opendaylight/md-sal/clustered-data-store/implementation/src/test/java/org/opendaylight/controller/datastore/internal/ActivatorTest.java @@ -0,0 +1,13 @@ +package org.opendaylight.controller.datastore.internal; + +import org.junit.Test; + +import static junit.framework.Assert.assertNotNull; + +public class ActivatorTest { + + @Test + public void construct(){ + assertNotNull(new Activator()); + } +} diff --git a/opendaylight/md-sal/clustered-data-store/implementation/src/test/java/org/opendaylight/controller/datastore/internal/ClusteredDataStoreTest.java b/opendaylight/md-sal/clustered-data-store/implementation/src/test/java/org/opendaylight/controller/datastore/internal/ClusteredDataStoreTest.java new file mode 100644 index 0000000000..7a8e8e8d10 --- /dev/null +++ b/opendaylight/md-sal/clustered-data-store/implementation/src/test/java/org/opendaylight/controller/datastore/internal/ClusteredDataStoreTest.java @@ -0,0 +1,12 @@ +package org.opendaylight.controller.datastore.internal; + +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; + +public class ClusteredDataStoreTest { + @Test + public void construct(){ + assertNotNull(new ClusteredDataStore()); + } +} diff --git a/opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml b/opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml new file mode 100644 index 0000000000..407b46bed1 --- /dev/null +++ b/opendaylight/md-sal/clustered-data-store/integrationtest/pom.xml @@ -0,0 +1,104 @@ + + + 4.0.0 + + org.opendaylight.controller + commons.integrationtest + 0.5.1-SNAPSHOT + ../../../commons/integrationtest + + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + https://wiki.opendaylight.org/view/OpenDaylight_Controller:Main + + + clustered-datastore.integrationtest + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + protocol_plugins.stub + 0.4.1-SNAPSHOT + + + org.opendaylight.controller + sal + 0.5.0-SNAPSHOT + + + org.opendaylight.controller + sal.implementation + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + containermanager + 0.5.0-SNAPSHOT + + + org.opendaylight.controller + containermanager.it.implementation + 0.5.0-SNAPSHOT + + + org.opendaylight.controller + clustering.services + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + clustering.stub + 0.4.0-SNAPSHOT + + + org.opendaylight.controller + clustered-datastore-implementation + 0.4.1-SNAPSHOT + + + + + + ../implementation/target/jacoco.exec + ../implementaiton/target/jacoco-it.exec + + + + + + org.jacoco + jacoco-maven-plugin + 0.5.3.201107060350 + + + + + + org.jacoco + jacoco-maven-plugin + 0.5.3.201107060350 + + ../implementation/target/jacoco-it.exec + org.opendaylight.controller.* + + + + pre-test + + prepare-agent + + + + post-test + + true + + + + + + + diff --git a/opendaylight/md-sal/clustered-data-store/integrationtest/src/test/java/org/opendaylight/controller/datastore/ClusteredDataStoreIT.java b/opendaylight/md-sal/clustered-data-store/integrationtest/src/test/java/org/opendaylight/controller/datastore/ClusteredDataStoreIT.java new file mode 100644 index 0000000000..ddf275ec14 --- /dev/null +++ b/opendaylight/md-sal/clustered-data-store/integrationtest/src/test/java/org/opendaylight/controller/datastore/ClusteredDataStoreIT.java @@ -0,0 +1,118 @@ +/* + * 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; + +import org.junit.Test; +import org.junit.runner.RunWith; +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.PathUtils; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.inject.Inject; + +import static junit.framework.Assert.assertTrue; +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; + + +@RunWith(PaxExam.class) +public class ClusteredDataStoreIT { + private Logger log = LoggerFactory + .getLogger(ClusteredDataStoreIT.class); + // get the OSGI bundle context + @Inject + private BundleContext bc; + + // Configure the OSGi container + @Configuration + public Option[] config() { + return options( + // + systemProperty("logback.configurationFile").value( + "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) + systemPackages("sun.reflect", "sun.reflect.misc", "sun.misc"), + // List framework bundles + mavenBundle("equinoxSDK381", "org.eclipse.equinox.console").versionAsInProject(), + mavenBundle("equinoxSDK381", "org.eclipse.equinox.util").versionAsInProject(), + mavenBundle("equinoxSDK381", "org.eclipse.osgi.services").versionAsInProject(), + mavenBundle("equinoxSDK381", "org.eclipse.equinox.ds").versionAsInProject(), + mavenBundle("equinoxSDK381", "org.apache.felix.gogo.command").versionAsInProject(), + mavenBundle("equinoxSDK381", "org.apache.felix.gogo.runtime").versionAsInProject(), + 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(), + // 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(), + + // 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(), + + // 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()); + } + + private String stateToString(int state) { + switch (state) { + case Bundle.ACTIVE: + return "ACTIVE"; + case Bundle.INSTALLED: + return "INSTALLED"; + case Bundle.RESOLVED: + return "RESOLVED"; + case Bundle.UNINSTALLED: + return "UNINSTALLED"; + default: + return "Not CONVERTED"; + } + } + + @Test + public void testDoNothing() throws Exception{ + assertTrue(true); + } + +} diff --git a/opendaylight/md-sal/clustered-data-store/integrationtest/src/test/resources/logback.xml b/opendaylight/md-sal/clustered-data-store/integrationtest/src/test/resources/logback.xml new file mode 100644 index 0000000000..2d63ce5744 --- /dev/null +++ b/opendaylight/md-sal/clustered-data-store/integrationtest/src/test/resources/logback.xml @@ -0,0 +1,13 @@ + + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + diff --git a/opendaylight/md-sal/pom.xml b/opendaylight/md-sal/pom.xml index 4221912524..a6740fabac 100644 --- a/opendaylight/md-sal/pom.xml +++ b/opendaylight/md-sal/pom.xml @@ -42,6 +42,11 @@ sal-connector-api sal-rest-connector flow-management-compatibility + + + clustered-data-store/implementation + clustered-data-store/integrationtest + -- 2.36.6