Serialization, RMI and deep copy

From: JP (notb2000_at_yahoo.com)
Date: 10/30/03


Date: Thu, 30 Oct 2003 11:46:26 -0500

All,

I need help with the following problem that stretches the limit of my
limited Java experience.

Situation:
In a centralized management application, I have a in-memory store
(singleton) that contains configuration information. Multiple clients can
request, through RMI, a configuration update (difference of what they have
vs what the store now contains). These updates can be very large and the
client requests can happen at any time (asynchronous). A web browser is also
a client of the store and can insert configuration changes.

Problem:
It takes a non-negligible amount of time to serve a configuration update
request from a client. First, the store must calculate what information is
pertinent, then that update object must be serialized through RMI. While
that is happening, the store must be locked to maintain data consistency.
The consequence is the browser responsiveness goes down the tube, especially
if we're dealing with poor network conditions that make serialization
slow/fail.

Proposed solution:
To minimize the store locking period, I propose to make a copy of the
configuration update object right after the calculation, release the store
lock and return the copy through RMI. Since the update object can be quite
complex, I thought of using serialization for the deep-copy operation. If I
can serialize to a data structure of some kind (ByteArrayOutputStream?), I
could return that object through RMI and the clients could de-serialize
their updates.

Facts:
The configuration object can be serialized. We have plenty of memory for the
copy operation. The design must withstand network failure conditions.

Questions:
- How do I do this? I'm pretty sure I could write the updates to a
ByteArrayOutputStream, but the client will need an InputStream of some sort
to read the object.

- Is it more efficient to "RMI" a byte array than a complex object if they
are of the same size? Since I want to serialize my update object prior to
the RMI call returning (for deep-copy purpose), I was hoping there was a way
to make the RMI serialization more efficient. Otherwise, it sounds like
duplicated work.

Thanks in advance for any help you can provide,
JP



Relevant Pages

  • Re: State Management
    ... John, ... > serialization. ... > temporarily store state. ... > handling the storage of user specific data as you're giving every user ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Storing an object info
    ... > I had a method in my mind which is to store an object in the file and read ... I mention performance because often serialization of objects isn't terribly ... efficient compared to more specific saving strategies. ... e.g. different versions of class files. ...
    (comp.lang.java.programmer)
  • Re: Why Serialization
    ... said that you can store a control in the state it is, but for the array ... control in the state as it is, but you can also use it to sent an object ... in the state it is pver the line without XML serialization. ...
    (microsoft.public.dotnet.general)
  • Re: nullreferenceexception for Private Object Variables
    ... In process session state can store the object as is in memory, ... serialization. ... > actually store objects themselves, or just XML representations of them? ... >> |> I have created a class which contains some private object variables, ...
    (microsoft.public.dotnet.framework.aspnet)