Package org.apache.geode.cache.util
Class StringPrefixPartitionResolver
java.lang.Object
org.apache.geode.cache.util.StringPrefixPartitionResolver
- All Implemented Interfaces:
CacheCallback,Declarable,PartitionResolver<String,Object>
public class StringPrefixPartitionResolver
extends Object
implements PartitionResolver<String,Object>
This partition resolver requires every key of the partitioned region to be an instance of String
and to contain at least one "|" delimiter. The prefix, the substring of the key that precedes the
first delimiter, is returned by getRoutingObject.
- Since:
- Geode 1.2.0
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a prefix resolver with the default delimiter. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Called when the region containing this callback is closed or destroyed, when the cache is closed, or when a callback is removed from a region using anAttributesMutator.booleangetName()Returns the name of the PartitionResolvergetRoutingObject(EntryOperation<String, Object> opDetails) Returns the prefix of the String key that precedes the first "|" in the key.inthashCode()Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.geode.cache.Declarable
init, initialize
-
Field Details
-
DEFAULT_DELIMITER
The default delimiter is "|". Currently this class only uses the default delimiter but in a future release configuring the delimiter may be supported.- See Also:
-
-
Constructor Details
-
StringPrefixPartitionResolver
public StringPrefixPartitionResolver()Creates a prefix resolver with the default delimiter.
-
-
Method Details
-
getRoutingObject
Returns the prefix of the String key that precedes the first "|" in the key.- Specified by:
getRoutingObjectin interfacePartitionResolver<String,Object> - Parameters:
opDetails- the detail of the entry operation e.g.Region.get(Object)- Returns:
- object associated with entry operation which allows the Partitioned Region to store associated data together
- Throws:
ClassCastException- if the key is not an instance of StringIllegalArgumentException- if the key does not contain at least one "|".
-
getName
Description copied from interface:PartitionResolverReturns the name of the PartitionResolver- Specified by:
getNamein interfacePartitionResolver<String,Object> - Returns:
- String name
-
hashCode
public int hashCode() -
equals
-
close
public void close()Description copied from interface:CacheCallbackCalled when the region containing this callback is closed or destroyed, when the cache is closed, or when a callback is removed from a region using anAttributesMutator.Implementations should cleanup any external resources such as database connections. Any runtime exceptions this method throws will be logged.
It is possible for this method to be called multiple times on a single callback instance, so implementations must be tolerant of this.
- Specified by:
closein interfaceCacheCallback- See Also:
-