From: Jack Xu Date: 2008-01-28T01:57:11+09:00 Subject: Re: Ruby Class Object Serialization -- HELP ------=_Part_9319_13425100.1201453036907 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Phlip, thanks for the response. Yes, please let me know about the process to set up the p-code nodes. I am looking for a solution that essentially works like Marshal.dump (which serializes the attributes of a object and sending it around), but should also be able to carry the meta content such as attribute alias, methods, & associations (as in ActiveRecord::Base). The requirement is that, after these classes are constructed at run time, the app should be able to upload them to a memcache server and then download them to each cluster app server and quickly re-construct the classes (with its meta content) . I have thought about using DRb. Because these classes that are constructed at runtime are at the core of my app, I think using DRb is going to add too much overhead to the system performance. Plus these classes can be constructed at any app server. Jack On Jan 25, 2008 11:10 PM, Phlip wrote: > Jack Xu wrote: > > I have created a ruby class at runtime with its methods created using > > class_eval, and I would like to share this class definition on all the > > clustered servers. One way I can think of doing is to marshal/serialize > > it up and send it to memcache, so that other servers can access it. > > Obviously, this doesn't work because according to Module class > > definition: "bindings, procedure or method objects, instances of class > > IO, or singleton objects can't be dumped". > > In theory, because the class fully exists at runtime as a big stack of > nodes > (essentially the p-code of Ruby), one could "disassemble" those p-codes, > and > reconstitute classes as source. Then one could trivially mail these > around. Ask > if you'd like to do it that way and I'l set you up. > > However, I can't help thinking your outer problem could use a re-think. > Can you > use DRb (Distributed Ruby), send handles to these objects out to the other > hosts, and let them call your objects? or would that load the system the > wrong way? > > -- > Phlip > > ------=_Part_9319_13425100.1201453036907 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Phlip, thanks for the response. Yes, please let me know about the process to set up the p-code nodes.

I am looking for a solution that essentially works like Marshal.dump (which serializes the attributes of a object and sending it around), but  should also be able to carry the meta content such as attribute alias, methods, & associations (as in ActiveRecord::Base). The requirement is that, after these classes are constructed at run time, the app should be able to upload them to a memcache server and then download them to each cluster app server and quickly re-construct the classes (with its meta content) .

I have thought about using DRb. Because these classes that are constructed at runtime are at the core of my app, I think using DRb is going to add too much overhead to the system performance. Plus these classes can be constructed at any app server.

Jack

On Jan 25, 2008 11:10 PM, Phlip <phlip2005@gmail.com> wrote:
Jack Xu wrote:
> I have created a ruby class at runtime with its methods created using
> class_eval, and I would like to share this class definition on all the
> clustered servers. One way I can think of doing is to marshal/serialize
> it up and send it to memcache, so that other servers can access it.
> Obviously, this doesn't work because according to Module class
> definition: "bindings, procedure or method objects, instances of class
> IO, or singleton objects can't be dumped".

In theory, because the class fully exists at runtime as a big stack of nodes
(essentially the p-code of Ruby), one could "disassemble" those p-codes, and
reconstitute classes as source. Then one could trivially mail these around. Ask
if you'd like to do it that way and I'l set you up.

However, I can't help thinking your outer problem could use a re-think. Can you
use DRb (Distributed Ruby), send handles to these objects out to the other
hosts, and let them call your objects? or would that load the system the wrong way?

--
  Phlip


------=_Part_9319_13425100.1201453036907--