Since 2016 Externalizer4J supports Hazelcast optimization.Using Hazelcast’s own DataSerializable optimized serialization API will optimize your class for you. Externalizer4J automatically generates full fledged DataSerializable implementations for your existing classes. See how Externalizer4J can help you tune Hazelcast performance and try it yourself using the free project on GitHub.

Using Hazelcast technology

The Hazelcast engineering team has understood the importance of high performance data serialization for their products. They have therefore developed a number of high performance serialization mechanisms right into their solutions.

The Hazelcast specific serialization APIs are:

  • DataSerializable
  • IdentifiedDataSerializable

These Hazelcast specific interfaces significantly increase serialization speed and reduce the amount of data sent through the network.

hazelcast-blue_dark_200px

Hazelcast optimization

The DataSerializable API is java interface. This means that your data classes need to implement DataSerializable to take advantage of Hazelcast’s serialization technology. This is a definitely a worthwhile effort but it is also time consuming and error prone exercise. That’s where Externalizer4J’s Hazelcast support can help.

Externalizer4J fully supports Hazecast’s high performance API and generates optimized implementations for your classes. Simple add the Externalizer4J build tools to your IDE, Ant or Maven build and let Externalizer4J analyze your classes and optimize them.

Simply choose the Hazelcast optimizer in the externalizer4j.properties file as illustrated below.

Configure externalizer4j to optimize classes using Hazelcast own API
Configure externalizer4j to optimize classes using Hazelcast own API.

After compilation by your standard java compiler Externalizer4J will optimize your plain Serializable classes and turn them into an implementation of the com.hazelcast.nio.serialization.DataSerializable API. Let’s look at the Person class in the example below.

The Serializable Person class before optimization for Hazelcast
The Serializable Person class before optimization for Hazelcast

Externalizer4J will analyze the class hierarchy and generate a DataSerializable version of your class using the Hazelcast API. This will be done directly in binary form, no source code modification or intermediate source generation involved. Take a look at the decompiled code for the optimized Person class shown below.

The Person class' bytecode generated by Externalizer4J to automatically implement the DataSerializable API
The Person class’ bytecode generated by Externalizer4J to automatically implement the DataSerializable API.

Externalizer4J automatically augmented the original class with the necessary readData() and writeData() methods needed to implementation the DataSerializable API. The Person class now also implements the DataSerializable interface as well.

How about the actual method implementation then? Very good question. Take look at the method body below. Externalizer4J generated the readData() and writeData() logic using the most efficient calls in the Hazelcast API. It also generated all the necessary null-checks for you.

The methods generated for the Person class to maximize performance using the Hazelcast DataSerializable API.
The methods generated for the Person class to maximize performance using the Hazelcast DataSerializable API.

Hazelcast IdentifiedDataSerializable support

Hazelcast provides an extension on its DataSerializable API called IdentifiedDataSerializable. It optimizes object creation even more. And of course Externalizer4J supports IdentifiedDataSerializable generation as well!

If your class already provides the required getId() and getFactoryId() methods then Externalizer4J will generate a IdentifiedDataSerializable class instead of a DataSerializable class. To enable the generation of the IdentifiedDataSerializable implementation specify optimizer=hazecast.IdentifiedDataSerializable (case insensitive) in the externalizer4j.properties file.

Click on the image below to view how Externalizer4J generated the IdentifiedDataSerializable code for the original Person class.

hazelcast-optimization-support

Tooling

The Externalizer4J tooling has been designed to integrate into you existing project with it easy. Simple add the Externalizer4J optimization after the compilation step of your project.

Integration is provided for:

Static code analysis of serialization logic

If your projects required hand written serailization logic Externalizer4J still can help. Externalizer4J also performs static code analysis for existing bytecode. For more information please take a look here.

Benchmark

We provide a series of JMH micro-benchmarks to allow you to experience the benefits of the Hazelcast performance optimization provided by Externalizer4J. Simply go to the Hazelcast performance optimization page on Github. There you’ll find a ready to go maven project.

Resources

Close Menu