Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

From this diagram, you can actually see the FOUR major components you need to create in order to have your element managed by the REST CMS: a controller, a configuration manager, a configuration validator and a configuration realizer. 

Configuration Controller

In order to add a rest end point, we will need a controller entry point to handle the request. You can see RegionManagementController as an example. Here is a few things you need to pay attention to:

...

The moment you want to call the CMS API, you find yourself in need of  two basic types for your Element: a Configuration object and a RuntimeInfo.

Configuration Object

...

This objects specifies how you want to configure this element like Region, Index, GatewayReceiver etc. To get started, consider only adding those attributes that you want to expose through rest api. For example, although according to the cache.xsd, a region can be configured with many attributes (see RegionConfig, which is generated by the jaxb service using the cache.xsd file), in rest management api, we don't want to overwhelm users, so we only expose those that are more commonly used. That would require us to expose a different configuration object called Region (better to put all configuration object in one package). 

...

For now, after you created a configuration manager, you will need to manually add it to the map in the list of managers in LocatorClusterManagementService.

...

For now, after you created a configuration validator, you will need to manually add it to the map in the list of validators in LocatorClusterManagementService.

...

For now, after you created a configuration realizer, you will need to manually add it to the map in the list of validators in CacheRealizationFunction

Note the configuration realizers are run on the servers.

Add A New Long Running Operation to be started by REST CMS

You can also start a long running operation through CMS REST call. Currently, we have restore redundancy and rebalance operations. If you want to add another long running operation to be started asynchronously and have the user check back for status through the rest end point, you will need to add these: a controller and a performer.

Operation controller

this handles the REST request and response. See RebalanceOperationController for example. The same list of things to pay attention to in configuration controller also applies here as well.

When you want to call into the configuration service's API to start the operation, you find yourself in need to of two object: ClusterManagementOperation and OperationResult

ClusterManagementOperation

This object defines the operation you want to run on the cluster. See RebalanceOperation for example. This object needs to be typed with the result object explained below.

OperationResult

This object holds the information you want to return to the user about the operation result when this operation finishes. See RebalanceResult for example.

Operation Performer

Now that you've created the operation and result object, you can now implement a performer that would take this operation object and return the result. Your performer needs to implement the OperationPerformer interface. See RebalanceOperationPerformer for example.

For now, after you created the performer, you will need to manually register it in the operation manager

Note the performer is run on the locators, and if you need to invoke operations on the servers, you will need to have all that logic in your own performers.