From 2dbca7910d629b3fd10842143fc7ede0cc506c07 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Tue, 13 Oct 2015 21:53:48 -0400 Subject: [PATCH] Add cluster config yang RPCs and provider wiring Added experimental RPCs, including AddShardRelica, with initial empty implementations that return unsupported. Change-Id: Ie8587903920760fc4555bc009c81183e8d7740e4 Signed-off-by: Tom Pantelis --- .../resources/initial/05-clustering.xml.conf | 22 +++++ .../config/ClusterConfigRpcService.java | 97 +++++++++++++++++++ .../ClusterConfigProviderModule.java | 35 +++++++ .../ClusterConfigProviderModuleFactory.java | 13 +++ .../src/main/yang/cluster-config-service.yang | 56 +++++++++++ .../src/main/yang/cluster-config.yang | 76 +++++++++++++++ 6 files changed, 299 insertions(+) create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ClusterConfigRpcService.java create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_config_provider/ClusterConfigProviderModule.java create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_config_provider/ClusterConfigProviderModuleFactory.java create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-config-service.yang create mode 100644 opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-config.yang diff --git a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/05-clustering.xml.conf b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/05-clustering.xml.conf index 6c5e91a168..3cb1dfe432 100644 --- a/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/05-clustering.xml.conf +++ b/opendaylight/md-sal/sal-clustering-config/src/main/resources/initial/05-clustering.xml.conf @@ -84,6 +84,25 @@ 1000 + + prefix:cluster-config-provider + cluster-config-provider + + + operational-dom-store-spi:operational-dom-datastore + distributed-operational-store-service + + + + config-dom-store-spi:config-dom-datastore + distributed-config-store-service + + + + binding:binding-rpc-registry + binding-rpc-broker + + @@ -126,9 +145,12 @@ urn:opendaylight:params:xml:ns:yang:controller:config:concurrent-data-broker?module=odl-concurrent-data-broker-cfg&revision=2014-11-24 urn:opendaylight:params:xml:ns:yang:controller:config:actor-system-provider:service?module=actor-system-provider-service&revision=2015-10-05 urn:opendaylight:params:xml:ns:yang:controller:config:actor-system-provider:impl?module=actor-system-provider-impl&revision=2015-10-05 + urn:opendaylight:params:xml:ns:yang:controller:md:sal:cluster:config?module=cluster-config&revision=2015-10-13 + urn:opendaylight:params:xml:ns:yang:controller:config:cluster-config-provider?module=cluster-config-provider&revision=2015-10-13 urn:opendaylight:params:xml:ns:yang:controller:config:distributed-datastore-provider?module=distributed-datastore-provider&revision=2014-06-12 urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:config-dom-store?module=opendaylight-config-dom-datastore&revision=2014-06-17 urn:opendaylight:params:xml:ns:yang:controller:md:sal:core:spi:operational-dom-store?module=opendaylight-operational-dom-datastore&revision=2014-06-17 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:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 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 index 0000000000..0e0c48c0fa --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/config/ClusterConfigRpcService.java @@ -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 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> addShardReplica(AddShardReplicaInput input) { + // TODO implement + return RpcResultBuilder.failed().withError(ErrorType.APPLICATION, "operation-not-supported", + "Not implemented yet").buildFuture(); + } + + @Override + public Future> removeShardReplica(RemoveShardReplicaInput input) { + // TODO implement + return RpcResultBuilder.failed().withError(ErrorType.APPLICATION, "operation-not-supported", + "Not implemented yet").buildFuture(); + } + + @Override + public Future> addReplicasForAllShards() { + // TODO implement + return RpcResultBuilder.failed().withError(ErrorType.APPLICATION, "operation-not-supported", + "Not implemented yet").buildFuture(); + } + + @Override + public Future> removeAllShardReplicas() { + // TODO implement + return RpcResultBuilder.failed().withError(ErrorType.APPLICATION, "operation-not-supported", + "Not implemented yet").buildFuture(); + } + + @Override + public Future> convertMembersToVotingForAllShards(ConvertMembersToVotingForAllShardsInput input) { + // TODO implement + return RpcResultBuilder.failed().withError(ErrorType.APPLICATION, "operation-not-supported", + "Not implemented yet").buildFuture(); + } + + @Override + public Future> convertMembersToNonvotingForAllShards( + ConvertMembersToNonvotingForAllShardsInput input) { + // TODO implement + return RpcResultBuilder.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 index 0000000000..dea6a23636 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_config_provider/ClusterConfigProviderModule.java @@ -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 index 0000000000..bf29af8642 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/config/yang/config/cluster_config_provider/ClusterConfigProviderModuleFactory.java @@ -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 index 0000000000..478907a137 --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-config-service.yang @@ -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 index 0000000000..a13c13ac5c --- /dev/null +++ b/opendaylight/md-sal/sal-distributed-datastore/src/main/yang/cluster-config.yang @@ -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 -- 2.36.6