GemStone::GemFire::Cache::Generic::IFixedPartitionResolver< TKey, TValue > Interface Template Reference

Inherits GemStone::GemFire::Cache::Generic::IPartitionResolver< TKey, TValue >< TKey, TValue >.

Detailed Description

template<class TKey, class TValue>
interface GemStone::GemFire::Cache::Generic::IFixedPartitionResolver< TKey, TValue >

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, CacheableHashSet) 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 String getPartitionName(EntryOperation opDetails, CacheableHashSet 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, AttributesFactory.SetPartitionResolver, RegionAttributes.PartitionResolver

Public Member Functions

String^ GetName ()
String^ GetPartitionName (EntryEvent< TKey, TValue >^opDetails, System::Collections::Generic::ICollection< String^ >^targetPartitions)
Object^ GetRoutingObject (EntryEvent< TKey, TValue >^key)

Member Function Documentation

template<class TKey, class TValue>
String ^ GemStone::GemFire::Cache::Generic::IPartitionResolver< TKey, TValue >::GetName (  )  [inherited]

Returns the name of the PartitionResolver.

This function does not throw any exception.

the name of the PartitionResolver

template<class TKey, class TValue>
String ^ GemStone::GemFire::Cache::Generic::IFixedPartitionResolver< TKey, TValue >::GetPartitionName ( EntryEvent< TKey, TValue >^  opDetails,
System::Collections::Generic::ICollection< String^ >^  targetPartitions 

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

opDetails the details of the entry event e.g. Region#get(Object)
targetPartitions Avoid using this parameter. This set is deprecated from 7.5 and same will be removed in future release. represents all the available primary partitions on the nodes
<return> partition-name associated with node which allows mapping of given data to user defined partition </return>

template<class TKey, class TValue>
Object ^ GemStone::GemFire::Cache::Generic::IPartitionResolver< TKey, TValue >::GetRoutingObject ( EntryEvent< TKey, TValue >^  key  )  [inherited]

return object associated with entry event 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.

key key the detail of the entry event.

GemFire C++ Cache .NET API Documentation