GemFire 6.5

com.gemstone.gemfire.cache.partition
Interface PartitionListener


public interface PartitionListener

A callback for partitioned regions, invoked when a partition region is created or any bucket in a partitioned region becomes primary

A sample implementation of this interface to colocate partition regions using a primary key without having to honour the redundancy contract for every colocate partition regions is as follows :

 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();
   }
 }
 
A sample declaration of the ColocatingPartitionListener in cache.xml 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>
 

Since:
6.5
See Also:
Note : Please contact support@gemstone.com before using these APIs

Method Summary
 void afterPrimary(int bucketId)
          Callback invoked when any bucket in a partitioned region becomes primary
 void afterRegionCreate(Region<?,?> region)
          Callback invoked when a partition region is created
 

Method Detail

afterPrimary

void afterPrimary(int bucketId)
Callback invoked when any bucket in a partitioned region becomes primary

Parameters:
bucketId - id of the bucket which became primary
Since:
6.5

afterRegionCreate

void afterRegionCreate(Region<?,?> region)
Callback invoked when a partition region is created

Parameters:
region - handle of the region which is created
Since:
6.5

GemFire 6.5

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