gemfiregeode

Changing an existing Region's type in GemFire/Geode


Once a Region is created in Geode, say as a PARTITION type, is it possible to change the type to something else, such as PARTITION_PERSISTENT?


Solution

  • @juanramos is correct. You really only have the ability to alter (modify) a Region based on the configuration exposed in the AttributesMutator interface (see Javadoc).

    Programmatically, this would be acquired with:

    AttributesMutator attributesMutator = region.getAttributesMutator();
    
    // alter the Region using the AttributesMutator, such as by adding a new CacheListener
    

    In fact this is exactly how the alter region command in Gfsh was implemented (i.e. by using a Function to distribute the operation of altering/modifying the Region using the Region's AttributesMutator across the cluster of nodes hosting the Region).

    So, as Juan described, you can:

    1. Export Data from the Region
    2. Then, destroy the Region
    3. Next, re-create the Region with the desired DataPolicy (e.g. PARTITION_PERSISTENT)
    4. Finally, Import Data back into the re-created Region.

    Of course, if you do not have any data, then you can simply destroy and recreate the Region as well.

    Spring Boot for Apache Geode makes data handling (e.g. export and import) very simple to do, and can even be performed on an application restart (particularly during development time).