GemFire 5.8

com.gemstone.gemfire.cache.util
Class PartitionedRegionUtils

java.lang.Object
  extended by com.gemstone.gemfire.cache.util.PartitionedRegionUtils

public final class PartitionedRegionUtils
extends Object

Utility methods for handling partitioned Regions, for example during execution of Functions on a Partitioned Region.

Example of a Function using utility methods:

  public Serializable execute(FunctionContext context) {
     if (context instanceof RegionFunctionContext) {
         RegionFunctionContext rc = (RegionFunctionContext) context;
         if (PartitionedRegionUtils.isPartitionedRegion(rc.getDataSet())) {
             Region efficientReader =
              PartitionedRegionUtils.getLocalDataForContext(rc);
             efficientReader.get("someKey");
             // ...
         }
      }
  // ...
 

Since:
5.8LA
See Also:
FunctionService.onRegion(Region)

Method Summary
static Map getColocatedRegions(Region r)
          Given a partitioned Region, return a map of colocated Regions.
static Region getLocalData(Region r)
          Given a partitioned Region return a Region providing read access limited to the local heap, Writes using this Region have no constraints and behave the same as a partitioned Region.
static Region getLocalDataForContext(RegionFunctionContext c)
          Given a RegionFunctionContext for a partitioned Region, return a Region providing read access limited to the local heap.
static boolean isPartitionedRegion(Region r)
          Test a Region to see if it is a partitioned Region
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getColocatedRegions

public static Map getColocatedRegions(Region r)
Given a partitioned Region, return a map of colocated Regions. Given a local data reference to a partitioned region, return a map of local colocated Regions. If there are no colocated regions, return an empty map.

Parameters:
r - a partitioned Region
Returns:
an unmodifiable map of region name to Region
Throws:
IllegalStateException - if the Region is not a partitioned Region
Since:
5.8LA

getLocalDataForContext

public static Region getLocalDataForContext(RegionFunctionContext c)
Given a RegionFunctionContext for a partitioned Region, return a Region providing read access limited to the local heap. Writes using this Region have no constraints and behave the same as a partitioned Region.

Parameters:
c - a functions context
Returns:
a Region for efficient reads
Throws:
IllegalStateException - if RegionFunctionContext.getDataSet() returns something other than a partitioned Region

getLocalData

public static Region getLocalData(Region r)
Given a partitioned Region return a Region providing read access limited to the local heap, Writes using this Region have no constraints and behave the same as a partitioned Region.

Parameters:
r - a partitioned region
Returns:
a Region for efficient reads
Throws:
IllegalStateException - if the provided region is something other than a partitioned Region

isPartitionedRegion

public static boolean isPartitionedRegion(Region r)
Test a Region to see if it is a partitioned Region

Parameters:
r -
Returns:
true if it is a partitioned Region

GemFire 5.8

Copyright © 2002-2008 GemStone Systems, Inc. All Rights Reserved.