public interface PartitionResolver<K,V> extends CacheCallback
PartitionResolver
enable custom
partitioning on the PartitionedRegion
.
1. The Key class 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 - 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.
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 {Modifier and Type | Method and Description |
---|---|
String |
getName()
Returns the name of the PartitionResolver
|
Object |
getRoutingObject(EntryOperation<K,V> opDetails) |
close
Object getRoutingObject(EntryOperation<K,V> opDetails)
opDetails
- the detail of the entry operation e.g.
Region.get(Object)
RuntimeException
- any exception thrown will terminate the operation and the
exception will be passed to the calling thread.String getName()
Copyright © 1997-2017 Pivotal Software, Inc. All rights reserved.