Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
/** writesUse andDSFIDSerializerFactory readsto DataSerializableFixedIDcreate instances.a  Supports reading/writing of nulls serializer */
interfaceclass DSFIDSerializerDSFIDSerializerFactory {
  void writeDSFID(DataSerializableFixedID, DataOutput output) throws IOException;
  DataSerializableFixedID readDSFID(DataInput input) throws IOException, ClassNotFoundException;
}

/** provides context for toData and fromData serialization methods */
interface SerializationContext {
  DSFIDSerializer getDSFIDSerializer();
  SerializerPlugin getDataSerializer();  // provides InternalDataSerializer readObject/writeObject
  Version getSerializationVersion/** set an ObjectSerializer that should be used when invoking
   *  toData/fromData methods on objects.  This will typically
   *  defer serialization of DataSerializableFixedID objects to
   *  the DSFIDSerializer
   */
  setObjectSerializer(ObjectSerializer serializer);
  create();
}

/** writes injectsand higherreads level (e.g., DataSerializer) serialization services into DSFID serializers for
    use in serializing objects that the basic DSFIDSerializer can't handle */
interface SerializerPlugin {
  public void writeObject(Object obj, DataOutput output) throws IOException;
  public Object readObject(DataInput input) throws IOException, ClassNotFoundException;DataSerializableFixedID instances.  Supports reading/writing of nulls */
interface DSFIDSerializer {
  /** retrieve the ObjectSerializer.  If none was given to the factory this will be
   *  a default serializer that can only handle DataSerializableFixedID objects */
  ObjectSerializer getObjectSerializer();

  /**
 register a *class returnwith the versionserializer. associated withIt themust givenhave ordinala orno-arg theconstructor current*/
 version ifvoid the given
   * ordinal is > than the current version's ordinal
   */
  public Version getVersionForOrdinalOrCurrent(int ordinal);
}

/** a new superclass of HeapDataOutputStream that separates the methods used with Buffers from
    a bunch of other methods concerning other functionality such as Streamables, PDX, etc. */
class BufferDataOutputStream {
  // methods moved from HeapDataOutputStream unchangedregisterDSFID(int dsfid, Class dsfidClass);

  SerializationContext createSerializationContext(DataOutput dataOutput);
  SerializationContext createSerializationContext(DataInput dataInput);

  void writeDSFID(DataSerializableFixedID o, int dsfid, DataOutput out) throws IOException;
  void writeDSFID(DataSerializableFixedID dsfid, DataOutput out) throws IOException;

  Object create(int dsfid, DataInput in) throws IOException, ClassNotFoundException;

  void invokeToData(Object ds, DataOutput out) throws IOException;
  void invokeFromData(Object ds, DataInput in) throws IOException, ClassNotFoundException;

  int readDSFIDHeader(DataInput dis) throws IOException;
  void writeDSFIDHeader(int dsfid, DataOutput out) throws IOException;
}

/** DataSerializableFixedIDprovides iscontext modifiedfor totoData haveand morefromData parameters in toData/fromData serialization methods */
classinterface DataSerializableFixedIDSerializationContext {
  public Version[] getSerializationVersions()ObjectSerializer getSerializer();
  publicVersion int getDSFIDgetSerializationVersion();
}

interface ObjectSerializer {
  public void toDatawriteObject(DataOutputObject outputobj, SerializationContextDataOutput contextoutput) throws IOException;
  public voidObject fromDatareadObject(DataInput input, SerializationContext context) throws ClassNotFoundExceptionIOException, IOExceptionClassNotFoundException;
}


  void invokeToData(Object ds, DataOutput out) throws IOException;
  void invokeFromData(Object ds, DataInput in) throws IOException, ClassNotFoundException;

  public Version getVersionForOrdinalOrCurrent(int ordinal);
}

/** a new superclass of HeapDataOutputStream that separates the methods used with Buffers from
    a bunch of other methods concerning other functionality such as Streamables, PDX, etc. */
class BufferDataOutputStream {
  // methods moved from HeapDataOutputStream unchanged
}

/** DataSerializableFixedID is modified to have more parameters in toData/fromData methods */
class DataSerializableFixedID {
  public Version[] getSerializationVersions();
  public int getDSFID();
  public void toData(DataOutput output, SerializationContext context) throws IOException;
  public void fromData(DataInput input, SerializationContext context) throws ClassNotFoundException, IOException;
}


A collection of other classes A collection of other classes will be moved, virtually unchanged, into the new sub-project to fill out the API:

  • ByteArrayDataInput
  • DataSerializableFixedID will continue to hold all of Geode's DSFID constants until we find a better home for them.
  • DSCODE - basic serialization constants
  • DscodeHelper
  • DSFIDNotFoundException
  • SerializationVersions - interface for backward-compatible serialization
  • ThreadLocalByteArrayCache
  • VersionedDataInputStream
  • VersionedDataOutputStream
  • VersionedDataStream
  • Version - Geode's serialization version class
  • all of Geode's DSFID constants until we find a better home for them.
  • DSCODE - basic serialization constants
  • DscodeHelper
  • DSFIDNotFoundException
  • SerializationVersions - interface for backward-compatible serialization
  • ThreadLocalByteArrayCache
  • VersionedDataInputStream
  • VersionedDataOutputStream
  • VersionedDataStream
  • Version - Geode's serialization version class

Use DSFIDSerializerFactory to create a new serializer.  Set an ObjectSerializer if you want to provide serialization of other types of objects in readObject/writeObject.  Use DSFIDSerializer.registerClass() to register your classes so that the serializer knows how to instantiate them.

The new DSFID serializer sub-project will by and large not be composed of static methods as is InternalDataSerializer and its superclass DataSerializer.  InternalDataSerializer will hold an instance of the DSFIDSerializer and will register DSFID codes and constructors with it.  Instantiation will insert a SerializerPlugin into an ObjectSerializer into the DSFIDSerializer to provide users of the serializer the ability to write PDX, DataSerializables and other interfaces supported by Geode but not (directly) by the DSFIDSerializer.  InternalDataSerializer and DataSerializer will defer serialization of DSFIDs to the DSFIDSerializer instance.

A number of static serialization methods in DataSerializer and InternalDataSerializer will also be shifted into the DSFIDSerializer (writeString/readString, writeHashmap/readHashmap, etc) to maintain compatibility with past releases.  Those methods shifted from DataSerializer will remain available in that class since it is a public API.

...