public class OptiObjectOutputStream extends ObjectOutputStream
An ObjectOutputStream which optimizes storage by using a common ClassDescriptorStorage for maintaining the Class Descriptors for the class used in serialization. An index pointing to the central array of descriptors in the ClassDescriptorStorage is what is present in the stream.
The ClassDescriptorStorage is required to be up and working whenever a new class is encountered that is not present in the Local copy of the ClassDescriptors when writeObject method is called. If syncToStore field is set to true the ClassDescriptor storage is automatically updated with the local ClassDescriptors in that case. If the store attempt fails because the ClassDescriptors was updated in the store since it was read the operation is attempted again. If syncToStore is set to false then it is the responsibility of the user of this class to update the store with the new Class Descriptors available via the getUpdatedDescriptors method. If the update fails then the writeObject should be called again. Setting syncToStorage false is better since it makes fewer interactions with the store. However the user has to update the store when new Classes are encountered and the writeObject should be called again if the update fails. For retrying the writeObject the user has to either use a local Byte Array stream or use the mark/reset feature on a BufferedOutputStream. aredis uses false for syncToStorage.
This class is used by the OPTI_JAVA_HANDLER or aredis.
ObjectOutputStream.PutField
baseWireHandle, PROTOCOL_VERSION_1, PROTOCOL_VERSION_2, SC_BLOCK_DATA, SC_ENUM, SC_EXTERNALIZABLE, SC_SERIALIZABLE, SC_WRITE_METHOD, STREAM_MAGIC, STREAM_VERSION, SUBCLASS_IMPLEMENTATION_PERMISSION, SUBSTITUTION_PERMISSION, TC_ARRAY, TC_BASE, TC_BLOCKDATA, TC_BLOCKDATALONG, TC_CLASS, TC_CLASSDESC, TC_ENDBLOCKDATA, TC_ENUM, TC_EXCEPTION, TC_LONGSTRING, TC_MAX, TC_NULL, TC_OBJECT, TC_PROXYCLASSDESC, TC_REFERENCE, TC_RESET, TC_STRING
Constructor and Description |
---|
OptiObjectOutputStream(OutputStream out,
ClassDescriptorStorage pdescriptorsStorage)
Creates an OptiObjectOutputStream with syncToStorate as true.
|
OptiObjectOutputStream(OutputStream out,
ClassDescriptorStorage pdescriptorsStorage,
boolean psyncToStorage)
Creates an OptiObjectOutputStream.
|
Modifier and Type | Method and Description |
---|---|
ClassDescriptors |
getUpdatedDescriptors()
Gets the updated descriptors.
|
boolean |
isSyncToStorage()
Checks whether syncToStorage is enabled.
|
protected void |
writeClassDescriptor(ObjectStreamClass desc) |
annotateClass, annotateProxyClass, close, defaultWriteObject, drain, enableReplaceObject, flush, putFields, replaceObject, reset, useProtocolVersion, write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFields, writeFloat, writeInt, writeLong, writeObject, writeObjectOverride, writeShort, writeStreamHeader, writeUnshared, writeUTF
public OptiObjectOutputStream(OutputStream out, ClassDescriptorStorage pdescriptorsStorage, boolean psyncToStorage) throws IOException
out
- Underlying OutputStreampdescriptorsStorage
- Whether to sync the local class descriptors to store whenever a new class is
encountered in writeObject. This is simpler to use.psyncToStorage
- Class Descriptors store to useIOException
- In case of IO errorpublic OptiObjectOutputStream(OutputStream out, ClassDescriptorStorage pdescriptorsStorage) throws IOException
out
- Underlying OutputStreamIOException
- In case of IO errorprotected void writeClassDescriptor(ObjectStreamClass desc) throws IOException
writeClassDescriptor
in class ObjectOutputStream
IOException
public ClassDescriptors getUpdatedDescriptors()
public boolean isSyncToStorage()
Copyright © 2013- Suresh Mahalingam. All Rights Reserved.