Apache Geode CHANGELOG

Storing and Retrieving Region Shortcuts and Custom Named Region Attributes

Use these examples to get started with Geode region shortcuts.

Geode region shortcuts, in org.apache.geode.cache.RegionShortcut for peers and servers and org.apache.geode.cache.client.ClientRegionShortcut for clients, are available wherever you create a region in the cache.xml or through the API. Custom named attributes, stored by you, are available from the moment you store them on.

The region shortcuts are special Geode named region attributes, with identifying names. Create custom named region attributes by setting the attributes and storing them with a unique identifier in the region attribute id. Retrieve named attributes by providing the shortcut enum value or the name you assigned in the id to the region creation:

  • In the API, use the identifier in the region factory creation
  • In the cache.xml, use the identifier in the <region> or <region-attribute> refid setting. The refid is available in both elements for convenience


Example #1

This example shows partitioned region creation in the cache.xml:

  • The first region-attributes declaration starts with the predefined PARTITION_REDUNDANT attributes, modifies the local-max-memory setting, and stores the resulting attributes in the custom-named myPartition attributes.
  • The region declarations use the new stored attributes, but each has its own interest policy, which is specified in the individual region creation.

    <!-- Retrieving and storing attributes -->
    <region-attributes id="myPartition" refid="PARTITION_REDUNDANT">
        <partition-attributes local-max-memory="512"/>
    <!-- Two partitioned regions, one colocated with the other -->
    <!-- Attributes are retrieved and applied in the first region -->
    <region name="PartitionedRegion1" refid="myPartition"/>
    <!-- Same stored attributes, modification for this region-->
    <region name="PartitionedRegion2" refid="myPartition">
            <partition-attributes colocated-with="PartitionedRegion1" />

Example #2

This example uses the RegionFactory API to create a region based on the predefined PARTITION region shortcut:

final Region diskPortfolios = 
    new RegionFactory("PARTITION").create("Portfolios");

This example retrieves an attributes template and passes it to the region creation with a modified pool specification:

ClientRegionFactory<String,String> regionFactory =         
Region<String, String> region = regionFactory