Table of Contents |
---|
Problem Statement
Currently, when developer wants to change the configuration of a cluster, say, create a region (or destroy an index, or update an async event queue) and have the change persisted in cluster configuration for incoming servers, there is no public api for him to do so. He will have to replicate the effort of the equivalent gfsh command to achieve the same effect. It would be nice if we can expose what these commands do to a public API.
Product Goals
The developer should be able to save their configuration to the Cluster Management Service without having to restart the servers.
Obtain the cluster management service from cache when calling from a client or a server.
Pass config object to the cluster management service.
CRUD operations support for config objects.
User Goals
Create a more modular product to allow for easy extension and integration. The beneficiaries of this work are the developers working on different parts of the code such as Spring Data for Apache, Queries for Lucene index, storage for the JDBC connector, other Geode developers and anyone who wants to change the configuration of the cluster (create/destroy regions, indices or gateway receivers/senders etc), have these changes replicated on all the applicable servers and persisted in the configuration persistence service for new joining servers.
What We Have Now:
Our admin rest API "sort of" already serves this purpose, but it has these short comings:
- It's not a public API
- the API includes a gfsh command string.
- Each commands do similar things yet not consistent with each other.
Below is a diagram of the current state of things:
Gliffy Diagram | ||||
---|---|---|---|---|
|
From the current state of commands, It's not easy to extract a common interface for all the commands. And developers do not want to use gfsh command strings as a "make shift" api to call into the command. We are in need of a unified interface and a unified workflow for all the commands as well.
Proposal
Gliffy Diagram | ||||
---|---|---|---|---|
|
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
//on Clients ConfigurationManagementService cms = ClientCache.getConfigurationManagementService(); //on Server ConfigurationManagementService cms = Cache.getConfigurationManagementService(); RegionConfig regionConfig = new RegionConfig(); //These are JAXB generated configuration objects regionConfig.setName("Foo"); regionConfig.setrefId("REPLICATE"); Region region = cms.create(regionConfig, null, true); //create(config, memberOrGroup, ifNotExists), returned region is either a ProxyRegion or Region dependening on client or server. |
Following the effort here, Configuration Persistence Service, we already have a set of configuration objects derived from the cache xml schema. This would serve a common object that developers would use to configure the config instance first and then ask the cluster management service to persist it, either on the cache(create the real thing on an existing cache) or on the configuration persistence service (persist the configuration itself).
Gliffy Diagram | ||||
---|---|---|---|---|
|
Pros and Cons:
Pros:
- a common interface to call either on the locator/server/client side.
- a common workflow to enforce behavior consistency.
- Modularized implementation. The configuration object needs to implement the addition interfaces in order to be used in this API. This allows us to add functionality gradually and per function groups.
Cons:
- Existing gfsh commands need to be refactored to use this API as well, otherwise we would have duplicate implementations, or have different behaviors between using this API and using gfsh commands.
- When refactoring gfsh commands, some commands' behavior will change if they want to strictly follow this workflow, unless we add additional APIs for specific configuration objects.
Migration Strategy:
Our current commands uses numerous command options to configure the behavior of the commands. We will have to follow these steps to refactor the commands.
- combine all the command options into one configuration objects inside the command itself.
- have the command execution call the public API if the command conforms to the new workflow. In this step, the config objects needs to implement the ClusterConfigElement
- If the command can't use the common workflow, make a special method in the api for that specific configuration object (we need to evaluate carefully. we don't want to make too many exceptions to the common workflow)
The above work can be divided into functional groups and have different group share the work load.
Once all the commands are converted using the ClusterManagementService API, All the command classes are just a a facade of collecting the options values, build the config object and call into the API. At this point, the command objects can only exist on the gfsh client.
The end architecture would look like this:
Gliffy Diagram | ||||
---|---|---|---|---|
|
Project Milestones
- API is clearly defined
- All commands are converted using this API
- Command classes only exists on Gfsh client. The GfshHttpInvoker uses the rest api to call this ClusterConfigurationService with the configuration objects directly.