Package com.twitter.chill.config
Class ConfiguredInstantiator
java.lang.Object
com.twitter.chill.KryoInstantiator
com.twitter.chill.config.ConfiguredInstantiator
- All Implemented Interfaces:
Serializable
This is the standard Config based KryoInstantiator.
It delegates to another KryoInstantiator that is described a Config
object. This is either done via reflection or reflection AND serialization.
If the KEY is not set, the delegate is the default: new KryoInstantiator()
In the case of reflection, the class name of the delegate instantiator is given.
In the case of serialization, we first reflect to create the KryoInstatiator
we use to get the Kryo we need to deserialize.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final KryoInstantiatorstatic final StringKey we use to configure this class. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static KryoInstantiatordeserialize(com.esotericsoftware.kryo.kryo5.Kryo k, String base64Value) static String[]fastSplitKey(String key) Java's string split is very expensive due to regexes.Return the delegated KryoInstantiatorcom.esotericsoftware.kryo.kryo5.KryonewKryo()Calls through to the delegateprotected static Stringserialize(com.esotericsoftware.kryo.kryo5.Kryo k, KryoInstantiator ki) static voidsetReflect(Config conf, Class<? extends KryoInstantiator> instClass) In this mode, we are just refecting to another delegated class.static voidsetSerialized(Config conf, KryoInstantiator ki) Use the default KryoInstantiator to serialize the KryoInstantiator ki same as: setSerialized(conf, KryoInstantiator.class, ki)static voidsetSerialized(Config conf, Class<? extends KryoInstantiator> reflector, KryoInstantiator ki) If this reflector needs config to be set, that should be done PRIOR to making this call.Methods inherited from class com.twitter.chill.KryoInstantiator
setClassLoader, setInstantiatorStrategy, setReferences, setRegistrationRequired, setThreadContextClassLoader, withRegistrar
-
Field Details
-
delegate
-
KEY
Key we use to configure this class. Format: <class of KryoInstantiator>(:<base64 serialized instantiator>) if there is no serialized instantiator, we use the reflected instance as the delegate- See Also:
-
-
Constructor Details
-
ConfiguredInstantiator
- Throws:
ConfigurationException
-
-
Method Details
-
newKryo
public com.esotericsoftware.kryo.kryo5.Kryo newKryo()Calls through to the delegate- Overrides:
newKryoin classKryoInstantiator
-
getDelegate
Return the delegated KryoInstantiator -
setReflect
In this mode, we are just refecting to another delegated class. This is preferred if you don't have any configuration to do at runtime (i.e. you can make a named class that has all the logic for your KryoInstantiator). -
setSerialized
Use the default KryoInstantiator to serialize the KryoInstantiator ki same as: setSerialized(conf, KryoInstantiator.class, ki)- Throws:
ConfigurationException
-
setSerialized
public static void setSerialized(Config conf, Class<? extends KryoInstantiator> reflector, KryoInstantiator ki) throws ConfigurationException If this reflector needs config to be set, that should be done PRIOR to making this call. This mode serializes an instance (ki) to be used as the delegate. Only use this mode if reflection alone will not work.- Throws:
ConfigurationException
-
deserialize
protected static KryoInstantiator deserialize(com.esotericsoftware.kryo.kryo5.Kryo k, String base64Value) throws ConfigurationException - Throws:
ConfigurationException
-
serialize
-
fastSplitKey
Java's string split is very expensive due to regexes. Implement our own simple version instead.
-