Results 1 to 9 of 9

Thread: Searching object adapter for servants

  1. #1
    ctennis is offline Registered User
    Name: Caleb Tennis
    Organization: AEI
    Project: Project GINA
    Join Date
    Mar 2006
    Posts
    123

    Searching object adapter for servants

    This is probably too late for 3.3, but one thing that would be handy would be to be able to get a list of servants from an object adapter based on a passed in string category. Something like:

    Ice::ObjectSeq findByCategory(string category);

    (and probably one for specific facets as well).

    This can be incredibly handy because then you don't have to maintain a list outside of the adapter of all of the servants in it if you want to be able to iterate over that list for some reason (maybe you need to get the name of each of the servants, for example).
    Caleb Tennis
    Analytical Engineering, Inc.
    http://www.aei-tech.com
    Project: Our facility infrastructure heavily utilizes Ice

    Gentoo ebuild maintainer for Ice, IceRuby, etc.

  2. #2
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    We could add an operation that returns a subset (or all) of the map. The application would have to make sure though that, by the time it gets around to using the result, the result still makes sense because the ASM may have been modified by other threads in the mean time.

    Could you explain a little more about what you are trying to do? Maybe there is another way to achieve what you need. (I'm not opposed to adding such an operation to the ASM per se, but I want to be sure that there is no reasonable alternative for achieving the same thing in the application.)

    Cheers,

    Michi.
    Last edited by michi; 11-27-2007 at 06:48 PM.

  3. #3
    ctennis is offline Registered User
    Name: Caleb Tennis
    Organization: AEI
    Project: Project GINA
    Join Date
    Mar 2006
    Posts
    123

    Question

    I wrote a long winded explanation to this, but when I got to the end of it I came to the conclusion that everything I want/need to do can be implemented via a little smart logic with servant locators. I can just create a new subclass of the servant locator that implements the logic I want, then subclass it again into my actual locators that will handle the specific categories.

    I think the main "issue" stems to the fact that there's no way to get a servant back from an object adapter unless you explicitly know its whole identity. There are times when I don't want to have to keep track of individual object identities, but instead throw a bunch of servants into a single "category" and be able to get back a list of those objects later so I can iterate over them...perhaps in a background thread that performs an "update" of their internal data.

    Right now the only way to do this is to create my own map that contains the objects (either alongside an object adapter's ASM or inside of a servant locator). The first is a bit redundant and prone to some error, especially if you're adding or removing servants throughout the code as you have to make sure you're also adding/removing them from your secondary map. The latter is a better way of going about it, but then means you lose all of the advantages of having the ASM keeping track of your servants for you, and makes the program a bit more complex.

    So I think my "feature request" is more to save from having to go the full blown route of implementing servant locators just to be able to more easily consider servants at the category level instead of the individual object level.
    Caleb Tennis
    Analytical Engineering, Inc.
    http://www.aei-tech.com
    Project: Our facility infrastructure heavily utilizes Ice

    Gentoo ebuild maintainer for Ice, IceRuby, etc.

  4. #4
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Hi Caleb,

    yes, I understand where you are coming from. We'll consider adding something like this (but no promises!)

    Cheers,

    Michi.

  5. #5
    paolo is offline Registered User
    Name: paolo volpi
    Organization: tvblob
    Project: tvblob blobbox
    Join Date
    Aug 2007
    Posts
    22
    That feature would be very useful also for me thx

  6. #6
    joshmoore is offline Registered User
    Name: Josh Moore
    Organization: Glencoe Software, Inc.
    Project: OMERO, http://trac.openmicroscopy.org.uk/omero
    Join Date
    Feb 2007
    Location
    Germany
    Posts
    115
    +1 Though I haven't tried the servant locator solution, I do often have an accompanying hash map from id to servant which has to been kept in sync with the ASM. If there are no locking issues, etc., it seems like it would be helpful. And since even when just acquiring a single servant from the ASM, there is a race condition, I'd be for it. Thanks, ~J.

  7. #7
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    It seems you can do what you want by simply using a default servant that implements its own hash map. That way, the ASM is empty and all the identity-to-servant mappings are taken care of by your default servant. Now you can iterate over the map (or perform whatever other operation you need) to your heart's content.

    With this approach, any concurrency issues are now the responsibility of your implementation. That's as it should be, seeing that you know a lot more about concurrency of your application than the Ice run time does.

    So, overall, it seems to me that it is better for you to implement a default servant than it would be for the Ice run time to provide an API that risks returning stale information to the application.

    Cheers,

    Michi.

  8. #8
    joshmoore is offline Registered User
    Name: Josh Moore
    Organization: Glencoe Software, Inc.
    Project: OMERO, http://trac.openmicroscopy.org.uk/omero
    Join Date
    Feb 2007
    Location
    Germany
    Posts
    115
    For others, see 32.9.2 Default servants which I found while wondering if there wouldn't need to be several default servants. And there would. One per type. And (32.8 Default servants) the category whould need to be the type? Will this work with glacier then where the category must be the session id?

    If the combination is ok, then like the servant locator solution, it sounds very workable, but I still think for very simple use cases, find/search methods by type/category on the object adapter would be handy even if it's the consumers responsibility to check the "liveness" of any servant. (Typically, I want to find all servants with a glacier session as category in order to remove it.)

    Thanks, Michi.
    ~Josh.

  9. #9
    michi's Avatar
    michi is offline Registered User
    Name: Michi Henning
    Organization: Triodia Technologies
    Project: I have a passing interest in Ice :-)
    Join Date
    Feb 2003
    Location
    Brisbane, Australia
    Posts
    1,055
    Quote Originally Posted by joshmoore View Post
    And (32.8 Default servants) the category whould need to be the type? Will this work with glacier then where the category must be the session id?
    This is an issue only if:

    • a client provides callback objects to a server
    • the callback objects have different Slice types
    • the client implements the callback objects with a default servant or servant locator

    In this case, the category of the object identity is used by Glacier2 to demultiplex callbacks from the server to the clients and you have to either mangle the object type into the name member, or implement the client's callback objects using the usual ASM approach.

    Cheers,

    Michi.
    Last edited by michi; 01-28-2009 at 06:54 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find object in object adapter by its proxy
    By dnnbg in forum Help Center
    Replies: 2
    Last Post: 02-25-2009, 04:09 AM
  2. object adapter question
    By mwilson in forum Help Center
    Replies: 2
    Last Post: 11-17-2006, 08:28 PM
  3. Replicated Object Adapter
    By vsonnathi in forum Help Center
    Replies: 3
    Last Post: 04-13-2005, 03:30 PM
  4. how to get an object adapter from the communicator
    By paulling in forum Help Center
    Replies: 1
    Last Post: 11-26-2003, 12:29 AM
  5. How does the object adapter work?
    By catalin in forum Help Center
    Replies: 0
    Last Post: 10-29-2003, 09:13 AM

Posting Permissions

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