Class KryoSerializerFactory

java.lang.Object
net.sodacan.core.serialize.kryo.KryoSerializerFactory
All Implemented Interfaces:
SerializerFactory, PoolItemFactory<com.esotericsoftware.kryo.Kryo>

public class KryoSerializerFactory extends Object implements SerializerFactory, PoolItemFactory<com.esotericsoftware.kryo.Kryo>
Factory that creates individual Serializers. Each actor will ask for a serializer. The factory is free to hand out individual Serializers or a single shared serializer. In any case, the factory will be getting requests from multiple threads and so should be sure to avoid concurrency issues.

Our constructor is created during Config. At this time, before we are accessed by Actors, we create a thread-safe pool of Kryo instances.

  • Field Details

    • messageClass

      protected Class<? extends Message> messageClass
    • pool

      protected Pool<com.esotericsoftware.kryo.Kryo> pool
  • Constructor Details

    • KryoSerializerFactory

      public KryoSerializerFactory(Config config)
  • Method Details

    • createItem

      public com.esotericsoftware.kryo.Kryo createItem()
      Specified by:
      createItem in interface PoolItemFactory<com.esotericsoftware.kryo.Kryo>
    • create

      public Serializer create(ActorId actorId)
      Create a serializer for the specified actorId. This method is called from an individual Actor's thread. We don't modify any shared variables here but if we did, then syncing is needed.
      Specified by:
      create in interface SerializerFactory
    • getConfig

      public Config getConfig()
    • getMessageClass

      public Class<? extends Message> getMessageClass()