public interface PartitionListener
package com.myCompany.MyPartitionListener; public class MyPartitionListener extends PartitionListenerAdapter implements Declarable { private String regionName; public MyPartitionListener() {} public void afterPrimary(int bucketId) { System.out.println("bucket:" + bucketId + " has become primary on " + this.regionName); } public void afterRegionCreate(Region<?, ?> region) { this.regionName = region.getName(); } }A sample declaration of the MyPartitionListener in cache.xml as follows :
<partition-attributes redundant-copies="1"> <partition-listener> <class-name>com.myCompany.MyPartitionListener</class-name> </partition-listener> </partition-attributes>
PartitionAttributesFactory.addPartitionListener(PartitionListener)
Modifier and Type | Method and Description |
---|---|
void |
afterBucketCreated(int bucketId,
Iterable<?> keys)
Callback invoked after a bucket has been created in a member (e.g.
|
void |
afterBucketRemoved(int bucketId,
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
|
default void |
afterSecondary(int bucketId)
Callback invoked when any bucket in a partitioned region stops being primary
|
void afterPrimary(int bucketId)
bucketId
- id of the bucket which became primarydefault void afterSecondary(int bucketId)
bucketId
- id of the bucket which stopped being primaryvoid afterRegionCreate(Region<?,?> region)
region
- handle of the region which is createdvoid afterBucketRemoved(int bucketId, Iterable<?> keys)
bucketId
- id of the bucket removedkeys
- keys in the bucket removedvoid afterBucketCreated(int bucketId, Iterable<?> keys)
bucketId
- id of the bucket createdkeys
- keys in the bucket created