Class StringPrefixPartitionResolver

  • java.lang.Object
    • org.apache.geode.cache.util.StringPrefixPartitionResolver
  • All Implemented Interfaces:
    CacheCallback, Declarable, PartitionResolver<java.lang.String,​java.lang.Object>

    public class StringPrefixPartitionResolver
    extends java.lang.Object
    implements PartitionResolver<java.lang.String,​java.lang.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 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_DELIMITER
      The default delimiter is "|".
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      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 an AttributesMutator.
      boolean equals​(java.lang.Object o)  
      java.lang.String getName()
      Returns the name of the PartitionResolver
      java.lang.Object getRoutingObject​(EntryOperation<java.lang.String,​java.lang.Object> opDetails)
      Returns the prefix of the String key that precedes the first "|" in the key.
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_DELIMITER

        public static final java.lang.String 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:
        Constant Field Values
    • Constructor Detail

      • StringPrefixPartitionResolver

        public StringPrefixPartitionResolver()
        Creates a prefix resolver with the default delimiter.
    • Method Detail

      • getRoutingObject

        public java.lang.Object getRoutingObject​(EntryOperation<java.lang.String,​java.lang.Object> opDetails)
        Returns the prefix of the String key that precedes the first "|" in the key.
        Specified by:
        getRoutingObject in interface PartitionResolver<java.lang.String,​java.lang.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:
        java.lang.ClassCastException - if the key is not an instance of String
        java.lang.IllegalArgumentException - if the key does not contain at least one "|".
      • getName

        public java.lang.String getName()
        Description copied from interface: PartitionResolver
        Returns the name of the PartitionResolver
        Specified by:
        getName in interface PartitionResolver<java.lang.String,​java.lang.Object>
        Returns:
        String name
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • close

        public void close()
        Description copied from interface: CacheCallback
        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 an AttributesMutator.

        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:
        close in interface CacheCallback
        See Also:
        RegionService.close(), Region.close(), Region.localDestroyRegion(), Region.destroyRegion(), AttributesMutator