Cluster configuration service manages these three things in the cluster:
- contents of cluster.xml for each cluster group
- a list of runtime properties for each cluster group
- a list of deployed jars for each cluster group
When a server starts up and claims it's using cluster configuration, it will get these above 3 things from the connected locator and use them to configure its own cache and runtime environment (on top of its own properties) based on the cluster group it belongs to. So if you would like your attributes to be managed by cluster configuration, you can consider either one of these three types of attributes. In this article, we can talk about how to add elements to each of them.
Add Element to Cluster.xml
Our cache.xsd allows you to add your own custom elements in two places: one is directly under <cache> element, another is to add it under <region>. Please consider carefully if this is the right place for you to add your element.
These are the essential steps you need to follow to do this:
- define your element xml schema. See lucene.xsd for example.
- use jaxb tool in your IDE to auto generate java pojo objects based on your xml schema. This step can be automated using build tool
- You need annotate the root object created by step 2 with @XSDRootElement and define the namespace and schemaLocation. See Index.java for example. This allows the Geode to correctly register your type into cluster configuration service.
- Then you are free to use this object you created in step 3 when interacting with Geode's Cluster Persistence Service. CPS will use that object to correctly serialize/deserialize into/from xml and inserted into cluster.xml
- Note this only takes care of saving your element into cluster.xml, the part that actually takes what's in the cluster.xml and realize it in cache object is done using a different process involving CacheCreation, You will need to find out what to do in that end.
Add Element to Runtime Properties
This needs to be Geode property that can be altered after the cache is created.
Add Code in Deployed Jars
This is controlled by the gfsh "deploy" command, every jars deployed by the "deploy" command will be managed by cluster configuration service.