Add cluster config yang RPCs and provider wiring 66/28366/6
authorTom Pantelis <tpanteli@brocade.com>
Wed, 14 Oct 2015 01:53:48 +0000 (21:53 -0400)
committerTom Pantelis <tpanteli@brocade.com>
Wed, 14 Oct 2015 15:14:03 +0000 (11:14 -0400)
Added experimental RPCs, including AddShardRelica, with initial empty
implementations that return unsupported.

Change-Id: Ie8587903920760fc4555bc009c81183e8d7740e4
Signed-off-by: Tom Pantelis <tpanteli@brocade.com>
opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/05-clustering.xml.conf
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ClusterConfigRpcService.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_config_provider/ClusterConfigProviderModule.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_config_provider/ClusterConfigProviderModuleFactory.java [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-config-service.yang [new file with mode: 0644]
opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-config.yang [new file with mode: 0644]

index 6c5e91a..3cb1dfe 100644 (file)
                     <bounded-mailbox-capacity xmlns="urn:opendaylight:params:xml:ns:yang:controller:config:remote-rpc-connector">1000</bounded-mailbox-capacity>
                 </module>
 
+                <module>
+                    <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:controller:config:cluster-config-provider">prefix:cluster-config-provider</type>
+                    <name>cluster-config-provider</name>
+
+                    <oper-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>
+                    </oper-data-store>
+
+                    <config-data-store>
+                        <type xmlns:config-dom-store-spi="urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store">config-dom-store-spi:config-dom-datastore</type>
+                        <name>distributed-config-store-service</name>
+                    </config-data-store>
+
+                    <rpc-registry>
+                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+                        <name>binding-rpc-broker</name>
+                    </rpc-registry>
+                </module>
             </modules>
 
             <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
         <capability>urn:opendaylight:params:xml:ns:yang:controller:config:concurrent-data-broker?module=odl-concurrent-data-broker-cfg&amp;revision=2014-11-24</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:config:actor-system-provider:service?module=actor-system-provider-service&amp;revision=2015-10-05</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:config:actor-system-provider:impl?module=actor-system-provider-impl&amp;revision=2015-10-05</capability>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:cluster:config?module=cluster-config&amp;revision=2015-10-13</capability>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:config:cluster-config-provider?module=cluster-config-provider&amp;revision=2015-10-13</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:config:distributed-datastore-provider?module=distributed-datastore-provider&amp;revision=2014-06-12</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store?module=opendaylight-config-dom-datastore&amp;revision=2014-06-17</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store?module=opendaylight-operational-dom-datastore&amp;revision=2014-06-17</capability>
         <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:dom?module=opendaylight-md-sal-dom&amp;revision=2013-10-28</capability>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
     </required-capabilities>
 </snapshot>
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ClusterConfigRpcService.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ClusterConfigRpcService.java
new file mode 100644 (file)
index 0000000..0e0c48c
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * 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.config;
+
+import java.util.concurrent.Future;
+import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.config.rev151013.AddShardReplicaInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.config.rev151013.ClusterConfigService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.config.rev151013.ConvertMembersToNonvotingForAllShardsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.config.rev151013.ConvertMembersToVotingForAllShardsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.cluster.config.rev151013.RemoveShardReplicaInput;
+import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Implements the yang RPCs defined in the generated ClusterConfigService interface.
+ *
+ * @author Thomas Pantelis
+ */
+public class ClusterConfigRpcService implements ClusterConfigService, AutoCloseable {
+    private static final Logger LOG = LoggerFactory.getLogger(ClusterConfigRpcService.class);
+
+    private final DistributedDataStore configDataStore;
+    private final DistributedDataStore operDataStore;
+    private RpcRegistration<ClusterConfigService> rpcRegistration;
+
+    public ClusterConfigRpcService(DistributedDataStore configDataStore, DistributedDataStore operDataStore) {
+        this.configDataStore = configDataStore;
+        this.operDataStore = operDataStore;
+    }
+
+    public void start(RpcProviderRegistry rpcProviderRegistry) {
+        LOG.debug("ClusterConfigRpcService starting");
+
+        rpcRegistration = rpcProviderRegistry.addRpcImplementation(ClusterConfigService.class, this);
+    }
+
+    @Override
+    public Future<RpcResult<Void>> addShardReplica(AddShardReplicaInput input) {
+        // TODO implement
+        return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
+                "Not implemented yet").buildFuture();
+    }
+
+    @Override
+    public Future<RpcResult<Void>> removeShardReplica(RemoveShardReplicaInput input) {
+        // TODO implement
+        return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
+                "Not implemented yet").buildFuture();
+    }
+
+    @Override
+    public Future<RpcResult<Void>> addReplicasForAllShards() {
+        // TODO implement
+        return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
+                "Not implemented yet").buildFuture();
+    }
+
+    @Override
+    public Future<RpcResult<Void>> removeAllShardReplicas() {
+        // TODO implement
+        return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
+                "Not implemented yet").buildFuture();
+    }
+
+    @Override
+    public Future<RpcResult<Void>> convertMembersToVotingForAllShards(ConvertMembersToVotingForAllShardsInput input) {
+        // TODO implement
+        return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
+                "Not implemented yet").buildFuture();
+    }
+
+    @Override
+    public Future<RpcResult<Void>> convertMembersToNonvotingForAllShards(
+            ConvertMembersToNonvotingForAllShardsInput input) {
+        // TODO implement
+        return RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, "operation-not-supported",
+                "Not implemented yet").buildFuture();
+    }
+
+    @Override
+    public void close() {
+        if(rpcRegistration != null) {
+            rpcRegistration.close();
+        }
+    }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_config_provider/ClusterConfigProviderModule.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_config_provider/ClusterConfigProviderModule.java
new file mode 100644 (file)
index 0000000..dea6a23
--- /dev/null
@@ -0,0 +1,35 @@
+package org.opendaylight.controller.config.yang.config.cluster_config_provider;
+
+import com.google.common.base.Preconditions;
+import org.opendaylight.controller.cluster.datastore.DistributedDataStore;
+import org.opendaylight.controller.cluster.datastore.config.ClusterConfigRpcService;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+
+public class ClusterConfigProviderModule extends AbstractClusterConfigProviderModule {
+    public ClusterConfigProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public ClusterConfigProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver,
+            ClusterConfigProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public AutoCloseable createInstance() {
+        Preconditions.checkArgument(getConfigDataStoreDependency() instanceof DistributedDataStore,
+                "Injected config DOMStore must be an instance of DistributedDataStore");
+        Preconditions.checkArgument(getOperDataStoreDependency() instanceof DistributedDataStore,
+                "Injected operational DOMStore must be an instance of DistributedDataStore");
+        ClusterConfigRpcService service = new ClusterConfigRpcService((DistributedDataStore)getConfigDataStoreDependency(),
+                (DistributedDataStore)getOperDataStoreDependency());
+        service.start(getRpcRegistryDependency());
+        return service;
+    }
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_config_provider/ClusterConfigProviderModuleFactory.java b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_config_provider/ClusterConfigProviderModuleFactory.java
new file mode 100644 (file)
index 0000000..bf29af8
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: cluster-config-provider yang module local name: cluster-config-provider
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Tue Oct 13 22:12:46 EDT 2015
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.controller.config.yang.config.cluster_config_provider;
+
+public class ClusterConfigProviderModuleFactory extends AbstractClusterConfigProviderModuleFactory {
+}
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-config-service.yang b/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-config-service.yang
new file mode 100644 (file)
index 0000000..478907a
--- /dev/null
@@ -0,0 +1,56 @@
+module cluster-config-provider {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:config:cluster-config-provider";
+    prefix "cluster-config-provider";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-operational-dom-datastore {prefix operational-dom-store-spi;}
+    import opendaylight-config-dom-datastore {prefix config-dom-store-spi;}
+    import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
+
+    description
+        "This module contains the configuration YANG definitions for the ClusterConfigRpcService implementation";
+
+    revision "2015-10-13" {
+        description "Initial revision.";
+    }
+
+    // This is the definition of the provider implementation as a module identity.
+    identity cluster-config-provider {
+        base config:module-type;
+        config:java-name-prefix ClusterConfigProvider;
+    }
+
+    //  Augments the 'configuration' choice node under modules/module.
+    augment "/config:modules/config:module/config:configuration" {
+        case cluster-config-provider {
+            when "/config:modules/config:module/config:type = 'cluster-config-provider'";
+                container config-data-store {
+                    uses config:service-ref {
+                        refine type {
+                            mandatory true;
+                            config:required-identity config-dom-store-spi:config-dom-datastore;
+                        }
+                    }
+                }
+
+                container oper-data-store {
+                    uses config:service-ref {
+                        refine type {
+                            mandatory true;
+                            config:required-identity operational-dom-store-spi:operational-dom-datastore;
+                        }
+                    }
+                }
+
+                container rpc-registry {
+                    uses config:service-ref {
+                        refine type {
+                            mandatory true;
+                            config:required-identity mdsal:binding-rpc-registry;
+                        }
+                    }
+                }
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-config.yang b/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-config.yang
new file mode 100644 (file)
index 0000000..a13c13a
--- /dev/null
@@ -0,0 +1,76 @@
+module cluster-config {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:md:sal:cluster:config";
+    prefix "clustering-config";
+
+    description
+        "This module contains YANG RPC definitions for configuring a cluster.";
+
+    revision "2015-10-13" {
+        description "Initial revision.";
+    }
+
+    rpc add-shard-replica {
+        input {
+            leaf shard-name {
+              type string;
+              description "The name of the shard for which to create a replica.";
+            }
+        }
+
+        description "Adds a replica of a shard to this node and joins it to an existing cluster. The shard must
+            already have a module configuration defined for it and there must already be a shard existing on
+            another node with a leader. This RPC first contacts peer member seed nodes searching for a shard.
+            When found, an AddServer message is sent to the shard leader and applied as described in the Raft
+            paper.";
+    }
+
+    rpc remove-shard-replica {
+        input {
+            leaf shard-name {
+              type string;
+              description "The name of the shard for which to remove the replica.";
+            }
+        }
+
+        description "Removes an existing replica of a shard from this node via the RemoveServer mechanism as
+            described in the Raft paper.";
+    }
+
+    rpc add-replicas-for-all-shards {
+        description "Adds replicas on this node for all currently defined shards. This is equivalent to issuing
+            an add-shard-replica RPC for all shards.";
+    }
+
+    rpc remove-all-shard-replicas {
+        description "Removes replicas for all shards on this node. This is equivalent to issuing
+            a remove-shard-replica for all shards and essentially removes this node from a cluster.";
+    }
+
+    rpc convert-members-to-nonvoting-for-all-shards {
+        input {
+            leaf-list member-names {
+                type string;
+                description "The names of the cluster members to convert.";
+            }
+        }
+        
+        description "Converts the given cluster members to non-voting for all shards. The members will no 
+            longer participate in leader elections and consensus but will be replicated. This is useful for
+            having a set of members serve as a backup cluster in case the primary voting cluster suffers
+            catastrophic failure. This RPC can be issued to any cluster member and will be forwarded
+            to the leader.";
+    }
+
+    rpc convert-members-to-voting-for-all-shards {
+        input {
+            leaf-list member-names {
+                type string;
+                description "The names of the cluster members to convert.";
+            }
+        }
+        
+        description "Converts the given cluster members to voting for all shards. The members will 
+            participate in leader elections and consensus.";
+    }
+}
\ No newline at end of file