rgb1380
rgb1380

Reputation: 83

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?

Upvotes: 0

Views: 136

Answers (2)

John Blum
John Blum

Reputation: 8001

@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).

Upvotes: 1

Juan Ramos
Juan Ramos

Reputation: 1421

I don't think this is not possible out of the box... You can, however, use the gfsh export data command to export the current region data, destroy the region, create a new one with the correct type, and then use the gfsh import data command to re populate the region from the backup.

Upvotes: 1

Related Questions