Changes between Initial Version and Version 1 of uka.transport

Aug 22, 2005 8:57:56 AM (14 years ago)

From legacy page.


  • uka.transport

    v1 v1  
     1= Fast Object Serialization uka.transport =
     3In the Java API an object serialization mechanism is provided that is able to transparently convert object structures into a linear byte sequence representation and vice versa. For sending objects across the network, this representation can be used. To make his classes serializable, the Java programmer only needs to declare his classes to implement the empty tagging interface
     7/** A simple serializable class */
     8public class Param implements {
     9   int    intValue;
     10   float  floatValue;
     11   Object objectReference;
     15Although transparency of object serialization is one of Java's beauties, its runtime costs are phenomenal. Since RMI uses Java's built-in object serialization mechanism, usually one third of the overall invocation time of a remote method is spent in marshaling and unmarshaling method arguments. On current hardware, a millisecond is easy to spend in serialization alone. For details please refer to the section "JavaParty papers".
     19// Assume: Param p, InputStream in, OutputStream out
     21// Writing an object into a stream and reading it back
     22new ObjectOutputStream(out).writeObject(p);
     23Param q = (Param) new ObjectInputStream(in).readObject();
     26For high performance distributed computing inefficient serialization cannot be tolerated. Therefore, we've looked into the details of the official serialization, which is mostly implemented in Java itself, and derived an optimized replacement for it. In some benchmarks, we could eliminate 81-97% of the overhead caused by the regular Java serialization. For details please refer to the section "JavaParty papers".
     28== Object Serialization vs. Fast Marshaling ==
     30The regular Java serialization is justifiable for persistent object storage, because it guarantees that objects can be reconstructed from their byte sequence representation even with future Java releases, and even with modified application classes. Our optimized serialization does not make such guarantees. Instead, it is designed for exchanging objects between running VMs that share the same class base.
     32== Look and Feel ==
     34From the programmer's point of view our optimized serialization is slightly more difficult to use (you know, there is no free lunch.) The main difference is that instead of a newly introduced interface uka.transport.Transportable has to be implemented. In contrast to, the interface uka.transport.Transportable is not empty:
     38package uka.transport;
     40public interface Transportable
     41    extends, Cloneable
     43    // *** object marshaling ***
     44    public void marshal(MarshalStream s)
     45      throws;
     47    // *** object unmarshaling ***
     48    // public Transportable(UnmarshalStream s)
     49    //   throws;
     51    public void unmarshalReferences(UnmarshalStream s)
     52      throws, ClassNotFoundException;
     54    // *** local object copy ***
     55    public Object deepClone(DeepClone _helper)
     56      throws CloneNotSupportedException;
     60Each class whose objects should be marshaled efficiently must provide an implementation for the methods declared in the Transportable interface. Subclasses of a "transportable" class must override these methods, if they add fields to the base class. If a subclass does not add additional fields, it nevertheless must provide a constructor related to marshaling. For details see below.
     62Usage of the efficient serialization with transportable objects is almost identical to the regular Java serialization. Just replace with uka.transport.MarshalStream and with uka.transport.UnmarshalStream. In the following example, please assume that class TParam implements interface uka.transport.Transportable.
     66// Assume: TParam p, InputStream in, OutputStream out
     68// Writing a transportable object into a stream and reading it back
     69new MarshalStream(out).writeObject(p);
     70TParam q = (TParam) new UnmarshalStream(in).readObject();
     73The following sections will explain how to efficiently implement the methods required by the interface uka.transport.Transportable. If you feel that it is unreasonable to write marshaling code for your classes, please have a look at the bottom of this page: Such marshaling code can be generated automatically.