GemFire 5.8

Interface PartitionResolver

All Superinterfaces:

public interface PartitionResolver
extends CacheCallback

Implementers of interface PartitionResolver enable custom partitioning on the PartitionedRegion.

1. The Key class or callback arg can implement PartitionResolver interface to enable custom partitioning OR
2. Configure your own PartitionResolver class in partition attributes (For instance when the Key is a primitive type or String) Implement the appropriate equals

GemFire uses the routing object's hashCode to determine where the data is being managed. Say, for example, you want to colocate all Trades by month and year.The key is implemented by TradeKey class which also implements the PartitionResolver interface.

public class TradeKey implements PartitionResolver {
    private String tradeID;
    private Month month ;
    private Year year ;
    public TradingKey(){ }
    public TradingKey(Month month, Year year){
        this.month = month;
        this.year = year;
    public Serializable getRoutingObject(EntryOperation opDetails){
        return this.month + this.year;
In the example above, all trade entries with the same month and year are guaranteed to be colocated.


Method Summary
 String getName()
          Returns the name of the PartitionResolver
 Serializable getRoutingObject(EntryOperation opDetails)
Methods inherited from interface com.gemstone.gemfire.cache.CacheCallback

Method Detail


Serializable getRoutingObject(EntryOperation opDetails)
opDetails - the detail of the entry operation e.g. Region.get(Object)
object associated with entry operation which allows the Partitioned Region to store associated data together
RuntimeException - any exception thrown will terminate the operation and the exception will be passed to the calling thread.


String getName()
Returns the name of the PartitionResolver

String name

GemFire 5.8

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