gemfire::FixedPartitionResolver Class Reference

Inherits gemfire::PartitionResolver.


Detailed Description

Implementers of interface FixedPartitionResolver helps to achieve explicit mapping of a "user defined" partition to a data member node.

GemFire uses the partition name returned by FixedPartitionResolver#getPartitionName(EntryEvent, CacheableHashSetPtr) to determine on which member the data is being managed. Say, for example, you want to partition all Trades according to quarters. You can implement FixedPartitionResolver to get the name of the quarter based on the date given as part of EntryEvent.

public class QuarterPartitionResolver implements FixedPartitionResolver{
&nbsp &nbsp public const char* getPartitionName(EntryEvent event, CacheableHashSetPtr allAvailablePartitions) {
&nbsp &nbsp Date date = sdf.parse((String)opDetails.getKey());
&nbsp &nbsp Calendar cal = Calendar.getInstance();
&nbsp &nbsp cal.setTime(date);
&nbsp &nbsp int month = cal.get(Calendar.MONTH);
&nbsp &nbsp if (month == 0 || month == 1 || month == 2) {
&nbsp &nbsp &nbsp return "Quarter1";
&nbsp &nbsp }
&nbsp &nbsp else if (month == 3 || month == 4 || month == 5) {
&nbsp &nbsp &nbsp return "Quarter2";
&nbsp &nbsp }
&nbsp &nbsp else if (month == 6 || month == 7 || month == 8) {
&nbsp &nbsp &nbsp return "Quarter3";
&nbsp &nbsp }
&nbsp &nbsp else if (month == 9 || month == 10 || month == 11) {
&nbsp &nbsp &nbsp return "Quarter4";
&nbsp &nbsp }
&nbsp &nbsp else {
&nbsp &nbsp &nbsp return "Invalid Quarter";
&nbsp &nbsp }
&nbsp }

See also:
PartitionResolver

Public Member Functions

virtual const char * getName ()
 Returns the name of the PartitionResolver.
virtual const char * getPartitionName (const EntryEvent &opDetails, CacheableHashSetPtr targetPartitions)=0
virtual CacheableKeyPtr getRoutingObject (const EntryEvent &opDetails)=0
 
Parameters:
opDetails the detail of the entry event

void preserveSB () const
 Atomically increment reference count.
int32_t refCount ()
 
Returns:
the reference count

void releaseSB () const
 Atomically decrement reference count, the SharedBase object is automatically deleted when its reference count goes to zero.

Member Function Documentation

virtual const char* gemfire::PartitionResolver::getName (  )  [virtual, inherited]

Returns the name of the PartitionResolver.

Returns:
String name

virtual const char* gemfire::FixedPartitionResolver::getPartitionName ( const EntryEvent opDetails,
CacheableHashSetPtr  targetPartitions 
) [pure virtual]

public methods This method is used to get the name of the partition for the given entry operation.

Parameters:
opDetails the details of the entry event e.g. Region#get(Object)
targetPartitions represents all the available primary partitions on the nodes
Returns:
partition-name associated with node which allows mapping of given data to user defined partition

virtual CacheableKeyPtr gemfire::PartitionResolver::getRoutingObject ( const EntryEvent opDetails  )  [pure virtual, inherited]

Parameters:
opDetails the 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 (  )  [inline, inherited]

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