DataSerializable classes will not be PDX serialized by the Reflection Based Autoserializer and will require the domain class be deployed on servers for queries.
book
Article ID: 294354
calendar_today
Updated On:
Products
VMware Tanzu Gemfire
Issue/Introduction
Classes implementing DataSerializable will not be PDX serialized which can cause issues with queries or function executions.
Tanzu GemFire's PDX Serialization stores data in named fields that you can access individually, to avoid the cost of deserializing the entire data object. This allows clients to run queries and functions against the data in the servers without the domain classes being available on the servers. By contrast, the DataSerializable interface is an older API that, while providing faster and more compact data serialization than PDX, requires full deserialization on the server and, hence, that the domain classes be available on both clients and servers. PDX serialization can be made even easier by using the ReflectionBasedAutoSerializer, which can automatically PDX serialize and deserialize domain objects without any code changes to the classes. Thus, properly configured, the ReflectionBasedAutoSerializer enables clients to store and run queries against data without needing to modify the domain classes or deploy them to the servers.
Whenever data needs to be sent over the network or stored on disk, Tanzu GemFire will need to determine which serialization method to use. The internal data serializer will attempt to determine the best method by considering a number of factors, including whether the class has a well known serializer, what serialization interface(s) it implements, and whether it is PDX serializable. In the case where the class to be serialized implements the DataSerializable interface, this method will be tried and used before considering PDX serialization and the object will be serialized using the DataSerializable format rather than as a PDX Instance. As a consequence, the domain class(es) will be needed on both the client and server when running queries that need access to fields of those objects.
Environment
Product Version: 9.8
Resolution
Options: In order to achieve the desired behavior, there are really only two options:
1) refactor the domain classes so they no longer implement DataSerializable; or 2) deploy the domain class files (or containing jars) to server's classpath.
Classes that implement the DataSerializable interface will not be considered for PDX serialization by the Reflection Based Autoserializer when sent to the servers and will, instead, be sent and stored using the DataSerializable format. As a consequence, operations that need to access individual fields of serialized objects, such as queries, will require that the class file be available on the serve in order to work as expected.