I have a drb server on one machine, which is basically started with:
def server(uri)
puts "uri is #{uri}, self is #{self}"
primary = DRb::DRbServer.new(uri, self)
# May want to do something else here.
p primary.class.ancestors
return primary
end
called with “druby://:0”
I then have a client, which is given the resulting url, and started
like this:
@remote_server = remote_server(serverURI)[1]
where
def remote_server(uri)
primary = DRb::DRbServer.new
remote = DRb::DRbObject.new(nil, uri)
puts "in #{caller()}, <Contractor> remote is #{remote}"
return primary, remote
end
and uri is that obtained from the running server. I.e. I’m using
the server to share work out to the clients, who do the fragments
for the server.
Fine. However, after the client connects to the server object
(which it does successfully) when the server invokes a method of the
client’s, that method is exected on the server machine, not on the
client machine.
I know this because I created a instance method of the client class:
def ping
x = "#{caller(0)[0]} #{Socket.gethostname} #{$$}"
puts x
return x
end
which always yields the name of the server machine, not the client
machine. Plus the print statements appear in the wrong window.
Furthermore, when the client sees code in the server running the
caller(0)[0] is a druby uri, but when my server runs client methods
the calller(0)[0] is just a normal file:line_number type expression
Is there anything I have missed in this?
How can I test an object in a server to see if it is remote or local?
Will certain kinds of objects always end up as local after being
sent to a server – if for example they contain references to IO
objects which cannot be marshalled, or maybe references to the
sever?
The thing is, I’m fairly sure the simplified version of this code
worked when it doe no I/O or serious work.
Thank you,
Hugh