public interface PartitionListener
public class ColocatingPartitionListener extends PartitionListenerAdapter
implements 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>
Note : Please contact support@gemstone.com before using these APIs| Modifier and Type | Method and Description |
|---|---|
void |
afterBucketCreated(int bucketId,
java.lang.Iterable<?> keys)
Callback invoked after a bucket has been created in a member (e.g.
|
void |
afterBucketRemoved(int bucketId,
java.lang.Iterable<?> keys)
Callback invoked after a bucket has been removed from a member (e.g.
|
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
|
void afterPrimary(int bucketId)
bucketId - id of the bucket which became primaryvoid afterRegionCreate(Region<?,?> region)
region - handle of the region which is createdvoid afterBucketRemoved(int bucketId,
java.lang.Iterable<?> keys)
bucketId - id of the bucket removedkeys - keys in the bucket removedvoid afterBucketCreated(int bucketId,
java.lang.Iterable<?> keys)
bucketId - id of the bucket createdkeys - keys in the bucket created