How to make a photo smaller?
java serialization alternative
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Ñîîáùåñòâà
• Talxy Chat
• Horoscope
• Online
 
Çàðåãèñòðèðóéñÿ!

QAIX > Java Programming > java serialization alternative 10 July 2008 21:18:02

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

java serialization alternative

Rodrick Brown 10 July 2008 21:18:02
 Do any of you guys have experience with Java serialization and what
kind of overheads it causes? As far as I know, it produces very large
messages and is not particularly fast, so I am concerned about that
given that it is pervasively used in our system core for sending
messages between daemons over our messaging API.

One possible alternative is http://xstream.code­haus.org/ which can be
tuned to produce fairly small messages (by aliasing class names and
types for example). However, I have no sense of the speed. I will
do some performance tests.

Comments, questions, etc?


--
[ Rodrick R. Brown ]
http://www.rodrickb­rown.com
http://www.linkedin­.com/in/rodrickbrown­

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Avinash Lakshman 29 March 2008 05:41:34 permanent link ]
 We are building a large scale system which relies on messaging heavily. We tried all kinds of serialization formats: Java, JAXB, XML and JSON with XStream. All of them were useless for high throughput. So we switched to Externalizable style serialization and were able to get much better performance. Which was evident upfront but we didn't have to write that code. Also now it behooves us to come with some kind of versioning scheme so that we push rolling upgrades to the cluster w/o bringing the whole cluster down. I can dig up the numbers if you would like.

A

Date: Fri, 28 Mar 2008 11:18:04 -0400
From: rodrick.brown@GMAIL­.COM
Subject: [ADVANCED-JAVA] java serialization alternative
To: ADVANCED-JAVA@DISCU­SS.DEVELOP.COM
Do any of you guys have experience with Java serialization and what
kind of overheads it causes? As far as I know, it produces very large
messages and is not particularly fast, so I am concerned about that
given that it is pervasively used in our system core for sending
messages between daemons over our messaging API.
One possible alternative is http://xstream.code­haus.org/ which can be
tuned to produce fairly small messages (by aliasing class names and
types for example). However, I have no sense of the speed. I will
do some performance tests.
Comments, questions, etc?
--
[ Rodrick R. Brown ]
===================­================
This list is hosted by DevelopMentor® http://www.develop.­com
View archives and manage your subscription(s) at http://discuss.deve­lop.com

___________________­____________________­____________________­______
How well do you know your celebrity gossip?
http://originals.ms­n.com/thebigdebate?o­cid=T002MSN03N0707A
===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Randall R Schulz 29 March 2008 05:54:25 permanent link ]
 On Friday 28 March 2008 18:41, Avinash Lakshman wrote:
We are building a large scale system which relies on messaging
heavily. We tried all kinds of serialization formats: Java, JAXB, XML
and JSON with XStream. All of them were useless for high throughput.
So we switched to Externalizable style serialization and were able to
get much better performance. Which was evident upfront but we didn't
have to write that code.

Doesn't Externalizable require you to implement the actual conversion to
and from the external format?


...


Randall Schulz

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Avinash Lakshman 29 March 2008 18:54:31 permanent link ]
 Yes it does. But it seemed to worked much better in terms of time taken to do so. I don't seem to remember the exact numbers but increased our throughput by atleast 400%.

Avinash> Date: Fri, 28 Mar 2008 18:54:25 -0700> From: rschulz@SONIC.NET> Subject: Re: [ADVANCED-JAVA] java serialization alternative> To: ADVANCED-JAVA@DISCU­SS.DEVELOP.COM> > On Friday 28 March 2008 18:41, Avinash Lakshman wrote:> > We are building a large scale system which relies on messaging> > heavily. We tried all kinds of serialization formats: Java, JAXB, XML> > and JSON with XStream. All of them were useless for high throughput.> > So we switched to Externalizable style serialization and were able to> > get much better performance. Which was evident upfront but we didn't> > have to write that code.> > Doesn't Externalizable require you to implement the actual conversion to> and from the external format?> > > > ...> > > Randall Schulz> > ===================­================> This list is hosted by DevelopMentor® http://www.develop.­com> > View archives and manage your subscription(s) at http://discuss.deve­lop.com
___________________­____________________­____________________­______
Windows Live Hotmail is giving away Zunes.
http://www.windowsl­ive-hotmail.com/Zune­ADay/?locale=en-US&o­cid=TXT_TAGLM_Mobile­_Zune_V3
===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Attila Szegedi 29 March 2008 18:55:10 permanent link ]
 Hm... Same here - large scale system, with a bunch of stateless
services connected by messaging middleware. However, we never found
serialization to be a bottleneck. Just goes to show that you need to
measure every system separately and that performance advice is hard to
generalize. As a matter of fact, my system scales nicely, so for few
years now we just throw more hardware into it when our business
capacity demands expand.

Attila.

On 2008.03.29., at 2:41, Avinash Lakshman wrote:
We are building a large scale system which relies on messaging
heavily. We tried all kinds of serialization formats: Java, JAXB,
XML and JSON with XStream. All of them were useless for high
throughput. So we switched to Externalizable style serialization and
were able to get much better performance. Which was evident upfront
but we didn't have to write that code. Also now it behooves us to
come with some kind of versioning scheme so that we push rolling
upgrades to the cluster w/o bringing the whole cluster down. I can
dig up the numbers if you would like.
A
Date: Fri, 28 Mar 2008 11:18:04 -0400
From: rodrick.brown@GMAIL­.COM
Subject: [ADVANCED-JAVA] java serialization alternative
To: ADVANCED-JAVA@DISCU­SS.DEVELOP.COM
Do any of you guys have experience with Java serialization and what
kind of overheads it causes? As far as I know, it produces very
large
messages and is not particularly fast, so I am concerned about that
given that it is pervasively used in our system core for sending
messages between daemons over our messaging API.
One possible alternative is http://xstream.code­haus.org/ which can be
tuned to produce fairly small messages (by aliasing class names and
types for example). However, I have no sense of the speed. I will
do some performance tests.
Comments, questions, etc?
--
[ Rodrick R. Brown ]

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Carfield Yim 29 March 2008 20:48:11 permanent link ]
 How do you implement the Externalizable code? Is it just similar to
http://java.sun.com­/developer/TechTips/­2000/tt0425.html or is that better
approach? How do you handle HashMap?

On 3/29/08, Avinash Lakshman <avinashdha@hotmail­.com> wrote:
Yes it does. But it seemed to worked much better in terms of time taken to
do so. I don't seem to remember the exact numbers but increased our
throughput by atleast 400%.
Avinash> Date: Fri, 28 Mar 2008 18:54:25 -0700> From: rschulz@SONIC.NET>
Subject: Re: [ADVANCED-JAVA] java serialization alternative> To:
ADVANCED-JAVA@DISCU­SS.DEVELOP.COM> > On Friday 28 March 2008 18:41,
Avinash Lakshman wrote:> > We are building a large scale system which relies
on messaging> > heavily. We tried all kinds of serialization formats: Java,
JAXB, XML> > and JSON with XStream. All of them were useless for high
throughput.> > So we switched to Externalizable style serialization and were
able to> > get much better performance. Which was evident upfront but we
didn't> > have to write that code.> > Doesn't Externalizable require you to
implement the actual conversion to> and from the external format?> > > >
...> > > Randall Schulz> > ===================­================> This list is
hosted by DevelopMentor(R) http://www.develop.­com> > View archives and
manage your subscription(s) at http://discuss.deve­lop.com
___________________­____________________­____________________­______
Windows Live Hotmail is giving away Zunes.
===================­================
This list is hosted by DevelopMentor(R) http://www.develop.­com
View archives and manage your subscription(s) at

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Olivier Lefevre 29 March 2008 21:43:40 permanent link ]
 There have been so many such systems. Googling for "fast RMI + Java"
should return most of them.

-- O.L.

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Bob Lee 29 March 2008 22:01:58 permanent link ]
 I would also check out Thrift (http://developers.­facebook.com/thrift/­) and
other solutions which use compile time generation instead. We use our own
such approach for everything internally. The thing I like most about these
approaches is that you don't have to worry about NotSerializableExce­ptions
at runtime, and it's much easier to maintain compatibility (I would argue
that reliably maintaining compatibility is almost impossible with
serialization without a robust test suite which easily counteracts the
simplicity of serialization).

Bob

On Fri, Mar 28, 2008 at 8:18 AM, Rodrick Brown <rodrick.brown@gmai­l.com>
wrote:

Do any of you guys have experience with Java serialization and what
kind of overheads it causes? As far as I know, it produces very large
messages and is not particularly fast, so I am concerned about that
given that it is pervasively used in our system core for sending
messages between daemons over our messaging API.
One possible alternative is http://xstream.code­haus.org/ which can be
tuned to produce fairly small messages (by aliasing class names and
types for example). However, I have no sense of the speed. I will
do some performance tests.
Comments, questions, etc?
--
[ Rodrick R. Brown ]
===================­================
This list is hosted by DevelopMentor(R) http://www.develop.­com
View archives and manage your subscription(s) at

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Jeff Kesselman 29 March 2008 23:11:01 permanent link ]
 A dissenting view

Theres a lot of mythology arpound Java Serialization. The fact of the
matter is that, for
the kind of system it is, if you need all it capabilities, its about as
effecieint as anything
else your likely to build. Provided you use it right. We use Java
serialization in Darkstar
and get object accesses, which inbclused both
serialization/deser­ialization and databsase acess)
in the low tenths of ms. (Thats tenths, not tens.)

It is very easy to over-serialize by not properly pruning your object
graph. You need to
be actively aware of what data you are really trying to communicate and
make efective use
of Transient fields to trim the graph.

Keep in mind that you can use Java serialization and take control of the
actual representations
of individual objects if you wish at multiple levels (the most extreme
case being using Externalizable
to take total control threof.)

IMO the question you reallu need tpo ask is, is object level
communication really what you want? if
all you are doing is pushing well known messages around then a byte
packet protocol is always going to
be more efficient and is trivial to implement in Java,

A *sperate* question you need to ask is if RMI is appropriate. RMI is a
synchronous protocol. It blocks until
the foreign call completes. This means you are paying 2-way latency
costs for each call and making your code
synchronous where aynchronicity might be more efficient.

FInally, you strtaed all this with "I suspect that..." Why do you
suspect that? Have you actually profiled
and mesured costs? If not then this counts as premature optimization
asn is likely as not a total waste of time.

--
===================­====================­====================­============
Journalism 101: The difference between news and a press release

News tells you what the reporter thinks is true.

A press release tells you what a company wants *you* to think is true.

Only bad reporters think the two are the same.

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Jeff Kesselman 30 March 2008 00:43:58 permanent link ]
 Avinash Lakshman wrote:
Yes it does. But it seemed to worked much better in terms of time taken to do so.
Likely because you were making conscious or unconscious assumptions
about your code that allowed you to do the coding more efficiently.

If you go to making every communicated object "externalizable" then its
morally equivalent really to building your own packet protocol. About
the only time I can imagine this would be useful is if you wanted to
keep RMI while ditching the Serialization code. Myself i havent run
into a case where default Serialization was inappropriate but RMI still
was....

I don't seem to remember the exact numbers but increased our throughput by atleast 400%.
Avinash> Date: Fri, 28 Mar 2008 18:54:25 -0700> From: rschulz@SONIC.NET> Subject: Re: [ADVANCED-JAVA] java serialization alternative> To: ADVANCED-JAVA@DISCU­SS.DEVELOP.COM> > On Friday 28 March 2008 18:41, Avinash Lakshman wrote:> > We are building a large scale system which relies on messaging> > heavily. We tried all kinds of serialization formats: Java, JAXB, XML> > and JSON with XStream. All of them were useless for high throughput.> > So we switched to Externalizable style serialization and were able to> > get much better performance. Which was evident upfront but we didn't> > have to write that code.> > Doesn't Externalizable require you to implement the actual conversion to> and from the external format?> > > > ...> > > Randall Schulz> > ===================­================> This list is hosted by DevelopMentor® http://www.develop.­com> > View archives and manage your subscription(s) at http://discuss.deve­lop.com
___________________­____________________­____________________­______
Windows Live Hotmail is giving away Zunes.
===================­================
This list is hosted by DevelopMentor® http://www.develop.­com
View archives and manage your subscription(s) at http://discuss.deve­lop.com

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Jeff Kesselman 30 March 2008 00:43:58 permanent link ]
 I ALSO feel a pressing need to add that I find efficiency paranoia over
Serialization a little nutty in a world that has adopted SOAP left right
and center...

Talk about inefficient....

JK


Jeff Kesselman wrote:
Avinash Lakshman wrote:
Yes it does. But it seemed to worked much better in terms of time
taken to do so.
Likely because you were making conscious or unconscious assumptions
about your code that allowed you to do the coding more efficiently.
If you go to making every communicated object "externalizable" then
its morally equivalent really to building your own packet protocol.
About the only time I can imagine this would be useful is if you
wanted to keep RMI while ditching the Serialization code. Myself i
havent run into a case where default Serialization was inappropriate
but RMI still was....
I don't seem to remember the exact numbers but increased our
throughput by atleast 400%.
Avinash> Date: Fri, 28 Mar 2008 18:54:25 -0700> From:
rschulz@SONIC.NET> Subject: Re: [ADVANCED-JAVA] java serialization
alternative> To: ADVANCED-JAVA@DISCU­SS.DEVELOP.COM> > On Friday 28
March 2008 18:41, Avinash Lakshman wrote:> > We are building a large
scale system which relies on messaging> > heavily. We tried all kinds
of serialization formats: Java, JAXB, XML> > and JSON with XStream.
All of them were useless for high throughput.> > So we switched to
Externalizable style serialization and were able to> > get much
better performance. Which was evident upfront but we didn't> > have
to write that code.> > Doesn't Externalizable require you to
implement the actual conversion to> and from the external format?> >
...> > > Randall Schulz> > ===================­================>
This list is hosted by DevelopMentor® http://www.develop.­com> > View
archives and manage your subscription(s) at http://discuss.deve­lop.com
___________________­____________________­____________________­______
Windows Live Hotmail is giving away Zunes.
===================­================
This list is hosted by DevelopMentor® http://www.develop.­com
View archives and manage your subscription(s) at
===================­================
This list is hosted by DevelopMentor® http://www.develop.­com
View archives and manage your subscription(s) at

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Attila Szegedi 30 March 2008 00:43:58 permanent link ]
 On 2008.03.29., at 19:01, Bob Lee wrote:
(I would argue
that reliably maintaining compatibility is almost impossible with
serialization without a robust test suite which easily counteracts the
simplicity of serialization).

Interesting statement - care to elaborate? I've found that evolving
the class design is easy with serialization but then, I've been mostly
adding fields and paid attention that the default value of the field
is okay for existing serialized object representations. On a single
object level, it is basically an object-to-(name-val­ue-pair) codec.
What pitfalls specifically do you have in mind?

Attila.

Bob

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Bob Lee 30 March 2008 00:43:58 permanent link ]
 On Sat, Mar 29, 2008 at 3:10 PM, Attila Szegedi <szegedia@gmail.com­> wrote:
Interesting statement - care to elaborate? I've found that evolving
the class design is easy with serialization but then, I've been mostly
adding fields and paid attention that the default value of the field
is okay for existing serialized object representations. On a single
object level, it is basically an object-to-(name-val­ue-pair) codec.
What pitfalls specifically do you have in mind?

Making compatible changes isn't hard. Identifying incompatible
changes, for example if a programmer makes a change to a class but
forgets to consider serialization, is very tricky. You simply can't
verify compatibility statically with serialization. The only way to
verify that two classes are compatible is to run them and test them.
You can either keep serialized data around in a file or something, or
you can use a trick like this:
http://crazybob.org­/2006/01/unit-testin­g-serialization-evol­ution_13.html.
Either approach is a pain in the butt.

If you use a tool like Thrift, you can check two definitions for
compatibility statically, so for example, you could add a submit check
to your source control system or test suite to detect incompatible
changes.

Bob

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Attila Szegedi 30 March 2008 12:03:12 permanent link ]
 On 2008.03.29., at 23:45, Bob Lee wrote:
Making compatible changes isn't hard. Identifying incompatible
changes, for example if a programmer makes a change to a class but
forgets to consider serialization, is very tricky.

Oh yes, I completely agree with that.

You simply can't
verify compatibility statically with serialization.

Yep, one could actually append "... by definition" here, right? :-)­

The only way to
verify that two classes are compatible is to run them and test them.
You can either keep serialized data around in a file or something, or
you can use a trick like this:
.
Either approach is a pain in the butt.

Right - the real pain (which your blog entry doesn't show) is when
both classes are actually two versions of the same class, so you must
ensure you have both .class files available somewhere, have them
loaded through different class loaders, and then persuade the
ObjectInputStream to deserialize to the right class (as it's
notoriously ignorant of thread context class loader...). PITA indeed.

Although, alternatively, you could try reading ObjectStreamClass and
its ObjectStreamField objects from the stream and comparing them
against the in-memory class... oh well, actually you can't as if the
object has a custom writeObject/readObj­ect, or is Externalizable, this
approach'd fail. (Just thinking out loud.)

If you use a tool like Thrift, you can check two definitions for
compatibility statically, so for example, you could add a submit check
to your source control system or test suite to detect incompatible
changes.

Nice - thanks for the pointer. I wonder how easy is it to extract this
functionality from Thrift, as otherwise it seems to be geared toward
RPC, and I'm more on the async messaging side of architecture...

Attila.

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Jeff Kesselman 30 March 2008 21:35:30 permanent link ]
 Bob Lee wrote:
On Sat, Mar 29, 2008 at 3:10 PM, Attila Szegedi <szegedia@gmail.com­> wrote:
Interesting statement - care to elaborate? I've found that evolving
the class design is easy with serialization but then, I've been mostly
adding fields and paid attention that the default value of the field
is okay for existing serialized object representations. On a single
object level, it is basically an object-to-(name-val­ue-pair) codec.
What pitfalls specifically do you have in mind?
Making compatible changes isn't hard. Identifying incompatible
changes, for example if a programmer makes a change to a class but
forgets to consider serialization, is very tricky.
This is an issue we will be having to deal with down the line with
darkstar based apps. I've been toying mentally with the idea of a tool
that would take as input a serialized graph, an old code base, and a new
code base, and allow you to work interactively to solve an
incompatibilities, hopefully resultign in what is effectively a
translation script.

Obviously, this is not a trivial thing... Im still musign over all the
issues.

JK



You simply can't
verify compatibility statically with serialization. The only way to
verify that two classes are compatible is to run them and test them.
You can either keep serialized data around in a file or something, or
you can use a trick like this:
Either approach is a pain in the butt.
If you use a tool like Thrift, you can check two definitions for
compatibility statically, so for example, you could add a submit check
to your source control system or test suite to detect incompatible
changes.
Bob
===================­================
This list is hosted by DevelopMentor® http://www.develop.­com
View archives and manage your subscription(s) at http://discuss.deve­lop.com

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Jeff Kesselman 30 March 2008 21:39:02 permanent link ]
 Btw, There is one oddity about the rules that IMO mostly goes back to
pedanticism on the part of the people who designed them

You can remove a primitive field
You can add a primitive field
But you cannot change the type of a primitive field directly, even
though this is logically equivalent to a remove followed by an add.


Attila Szegedi wrote:
On 2008.03.29., at 19:01, Bob Lee wrote:
(I would argue
that reliably maintaining compatibility is almost impossible with
serialization without a robust test suite which easily counteracts the
simplicity of serialization).
Interesting statement - care to elaborate? I've found that evolving
the class design is easy with serialization but then, I've been mostly
adding fields and paid attention that the default value of the field
is okay for existing serialized object representations. On a single
object level, it is basically an object-to-(name-val­ue-pair) codec.
What pitfalls specifically do you have in mind?
Attila.
Bob
===================­================
This list is hosted by DevelopMentor® http://www.develop.­com
View archives and manage your subscription(s) at

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Jeff Kesselman 30 March 2008 21:40:58 permanent link ]
 Jeff Kesselman wrote:
Bob Lee wrote:
On Sat, Mar 29, 2008 at 3:10 PM, Attila Szegedi <szegedia@gmail.com­>
wrote:
Interesting statement - care to elaborate? I've found that evolving
the class design is easy with serialization but then, I've been mostly
adding fields and paid attention that the default value of the field
is okay for existing serialized object representations. On a single
object level, it is basically an object-to-(name-val­ue-pair) codec.
What pitfalls specifically do you have in mind?
Making compatible changes isn't hard. Identifying incompatible
changes, for example if a programmer makes a change to a class but
forgets to consider serialization, is very tricky.
This is an issue we will be having to deal with down the line with
darkstar based apps. I've been toying mentally with the idea of a tool
that would take as input a serialized graph, an old code base, and a new
code base, and allow you to work interactively to solve an
incompatibilities, hopefully resultign in what is effectively a
translation script.
From another pov, think of this as the serialization moral equivalent
of a codebase merge tool

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Bob Lee 30 March 2008 22:27:29 permanent link ]
 On Sun, Mar 30, 2008 at 1:03 AM, Attila Szegedi <szegedia@gmail.com­> wrote:
Right - the real pain (which your blog entry doesn't show) is when
both classes are actually two versions of the same class, so you must
ensure you have both .class files available somewhere, have them
loaded through different class loaders, and then persuade the
ObjectInputStream to deserialize to the right class (as it's
notoriously ignorant of thread context class loader...). PITA indeed.

The blog entry does address that. If you want to use the old classes
as is, you have to keep the class files around, you have to load them
in a separate classloader, and you have to somehow test them, but this
would be difficult (the same test code touching two different
instances of the same class loaded by different class loaders?!).

In the blog entry, I recommend copying the old code into the test
directory under a different name. My serialization utility enables you
to serialize it under the fake name and deserialize it under the real
name, and vice versa. It's hacky but much easier than the alternative,
IMO.

If you use a tool like Thrift, you can check two definitions for
compatibility statically, so for example, you could add a submit check
to your source control system or test suite to detect incompatible
changes.
Nice - thanks for the pointer. I wonder how easy is it to extract this
functionality from Thrift, as otherwise it seems to be geared toward
RPC, and I'm more on the async messaging side of architecture...

I assume you could just use the IDL functionality on its own, but I
haven't used Thrift before. I've used a few similar proprietary
frameworks though.

Bob

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Bob Lee 30 March 2008 22:28:31 permanent link ]
 On Sun, Mar 30, 2008 at 11:27 AM, Bob Lee <crazybob@crazybob.­org> wrote:
I assume you could just use the IDL functionality on its own, but I
haven't used Thrift before. I've used a few similar proprietary
frameworks though.

I mean, I assume you could just use the flattenning/seriali­zation
functionality on its own.

Bob

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Bob Lee 30 March 2008 22:40:22 permanent link ]
 Serialization sounds good in theory, but you really want to decouple
your code from its persistent state. Tools like Thrift force you to do
it. Serialization makes it easy not to do it--i.e. you really should
use the DTO pattern, but many people don't. If you couple your code
and its persistent state, you might be able to add a field here and
there, but what happens when you want to perform big refactorings and
rewrites? Your runtime classes may not match the serialized forms
anymore; serialization doesn't handle this well. To make matters
worse, the serialization format is very opaque and difficult to tool
with anything besides the original class. I think this is one of many
reasons why relational databases are still so much more popular for
long term persistence.

Bob

On Sun, Mar 30, 2008 at 11:28 AM, Bob Lee <crazybob@crazybob.­org> wrote:
On Sun, Mar 30, 2008 at 11:27 AM, Bob Lee <crazybob@crazybob.­org> wrote:
I assume you could just use the IDL functionality on its own, but I
haven't used Thrift before. I've used a few similar proprietary
frameworks though.
I mean, I assume you could just use the flattenning/seriali­zation
functionality on its own.
Bob

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Jeff Kesselman 31 March 2008 00:48:00 permanent link ]
 Bob Lee wrote:
Serialization sounds good in theory, but you really want to decouple
your code from its persistent state.

Well, not in our case.

Rally this sounds like the old RDBMS/OODB argument and there are palces
and tiems where either makes more sense.

JK
Tools like Thrift force you to do
it. Serialization makes it easy not to do it--i.e. you really should
use the DTO pattern, but many people don't. If you couple your code
and its persistent state, you might be able to add a field here and
there, but what happens when you want to perform big refactorings and
rewrites? Your runtime classes may not match the serialized forms
anymore; serialization doesn't handle this well. To make matters
worse, the serialization format is very opaque and difficult to tool
with anything besides the original class. I think this is one of many
reasons why relational databases are still so much more popular for
long term persistence.
Bob
On Sun, Mar 30, 2008 at 11:28 AM, Bob Lee <crazybob@crazybob.­org> wrote:
On Sun, Mar 30, 2008 at 11:27 AM, Bob Lee <crazybob@crazybob.­org> wrote:
I assume you could just use the IDL functionality on its own, but I
haven't used Thrift before. I've used a few similar proprietary
frameworks though.
I mean, I assume you could just use the flattenning/seriali­zation
functionality on its own.
Bob
===================­================
This list is hosted by DevelopMentor® http://www.develop.­com
View archives and manage your subscription(s) at http://discuss.deve­lop.com

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment


Bob Lee 31 March 2008 00:48:00 permanent link ]
 On Sun, Mar 30, 2008 at 4:30 PM, Jeff Kesselman
<Jeffrey.Kesselman@­sun.com> wrote:
Well, not in our case.

You say that until one of your users wants to rewrite something
without losing all their data. Even with short lived data, I seem to
run into situations where I want to upgrade the code without losing
the short lived data. Serialization is a big risk here. Even if I
tested compatibility well, I'm still not certain my upgrade won't
break something (one NotSerializableExce­ption breaks everything).

I used to think HttpSessions fell into the category of use cases where
serialization made sense, but even there I no longer recommend it. You
don't want all of your users to lose their sessions every time you
redeploy your web app. Maintaining compatibility is way too hard, so I
typically use rolling restarts, where you keep the old servers running
until the old session are gone, but those are complicated and error
prone, and some users still lose their sessions. Why should a user
lose their state after an hour? Ideally, they'd be able to come back
in three days and pick up where they left off.

I think this sort of transparent flattenning can work fine in a
dynamically typed language but not so well in a statically typed
language like Java.

Bob

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Jeff Kesselman 31 March 2008 00:48:00 permanent link ]
 Bob Lee wrote:
On Sun, Mar 30, 2008 at 4:30 PM, Jeff Kesselman
<Jeffrey.Kesselman@­sun.com> wrote:
Well, not in our case.
You say that until one of your users wants to rewrite something
without losing all their data.

There are plenty of things that can be re-written without losing data.
See "serialization compatible changes." Beyond that, as i mentioned
before, I'm already looking at ways to build a merge-type tool.

The fact of the matter is I need transparent POJO data management for my
client base and I know of no other way to achieve that. I recognize the
need for a small segment of the data to be relational in terms of access
and that we're looking at providing a back-door for.

At the end of the day there are always advantages and limits to every
tchhnique. A good craftsman does not so fall in love with his hammer he
forgets how to turn a screw, or vice versa.

And if he hist himself in the thumb with the hammer a few times, he
asks "what am i doing wrong with this tool." He doesn't throw it away.

JK

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment


Bob Lee 31 March 2008 00:48:00 permanent link ]
 On Sun, Mar 30, 2008 at 5:17 PM, Jeff Kesselman
<Jeffrey.Kesselman@­sun.com> wrote:
There are plenty of things that can be re-written without losing data.
See "serialization compatible changes."

You can make much more significant changes than those while
maintaining compatibility. See putFields() and readFields(). Like I
said, the problems with serialization are detecting incompatible
changes, no static foundation upon which to build tools, testing
compatibility, and it breaks down when you try to perform non trivial
refactorings: class renames, breaking one class down into a couple,
etc. You're effectively stuck with your original design so long as you
have data generated by that design.

Beyond that, as i mentioned
before, I'm already looking at ways to build a merge-type tool.

I'll look forward to your writing that, but I'm skeptical that the
result will be as user friendly and robust as other approaches.

The fact of the matter is I need transparent POJO data management for my
client base and I know of no other way to achieve that.

I'm not expert by JRuby might be an option. If you don't need static
type safety in your flattenning, perhaps you don't need it in the rest
of your code?

At the end of the day there are always advantages and limits to every
tchhnique. A good craftsman does not so fall in love with his hammer he
forgets how to turn a screw, or vice versa.

I'm not sure what you're trying to say here. There definitely aren't
always advantages to every technique. Are you trying to sell me on
serialization? I've used it extensively on multiple projects over the
years.

And if he hist himself in the thumb with the hammer a few times, he
asks "what am i doing wrong with this tool." He doesn't throw it away.

Sure, blame the flawed design on the user. :-)­

Bob

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Bob Lee 31 March 2008 00:48:00 permanent link ]
 On Sun, Mar 30, 2008 at 5:40 PM, Bob Lee <crazybob@crazybob.­org> wrote:
I'm not expert by JRuby might be an option.

That should say, "I'm no expert, but JRuby might be an option."

Bob

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment


Bob Lee 31 March 2008 04:48:13 permanent link ]
 On Sun, Mar 30, 2008 at 5:17 PM, Jeff Kesselman
<Jeffrey.Kesselman@­sun.com> wrote:
The fact of the matter is I need transparent POJO data management for my
client base and I know of no other way to achieve that.

Here's another idea. You could generate static data descriptors and
marshaling code from the user's code. If they don't need to maintain
compatibility, they can throw away and regenerate them after they
change their code. If they do need to maintain compatibility, they'll
be in a much better position to do so than they would be with
serialization. You could create Serialization 2.0.

Bob

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Olivier Lefevre 31 March 2008 18:55:54 permanent link ]
 --- Bob Lee <crazybob@CRAZYBOB.­ORG> wrote:
Serialization sounds good in theory, but you really want to decouple
your code from its persistent state. [...] I think this is one of many
reasons why relational databases are still so much more popular for
long term persistence.

And, a contrario,