Interface FixedPartitionResolver<K,V>
- All Superinterfaces:
CacheCallback,Declarable,PartitionResolver<K,V>
FixedPartitionResolver helps to achieve explicit mapping
of a "user defined" partition to a data member node.
GemFire uses the partition name returned by
getPartitionName(EntryOperation, Set) 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 EntryOperation.
public class QuarterPartitionResolver implements FixedPartitionResolver{
public String getPartitionName(EntryOperation opDetails, Set
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";
}
}
- Since:
- GemFire 6.6
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiongetPartitionName(EntryOperation<K, V> opDetails, Set<String> targetPartitions) This method is used to get the name of the partition for the given entry operation.Methods inherited from interface org.apache.geode.cache.CacheCallback
closeMethods inherited from interface org.apache.geode.cache.Declarable
init, initializeMethods inherited from interface org.apache.geode.cache.PartitionResolver
getName, getRoutingObject
-
Method Details
-
getPartitionName
This method is used to get the name of the partition for the given entry operation.- Parameters:
opDetails- the details of the entry operation e.g.Region.get(Object)targetPartitions- Avoid using this parameter.This set is deprecated from 8.0 and same will be removed in future release. 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
-