Follow these guidelines to use custom domain classes for your cached entry keys and values in VMware Tanzu GemFire.

Classloader

Each member’s classloader must include classes for all objects the member accesses.

Class Requirements

Data is sent between clients and servers in serialized form and the server stores client data in serialized form. The server does not need to deserialize data to send it to another client or to access it through a PDXInstance, but it does need to deserialize it to access it in other ways. The server’s classloader must include the classes for:

  • All entry keys
  • Entry values in regions that the server persists to disk
  • Entry values the server accesses for any reason other than access using a PdxInstance or transfer of the full entry value to a client

GemFire serializes data entry keys and values for distribution, so all data that GemFire moves out of the local cache for any reason must be serializable. Additionally, partitioned regions store data in serialized form. Almost every configuration requires serialization.

For information about the requirements and options for data serialization, see Data Serialization.

Classes Used as Keys

The region uses hashing on keys. If you define a custom class to use as a key, for the class, override:

  • equals
  • hashCode. The default hashCode inherited from Object uses identity, which is different in every system member. In partitioned regions, hashing based on identity puts data in the wrong place. For details, see the Java API documentation for java.lang.Object.

Do not call hashCode() on an enum type data member within the key’s custom hashCode() implementation. The enum hashCode() may not be overridden, and its hash is based upon an address. Therefore, an enumerated type’s hashCode() return value can be different on each server, violating the restriction that hashCode() must return the same value on every server that hosts the region.

check-circle-line exclamation-circle-line close-line
Scroll to top icon