Interface OptimizedMarshaller
-
- All Superinterfaces:
Marshaller
public interface OptimizedMarshaller extends Marshaller
Optimized implementation ofMarshaller. UnlikeJdkMarshaller, which is based on standardObjectOutputStream, this marshaller does not enforce that all serialized objects implementSerializableinterface. It is also about 20 times faster as it removes lots of serialization overhead that exists in default JDK implementation.OptimizedMarshalleris tested only on Java HotSpot VM on other VMs it could yield unexpected results. It is the default marshaller on Java HotSpot VMs and will be used if no other marshaller was explicitly configured.Configuration
Mandatory
This marshaller has no mandatory configuration parameters.Java Example
OptimizedMarshaller marshaller = new OptimizedMarshaller(); // Enforce Serializable interface. marshaller.setRequireSerializable(true); IgniteConfiguration cfg = new IgniteConfiguration(); // Override marshaller. cfg.setMarshaller(marshaller); // Starts grid. G.start(cfg);
Spring Example
GridOptimizedMarshaller can be configured from Spring XML configuration file:<bean id="grid.custom.cfg" class="org.apache.ignite.configuration.IgniteConfiguration" singleton="true"> ... <property name="marshaller"> <bean class="OptimizedMarshaller"> <property name="requireSerializable">true</property> </bean> </property> ... </bean>
For information about Spring framework visit www.springframework.org
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclearClassDescriptorsCache()Clears the optimized class descriptors cache.OptimizedMarshallersetIdMapper(OptimizedMarshallerIdMapper mapper)Sets ID mapper.OptimizedMarshallersetPoolSize(int poolSize)Specifies size of cached object streams used by marshaller.OptimizedMarshallersetRequireSerializable(boolean requireSer)Sets whether marshaller should requireSerializableinterface or not.-
Methods inherited from interface org.apache.ignite.marshaller.Marshaller
marshal, marshal, nodeName, onUndeploy, setContext, unmarshal, unmarshal
-
-
-
-
Method Detail
-
setRequireSerializable
OptimizedMarshaller setRequireSerializable(boolean requireSer)
Sets whether marshaller should requireSerializableinterface or not.- Parameters:
requireSer- Whether to requireSerializable.- Returns:
thisfor chaining.
-
setIdMapper
OptimizedMarshaller setIdMapper(OptimizedMarshallerIdMapper mapper)
Sets ID mapper.- Parameters:
mapper- ID mapper.- Returns:
thisfor chaining.
-
setPoolSize
OptimizedMarshaller setPoolSize(int poolSize)
Specifies size of cached object streams used by marshaller. Object streams are cached for performance reason to avoid costly recreation for every serialization routine. If0(default), pool is not used and each thread has its own cached object stream which it keeps reusing.Since each stream has an internal buffer, creating a stream for each thread can lead to high memory consumption if many large messages are marshalled or unmarshalled concurrently. Consider using pool in this case. This will limit number of streams that can be created and, therefore, decrease memory consumption.
NOTE: Using streams pool can decrease performance since streams will be shared between different threads which will lead to more frequent context switching.
- Parameters:
poolSize- Streams pool size. If0, pool is not used.- Returns:
thisfor chaining.
-
clearClassDescriptorsCache
void clearClassDescriptorsCache()
Clears the optimized class descriptors cache. This is essential for the clients on disconnect in order to make them register their user types again (server nodes may lose previously registered types).
-
-