VMware GemFire Native Client C++ API Reference
|
VMware VMware GemFire Native C++ Reference 10.4.3
|
Implementers of interface FixedPartitionResolver helps to achieve explicit mapping of a "user defined" partition to a data member node.
More...
#include <FixedPartitionResolver.hpp>
Inherits apache::geode::client::PartitionResolver.
Public Member Functions | |
| virtual const std::string & | getName () |
| Returns the name of the PartitionResolver. | |
| virtual const std::string & | getPartitionName (const EntryEvent &opDetails)=0 |
| public methods | |
| virtual std::shared_ptr< CacheableKey > | getRoutingObject (const EntryEvent &opDetails)=0 |
Detailed Description
Implementers of interface FixedPartitionResolver helps to achieve explicit mapping of a "user defined" partition to a data member node.
Geode uses the partition name returned by FixedPartitionResolver#getPartitionName(EntryEvent,
std::shared_ptr<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{
    public const char* getPartitionName(EntryEvent event,
std::shared_ptr<CacheableHashSet>
allAvailablePartitions) {
    Date date = sdf.parse((String)opDetails.getKey());
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    int month = cal.get(Calendar.MONTH);
    if (month == 0 || month == 1 || month == 2) {
      return "Quarter1";
    }
    else if (month == 3 || month == 4 || month == 5) {
      return "Quarter2";
    }
    else if (month == 6 || month == 7 || month == 8) {
      return "Quarter3";
    }
    else if (month == 9 || month == 10 || month == 11) {
      return "Quarter4";
    }
    else {
      return "Invalid Quarter";
    }
  }
- See also
- PartitionResolver
Member Function Documentation
◆ getName()
|
virtualinherited |
Returns the name of the PartitionResolver.
- Returns
- String name
Reimplemented in apache::geode::client::StringPrefixPartitionResolver.
◆ getPartitionName()
|
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)
- Returns
- partition-name associated with node which allows mapping of given data to user defined partition
◆ getRoutingObject()
|
pure virtualinherited |
- 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
Implemented in apache::geode::client::StringPrefixPartitionResolver.
Apache Geode C++ Cache API Documentation