Interface OptimizedMarshaller

  • All Superinterfaces:
    Marshaller

    public interface OptimizedMarshaller
    extends Marshaller
    Optimized implementation of Marshaller. Unlike JdkMarshaller, which is based on standard ObjectOutputStream, this marshaller does not enforce that all serialized objects implement Serializable interface. It is also about 20 times faster as it removes lots of serialization overhead that exists in default JDK implementation.

    OptimizedMarshaller is 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 Detail

      • setRequireSerializable

        OptimizedMarshaller setRequireSerializable​(boolean requireSer)
        Sets whether marshaller should require Serializable interface or not.
        Parameters:
        requireSer - Whether to require Serializable.
        Returns:
        this for 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. If 0 (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. If 0, pool is not used.
        Returns:
        this for 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).