PartitionResolver (Apache Geode 2.0.2)
Description: declaration: package: org.apache.geode.cache, interface: PartitionResolver

Package org.apache.geode.cache

# Interface PartitionResolver<K,V>

All Superinterfaces:
  `CacheCallback`, `Declarable`

All Known Subinterfaces:
  `FixedPartitionResolver<K,V>`

All Known Implementing Classes:
  `StringPrefixPartitionResolver`

public interface PartitionResolver<K,V> extends CacheCallback
Implementers of interface `PartitionResolver` enable custom standard partitioning on the `PartitionedRegion`.
See `FixedPartitionResolver` to enable custom fixed partitioning.

1. The key class can implement the PartitionResolver interface to enable custom partitioning. OR
2. Configure your own PartitionResolver class in partition attributes (for instance when the key is a JDK class like Integer or String). Implement the appropriate equals - For all implementations, you need to be sure to code the class equals method so it properly verifies equality for the PartitionResolver implementation. This might mean verifying that class names are the same or that the returned routing objects are the same etc.. When you initiate the partitioned region on multiple nodes, GemFire uses the equals method to ensure you are using the same PartitionResolver implementation for all of the nodes for the region. OR
3. The callback argument passed to the Region operation methods can implement PartitionResolver. This implementation restricts you to using methods that accept a cache callback argument to manage the region entries. For a full list of the methods that take a callback argument, see the Region Javadocs.

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 Object 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.

Since:
  GemFire 6.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getName()`
  Returns the name of the PartitionResolver
  `Object`
  `getRoutingObject(EntryOperation<K,V> opDetails)`

  ### Methods inherited from interface org.apache.geode.cache.CacheCallback

  `close`

  ### Methods inherited from interface org.apache.geode.cache.Declarable

  `init, initialize`

- ## Method Details

  - ### getRoutingObject

    Object getRoutingObject(EntryOperation<K,V> opDetails)
    Parameters:
      `opDetails` - the detail of the entry operation e.g. `Region.get(Object)`
    Returns:
      object associated with entry operation which allows the Partitioned Region to store associated data together
    Throws:
      `RuntimeException` - any exception thrown will terminate the operation and the exception will be passed to the calling thread.

  - ### getName

    String getName()
    Returns the name of the PartitionResolver
    Returns:
      String name