Professional Web Applications Themes

Removing methods from DRbObject - Ruby

My application is using DRb extensively in support of its client-server model. Ideally I would like to have the remote objects in the client scripts appear exactly as they would if they were local. All my data objects include DRb::DRbUndumped so that only references are passed across the network, as the objects' code needs to run on the server (database access etc). Unfortunately, DRb::DRbObject defines a bunch of methods which it doesn't really use, such as ==, ===, <=> etc; but because it defines them, calls to them don't get proxied to the server. The Criteria module has in it ...

  1. #1

    Default Removing methods from DRbObject

    My application is using DRb extensively in support of its client-server
    model. Ideally I would like to have the remote objects in the client
    scripts appear exactly as they would if they were local. All my data
    objects include DRb::DRbUndumped so that only references are passed
    across the network, as the objects' code needs to run on the server
    (database access etc). Unfortunately, DRb::DRbObject defines a bunch of
    methods which it doesn't really use, such as ==, ===, <=> etc; but
    because it defines them, calls to them don't get proxied to the server.

    The Criteria module has in it a neat little bit of code that looks like
    this:

    mask = ["__send__", "__id__", "inspect", "class", "is_a?", "dup",
    "instance_eval"];
    methods = instance_methods(true)
    methods = methods - mask

    methods.each do |m|
    undef_method(m)
    end

    This removes all methods from the class except those in mask.
    Something like this in DRb::DRBObject, with an appropriate mask list,
    would be really useful, because at the moment, if I have two DRbObjects
    which represent the same object on the remote side, the == method still
    returns false because of the way DRbObject defines == (the default way,
    if it's not exactly the same object they're not equal).

    Therefore I have three questions:
    1) Is this a reasonable change to make?
    2) What is an appropriate mask list to use for DRb::DRbObject?
    3) Can I get this change into the core library?

    --
    Tim Bates
    id.au


    Tim Guest

  2. #2

    Default Re: Removing methods from DRbObject


    "Tim Bates" <id.au> schrieb im Newsbeitrag
    news:id.au... 

    I'll prefer to raise another issue: usually it is not a good idea to
    reference masses of instances remotely. Thies yields hight network load
    since lot's of methods are not invoked locally but remotely. This can
    degenerate to a degree where an application is no longer usable. Did you
    verify that your application does not suffer from this performance
    degeneration? If not, I'd first verify that usig lots of instances
    remotely is practical. While transparent distribution of instances sounds
    like a good thing, a typical application using distribution should / must
    be aware of the distribution in order to do things efficiently. In your
    case it *might* be better to transfer an array or hash of data objects to
    the client, work with then and send them back afterwards.

    Just my 0.02EUR...

    Kind regards

    robert

    Robert Guest

  3. #3

    Default Re: Removing methods from DRbObject

    Tim Bates wrote: 

    You might want consider requiring drb/eq, which defines #== and #hash in
    terms of the remote reference, rather than object identity.


    Joel Guest

  4. #4

    Default Re: Removing methods from DRbObject

    Joel VanderWerf wrote: 

    class DRbObject
    def ==(other)
    return false unless DRbObject === other
    (ref == other.__drbref) && (uri == other.__drburi)
    end

    This doesn't do what I want either. It does some comparison of whether
    they represent *the same object* on the remote side. In my case, they
    don't - but the remote objects have a definition of #== that makes them
    equal. This doesn't solve my problem.

    By undefining #==, #inspect, #class and so on, you could make a
    DRbObject appear and behave exactly like the local one. I'm not sure how
    many of these such methods it is wise to undefine, though - some may be
    crucial to the way DRb works. Can someone with a knowledge of the
    internals of DRb please tell me if I'll get into trouble by undefining
    the wrong methods, and what those methods are?

    --
    Tim Bates
    id.au


    Tim Guest

Similar Threads

  1. #26350 [NEW]: Inherited methods can't access private methods
    By forseti at oak dot rpg dot pl in forum PHP Development
    Replies: 0
    Last Post: November 21st, 02:31 PM
  2. Replies: 8
    Last Post: July 18th, 04:34 PM
  3. Removing desktop icon from one account is removing from all accounts
    By Kyle in forum Windows Setup, Administration & Security
    Replies: 1
    Last Post: July 3rd, 03:04 PM
  4. Removing XP
    By Jerry in forum Windows XP/2000/ME
    Replies: 3
    Last Post: July 1st, 04:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139