Configuring the Hazelcast Serialization

For data to be sent over a network between cluster members and/or clients, it needs to be serialized into raw bytes. Hazelcast has many serialization options to choose from, depending on what you plan on doing with your data.

With the Hazelcast Platform Operator you can configure Hazelcast Serialization using the Hazelcast CR. To understand the Hazelcast Serialization, refer to Platform documentation.

You can find more detailed information on configuration of Serialization in API Reference page.

Configuring Custom Serialization

To register custom serializers, you need to define the list of serializers and types in the serializers section. The following configuration will register two custom serializers.

Custom serializers example configuration
apiVersion: hazelcast.com/v1alpha1
kind: Hazelcast
metadata:
  name: hazelcast
spec:
  serialization:
    serializers:
    - className: com.example.FooSerializer
      typeClass: com.example.Foo
    - className: com.example.BarSerializer
      typeClass: com.example.Bar

Configuring Compact Serialization

To configure Compact serialization, you need to define the compactSerialization section. The following configuration will register an explicit serializer com.example.FooSerializer along with a zero-config serializer for com.example.Bar class.

Compact serialization example configuration
apiVersion: hazelcast.com/v1alpha1
kind: Hazelcast
metadata:
  name: hazelcast
spec:
  serialization:
    compactSerialization:
      serializers:
      - com.example.FooSerializer
      classes:
      - com.example.Bar

Disallowing Deserialization of Untrusted Java Classes

To stop Hazelcast from deserializing arbitrary classes, you can allow or disallow deserialization of Java classes by class name or package name, using the javaSerializationFilter option.

Java serialization filter example configuration
apiVersion: hazelcast.com/v1alpha1
kind: Hazelcast
metadata:
  name: hazelcast
spec:
  serialization:
    javaSerializationFilter:
      whitelist:
        classes:
        - example.Foo
        packages:
        - com.acme.app
        prefixes:
        - com.hazelcast.
        - java.
        - javax.
        - \[
      blacklist:
        classes:
        - com.acme.app.BeanComparator