|
GemFire 6.6.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.gemstone.gemfire.cache.partition.PartitionManager
public final class PartitionManager
An utility class to manage partitions (aka buckets) on a Partitioned Region
without requiring data (e.g. keys).
Note : Please contact support@gemstone.com before using these APIs.
This is an example of how this API can be used to create a view
region with redundancy 0, which is colocated with another region of
redundancy 1, without using the standard gemfire colocated-with attribute,
which only supports colocated regions with the same redundancy level.
Note that when using this API, the data in the view region is discarded every
time a primary moves.
public class ColocatingPartitionListener implements PartitionListener, Declarable { private Cache cache; private List<String> viewRegionNames = new ArrayList<String>(); public ColocatingPartitionListener() { } public void afterPrimary(int bucketId) { for (String viewRegionName : viewRegionNames) { Region viewRegion = cache.getRegion(viewRegionName); PartitionManager.createPrimaryBucket(viewRegion, bucketId, true, true); } } public void init(Properties props) { String viewRegions = props.getProperty("viewRegions"); StringTokenizer tokenizer = new StringTokenizer(viewRegions, ","); while (tokenizer.hasMoreTokens()) { viewRegionNames.add(tokenizer.nextToken()); } } public void afterRegionCreate(Region<?, ?> region) { cache = region.getCache(); } }In the declaration of the parent region in cache.xml, install the ColocatedPartitionListener as follows :
<partition-attributes redundant-copies="1"> <partition-listener> <class-name>com.myCompany.ColocatingPartitionListener</class-name> <parameter name="viewRegions"> <string>/customer/ViewA,/customer/ViewB</string> </parameter> </partition-listener> </partition-attributes>If the regions needs to be rebalanced, use the
RebalanceFactory.excludeRegions(Set)
method to exclude the view regions.
Method Summary | |
---|---|
static boolean |
createPrimaryBucket(Region<?,?> region,
int bucketId,
boolean destroyExistingRemote,
boolean destroyExistingLocal)
This method creates a copy of the bucket on the current node, if no copy already exists. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static boolean createPrimaryBucket(Region<?,?> region, int bucketId, boolean destroyExistingRemote, boolean destroyExistingLocal)
If the partitioned region does not have a primary bucket for the bucketId, it creates a primary bucket on the member and returns true.
If the partitioned region does have a primary bucket for the bucketId on
the member :
a) If destroyExistingLocal passed is true, it destroys the existing bucket,
and then creates a new primary bucket and returns true.
b) If destroyExistingLocal passed is false, it does nothing and returns
false.
If the partitioned region does have a primary bucket for the bucketId on
remote members :
a) If destroyExistingRemote passed is true, it destroys the existing bucket
on remote member, and then creates a new primary bucket on this member and
returns true.
b) If destroyExistingRemote passed is false, it throws
IllegalStateException.
region
- the partitioned region on which to create the bucketbucketId
- the identifier of the bucket to createdestroyExistingRemote
- whether to destroy the remote bucket if it existsdestroyExistingLocal
- whether to destroy the local bucket if it exists
IllegalArgumentException
- if the provided region is not a partitioned region
IllegalArgumentException
- if the provided bucketId is less than zero or greater than or
equal to the partitioned region's total number of buckets
IllegalStateException
- if the partitioned region has the primary bucket for the bucket
id on a remote member and the destroyExistingRemote parameter
provided is false
|
GemFire 6.6.3 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |