Bug 4105: Added DistributedEntityOwnershipService and wiring 86/26786/2
authorTom Pantelis <tpanteli@brocade.com>
Fri, 7 Aug 2015 16:55:48 +0000 (12:55 -0400)
committerGerrit Code Review <gerrit@opendaylight.org>
Thu, 10 Sep 2015 19:47:59 +0000 (19:47 +0000)
Added a skeleton DistributedEntityOwnershipService impl class and config
system wiring.

I initially tried to instantiate it in the operational store module but
it needs to be its own service and AFAIK you can only provide one
service per module as createInstance returns a single AutoCloseable.

So I created a new config yang and xml for distributed-entity-ownership-service.
We also need a separate config yang service identity to allow for
multiple impls - I put this in sal-common-api where the
EntityOwnershipService is defined.

Change-Id: I4883af2e749bca5c9dfdac69cf943017294435a3
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
features/mdsal/src/main/resources/features.xml
opendaylight/commons/opendaylight/pom.xml
opendaylight/md-sal/sal-clustering-config/pom.xml
opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/06-clustered-entity-ownership.xml.conf [new file with mode: 0644]
opendaylight/md-sal/sal-common-api/pom.xml
opendaylight/md-sal/sal-common-api/src/main/yang/opendaylight-entity-ownership-service.yang [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-entity-ownership-service.yang [new file with mode: 0644]

index 2a5e8f2..f67d4f9 100644 (file)
@@ -16,6 +16,7 @@
     </feature>
     <feature name='odl-mdsal-common' version='${mdsal.version}' description="OpenDaylight :: Config :: All">
       <feature version='${yangtools.version}'>odl-yangtools-data-binding</feature>
+      <feature version='${config.version}'>odl-config-api</feature>
       <bundle>mvn:org.opendaylight.controller/sal-common-api/${mdsal.version}</bundle>
       <bundle>mvn:org.opendaylight.controller/sal-common-impl/${mdsal.version}</bundle>
       <bundle>mvn:org.opendaylight.controller/sal-common-util/${mdsal.version}</bundle>
@@ -82,6 +83,7 @@
         <feature version='${project.version}'>odl-mdsal-remoterpc-connector</feature>
         <feature version='${project.version}'>odl-mdsal-distributed-datastore</feature>
         <configfile finalname="${config.configfile.directory}/${config.clustering.configfile}">mvn:org.opendaylight.controller/sal-clustering-config/${project.version}/xml/config</configfile>
+        <configfile finalname="${config.configfile.directory}/${config.clustered-entity-ownership.configfile}">mvn:org.opendaylight.controller/sal-clustering-config/${project.version}/xml/entityownershipconfig</configfile>
         <configfile finalname="configuration/initial/akka.conf">mvn:org.opendaylight.controller/sal-clustering-config/${project.version}/xml/akkaconf</configfile>
         <configfile finalname="configuration/initial/module-shards.conf">mvn:org.opendaylight.controller/sal-clustering-config/${project.version}/xml/moduleshardconf</configfile>
         <configfile finalname="configuration/initial/modules.conf">mvn:org.opendaylight.controller/sal-clustering-config/${project.version}/xml/moduleconf</configfile>
index 3147b04..12cdd6b 100644 (file)
@@ -56,6 +56,7 @@
     <aaa.version>0.3.0-SNAPSHOT</aaa.version>
     <config.configfile.directory>etc/opendaylight/karaf</config.configfile.directory>
     <config.clustering.configfile>05-clustering.xml</config.clustering.configfile>
+    <config.clustered-entity-ownership.configfile>06-clustered-entity-ownership.xml</config.clustered-entity-ownership.configfile>
     <config.netty.configfile>00-netty.xml</config.netty.configfile>
     <config.mdsal.configfile>01-md-sal.xml</config.mdsal.configfile>
     <config.xsql.configfile>04-xsql.xml</config.xsql.configfile>
index 29d8ae4..1767fa6 100644 (file)
                   <type>xml</type>
                   <classifier>config</classifier>
                 </artifact>
+                <artifact>
+                  <file>${project.build.directory}/classes/initial/06-clustered-entity-ownership.xml.conf</file>
+                  <type>xml</type>
+                  <classifier>entityownershipconfig</classifier>
+                </artifact>
                 <artifact>
                   <file>${project.build.directory}/classes/initial/akka.conf</file>
                   <type>xml</type>
diff --git a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/06-clustered-entity-ownership.xml.conf b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/06-clustered-entity-ownership.xml.conf
new file mode 100644 (file)
index 0000000..06a1fcb
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2015 Brocade Communications 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
+-->
+<snapshot>
+    <configuration>
+        <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+            <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+                <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:distributed-entity-ownership-service">prefix:distributed-entity-ownership-service-provider</type>
+                    <name>distributed-entity-ownership-service-provider</name>
+
+                    <data-store>
+                        <type xmlns:operational-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store">operational-dom-store-spi:operational-dom-datastore</type>
+                        <name>distributed-operational-store-service</name>
+                    </data-store>
+                </module>
+            </modules>
+
+            <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+                <service>
+                    <type xmlns:entity-ownership="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service">entity-ownership:entity-ownership-service</type>
+                    <instance>
+                        <name>entity-ownership-service</name>
+                        <provider>/modules/module[type='distributed-entity-ownership-service-provider'][name='distributed-entity-ownership-service-provider']</provider>
+                    </instance>
+                </service>
+            </services>
+        </data>
+    </configuration>
+    <required-capabilities>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:config:distributed-entity-ownership-service?module=distributed-entity-ownership-service&amp;revision=2015-08-10</capability>
+    </required-capabilities>
+</snapshot>
index b502dac..9b30c72 100644 (file)
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
     </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>config-api</artifactId>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.yangtools</groupId>
       <artifactId>concepts</artifactId>
     </dependency>
   </dependencies>
 
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.opendaylight.yangtools</groupId>
+        <artifactId>yang-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>generate-sources</goal>
+            </goals>
+            <configuration>
+              <codeGenerators>
+                <generator>
+                  <codeGeneratorClass>org.opendaylight.yangtools.maven.sal.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass>
+                  <outputBaseDir>${salGeneratorPath}</outputBaseDir>
+                </generator>
+                <generator>
+                  <codeGeneratorClass>org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator</codeGeneratorClass>
+                  <outputBaseDir>${jmxGeneratorPath}</outputBaseDir>
+                  <additionalConfiguration>
+                    <namespaceToPackage1>urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang</namespaceToPackage1>
+                  </additionalConfiguration>
+                </generator>
+                <generator>
+                  <codeGeneratorClass>org.opendaylight.yangtools.yang.unified.doc.generator.maven.DocumentationGeneratorImpl</codeGeneratorClass>
+                  <outputBaseDir>target/site/models</outputBaseDir>
+                </generator>
+              </codeGenerators>
+              <inspectDependencies>true</inspectDependencies>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
   <scm>
     <connection>scm:git:http://git.opendaylight.org/gerrit/controller.git</connection>
     <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
diff --git a/opendaylight/md-sal/sal-common-api/src/main/yang/opendaylight-entity-ownership-service.yang b/opendaylight/md-sal/sal-common-api/src/main/yang/opendaylight-entity-ownership-service.yang
new file mode 100644 (file)
index 0000000..f16f7c4
--- /dev/null
@@ -0,0 +1,18 @@
+module opendaylight-entity-ownership-service {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:entity-ownership-service";
+    prefix "entity-ownership-service";
+
+    import config { prefix config; revision-date 2013-04-05; }
+
+    description "EntityOwnershipService interface definition";
+
+    revision "2015-08-10" {
+        description "Initial revision";
+    }
+
+    identity entity-ownership-service {
+        base "config:service-type";
+        config:java-class  "org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService";
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/entityownership/DistributedEntityOwnershipService.java
new file mode 100644 (file)
index 0000000..a4025c5
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2015 Brocade Communications Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.cluster.datastore.entityownership;
+
+import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
+import org.opendaylight.controller.md.sal.common.api.clustering.CandidateAlreadyRegisteredException;
+import org.opendaylight.controller.md.sal.common.api.clustering.Entity;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidate;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipCandidateRegistration;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListener;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipListenerRegistration;
+import org.opendaylight.controller.md.sal.common.api.clustering.EntityOwnershipService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * The distributed implementation of the EntityOwnershipService.
+ *
+ * @author Thomas Pantelis
+ */
+public class DistributedEntityOwnershipService implements EntityOwnershipService, AutoCloseable {
+    private static final Logger LOG = LoggerFactory.getLogger(DistributedEntityOwnershipService.class);
+
+    private final DistributedDataStore datastore;
+
+    public DistributedEntityOwnershipService(DistributedDataStore datastore) {
+        this.datastore = datastore;
+    }
+
+    public void start() {
+        LOG.info("DistributedEntityOwnershipService starting");
+    }
+
+    @Override
+    public EntityOwnershipCandidateRegistration registerCandidate(Entity entity, EntityOwnershipCandidate candidate)
+            throws CandidateAlreadyRegisteredException {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public EntityOwnershipListenerRegistration registerListener(Entity entity, EntityOwnershipListener listener) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public void close() {
+    }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModule.java
new file mode 100644 (file)
index 0000000..fd2f6a8
--- /dev/null
@@ -0,0 +1,37 @@
+package org.opendaylight.controller.config.yang.config.distributed_entity_ownership_service;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
+import org.opendaylight.controller.cluster.datastore.entityownership.DistributedEntityOwnershipService;
+import org.opendaylight.controller.sal.core.spi.data.DOMStore;
+
+
+public class DistributedEntityOwnershipServiceProviderModule extends org.opendaylight.controller.config.yang.config.distributed_entity_ownership_service.AbstractDistributedEntityOwnershipServiceProviderModule {
+    public DistributedEntityOwnershipServiceProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public DistributedEntityOwnershipServiceProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.distributed_entity_ownership_service.DistributedEntityOwnershipServiceProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public boolean canReuseInstance(AbstractDistributedEntityOwnershipServiceProviderModule oldModule) {
+        return true;
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        DOMStore dataStore = getDataStoreDependency();
+        Preconditions.checkArgument(dataStore instanceof DistributedDataStore,
+                "Injected DOMStore must be an instance of DistributedDataStore");
+        DistributedEntityOwnershipService service = new DistributedEntityOwnershipService((DistributedDataStore)dataStore);
+        service.start();
+        return service;
+    }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModuleFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/distributed_entity_ownership_service/DistributedEntityOwnershipServiceProviderModuleFactory.java
new file mode 100644 (file)
index 0000000..7d7447d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: distributed-entity-ownership-service yang module local name: distributed-entity-ownership-service-provider
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Thu Aug 06 18:06:54 EDT 2015
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.config.distributed_entity_ownership_service;
+public class DistributedEntityOwnershipServiceProviderModuleFactory extends org.opendaylight.controller.config.yang.config.distributed_entity_ownership_service.AbstractDistributedEntityOwnershipServiceProviderModuleFactory {
+
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-entity-ownership-service.yang b/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/distributed-entity-ownership-service.yang
new file mode 100644 (file)
index 0000000..72c4d4f
--- /dev/null
@@ -0,0 +1,38 @@
+module distributed-entity-ownership-service {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:config:distributed-entity-ownership-service";
+    prefix "distributed-entity-ownership-service";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-operational-dom-datastore {prefix operational-dom-store-spi;}
+    import opendaylight-entity-ownership-service { prefix entity-ownership-service-spi; }
+
+    description
+        "This module contains the base YANG definitions for the DistributedEntityOwnershipService implementation";
+
+    revision "2015-08-10" {
+        description "Initial revision.";
+    }
+
+    // This is the definition of the service implementation as a module identity.
+    identity distributed-entity-ownership-service-provider {
+        base config:module-type;
+        config:provided-service entity-ownership-service-spi:entity-ownership-service;
+        config:java-name-prefix DistributedEntityOwnershipServiceProvider;
+    }
+
+    //  Augments the 'configuration' choice node under modules/module.
+    augment "/config:modules/config:module/config:configuration" {
+        case distributed-entity-ownership-service-provider {
+            when "/config:modules/config:module/config:type = 'distributed-entity-ownership-service-provider'";
+                container data-store {
+                    uses config:service-ref {
+                        refine type {
+                            mandatory false;
+                            config:required-identity operational-dom-store-spi:operational-dom-datastore;
+                        }
+                    }
+                }
+        }
+    }
+}
\ No newline at end of file

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