From: Eric Hodel Date: 2006-04-11T03:10:21+09:00 Subject: Re: do i have to use DRbUndumped? On Apr 10, 2006, at 8:23 AM, holy sinner wrote: > i am currently using Ruby 1.8.4 and DRb 2.0.4, and i am stuck with > some marshalling problem > related to tuplespace. this is my hello world code using tuplespace > > --- > #HelloWorld.rb > require "rinda/ring" > > class HelloWorld > # include DRbUndumped > def initialize(str) > @str = str > end > def _dump(dumpDepth) > @str > end > def HelloWorld._load(srcString) > HelloWorld.new(srcString) > end > def to_s > @str > end > end > > DRb.start_service > > ringServer = Rinda::RingFinger.primary > tupleSpace = ringServer.read([:name, :TupleSpace, nil, nil])[2] > tupleSpace = Rinda::TupleSpaceProxy.new tupleSpace > > tupleSpace.write(["helloWorldObject", HelloWorld.new("Hello World!")]) > > aHelloWorldObject = tupleSpace.take(["helloWorldObject", nil]) > puts aHelloWorldObject[1] > > #DRb.thread.join > > --- > > my problem is that _dump doesn't work, because the HelloWorld > object gets converted into DRb::DRbUnknown, which can not be > converted into tuple to be inserted into the tuplespace. it does > not occur if i use DRb::DRbUndumped, but i think using > DRb::DRbUndumped is rather unsecure if i try using read instead of > take to get the object out of the tuplespace. Unsecure? Why? If you're worried about losing the object due to the taking process dying use a TupleSpaceProxy. It ensures that the object won't get lost. > the question is: > - what's wrong with my _dump (and _load) ? do i have to use > DRb::DRbUndumped ? You should really use marshal_load and marshal_dump. DRb::DRbUndumped must be used on objects that don't have their class present on all ruby processes in the system. > - do i have to use Rinda::Ring to work with Rinda::TupleSpace ? No. Rinda::Ring lets you find DRb services easily. It is zeroconf for DRb. -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com