Pivotal GemFire Native Client Cache Reference  9.0.6
gemfire::PartitionResolver Class Referenceabstract

Implementers of interface PartitionResolver enable custom partitioning on the PartitionedRegion. More...

Inherits gemfire::SharedBase.

Inherited by gemfire::FixedPartitionResolver.

Public Member Functions

virtual const char * getName ()
 Returns the name of the PartitionResolver. More...
 
virtual CacheableKeyPtr getRoutingObject (const EntryEvent &opDetails)=0
 
void preserveSB () const
 Atomically increment reference count. More...
 
int32_t refCount ()
 
void releaseSB () const
 Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero. More...
 
virtual ~PartitionResolver ()
 public methods More...
 

Protected Member Functions

 PartitionResolver ()
 constructors More...
 

Detailed Description

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 - 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 {
    &nbsp &nbsp private String tradeID;
    &nbsp &nbsp private Month month ;
    &nbsp &nbsp private Year year ;

&nbsp &nbsp public TradingKey(){ }
&nbsp &nbsp public TradingKey(Month month, Year year){
&nbsp &nbsp &nbsp &nbsp this.month = month;
&nbsp &nbsp &nbsp &nbsp this.year = year;
&nbsp &nbsp }
&nbsp &nbsp public Serializable getRoutingObject(EntryOperation opDetails){
&nbsp &nbsp &nbsp &nbsp return this.month + this.year;
&nbsp &nbsp }
}

In the example above, all trade entries with the same month and year are guaranteed to be colocated.

Constructor & Destructor Documentation

virtual gemfire::PartitionResolver::~PartitionResolver ( )
virtual

public methods

destructor

gemfire::PartitionResolver::PartitionResolver ( )
protected

constructors

Member Function Documentation

virtual const char* gemfire::PartitionResolver::getName ( )
virtual

Returns the name of the PartitionResolver.

Returns
String name
virtual CacheableKeyPtr gemfire::PartitionResolver::getRoutingObject ( const EntryEvent opDetails)
pure virtual
Parameters
opDetailsthe detail of the entry event
Exceptions
RuntimeException- any exception thrown will terminate the operation and the exception will be passed to the calling thread.
Returns
object associated with entry event which allows the Partitioned Region to store associated data together
void gemfire::SharedBase::preserveSB ( ) const
inherited

Atomically increment reference count.

int32_t gemfire::SharedBase::refCount ( )
inlineinherited
Returns
the reference count
void gemfire::SharedBase::releaseSB ( ) const
inherited

Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero.


GemFire C++ Cache API Documentation