Results 1 to 4 of 4

Thread: A problem about IceGrid's replicated servers

  1. #1
    rc_hz is offline Registered User
    Name: Eric RC
    Organization: www.genband.com
    Project: No project yet
    Join Date
    Jul 2004
    Location
    Hangzhou, China
    Posts
    189

    A problem about IceGrid's replicated servers

    If two servers implement differenct interfaces, but they have the same identity(for example: thePrinter@theAdapter), what will happen if they register to IceRegistry ? Can IceRegistry reject the second server's registration ? The following is my demo code:

    --------------------Printer.ice---
    module Demo
    {
    interface PrinterA
    {
    void printStringA(string s);
    };

    interface PrinterB
    {
    void printStringB(string s);
    };
    };

    --------------------ServerA.cpp----
    class PrinterAI : public PrinterA {
    public:
    virtual void printString(const string & s,
    const Ice::Current &);
    };

    int
    main(int argc, char* argv[])
    {
    int status = 0;
    Ice::CommunicatorPtr ic;
    try {
    ic = Ice::initialize(argc, argv);
    Ice::ObjectAdapterPtr adapter
    = ic->createObjectAdapterWithEndpoints("theAdapter", "default -p 10000");
    Ice::ObjectPtr object = new PrinterAI;

    //objectId: thePrinter@theAdapter - implementation the PrinterA interface
    adapter->add(object,
    Ice::stringToIdentity("thePrinter"));
    adapter->activate();
    ic->waitForShutdown();
    } catch (const Ice::Exception & e) {
    //...
    }
    }

    ---------------------ServerB.cpp---
    class PrinterBI : public PrinterB {
    public:
    virtual void printString(const string & s,
    const Ice::Current &);
    };
    //...

    int
    main(int argc, char* argv[])
    {
    int status = 0;
    Ice::CommunicatorPtr ic;
    try {
    ic = Ice::initialize(argc, argv);
    Ice::ObjectAdapterPtr adapter
    = ic->createObjectAdapterWithEndpoints("theAdapter", "default -p 10001");
    Ice::ObjectPtr object = new PrinterBI;

    //objectId: thePrinter@theAdapter - implementation the PrinterB interface
    adapter->add(object,
    Ice::stringToIdentity("thePrinter"));
    adapter->activate();
    ic->waitForShutdown();
    } catch (const Ice::Exception & e) {
    //...
    }
    }
    Eric RC
    www.genband.com (telecommunication)
    I like ICE (Ice for C++/Java/Python)

  2. #2
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    IceGrid isn't released yet . I'll describe how IcePack currently handle this, IceGrid won't be different in this respect.

    At the object adapter level, IcePack will do the following:
    • If you're not using dynamic registration (i.e.: IcePack.Registry.DynamicRegistration=0) , the IcePack registry will prevent you from registering 2 object adapters with the same id. It will also prevent you from activating an object adapter with a given id if an adapter with the same id is already activated (assuming this adapter was registered explicitly with the registry).
    • If you're using dynamic registration (i.e.: IcePack.Registry.DynamicRegistration=1), IcePack won't prevent you from activating an object adapter with a given id twice.

    At the object level, there's nothing to prevent you from using the same identity for different objects. You have to ensure that your objects use a different identity. The only case where it makes sense to use the same identity is for a replicated object.

    Benoit.

  3. #3
    rc_hz is offline Registered User
    Name: Eric RC
    Organization: www.genband.com
    Project: No project yet
    Join Date
    Jul 2004
    Location
    Hangzhou, China
    Posts
    189
    Quote Originally Posted by benoit
    At the object level, there's nothing to prevent you from using the same identity for different objects. You have to ensure that your objects use a different identity. The only case where it makes sense to use the same identity is for a replicated object.

    Benoit.
    Thank you!

    Can IcePack restrict that differenct objects using the same identity must confirm to the same interface ? Maybe this is very useful!
    Eric RC
    www.genband.com (telecommunication)
    I like ICE (Ice for C++/Java/Python)

  4. #4
    benoit's Avatar
    benoit is offline ZeroC Staff
    Name: Benoit Foucher
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Rennes, France
    Posts
    2,196
    Note that registering an object with the Ice object adapter won't automatically register it with the IcePack registry. To register it with the registry, you need to use the IcePack::Admin interface or the deployment descriptors.

    It would be possible to automatically register objects with the IcePack registry and add some checks at the time of the registration. However, this would add some overhead for applications which register many objects...

    It's probably better if you ensure at the application level that your objects use a unique identity, you can for example use UUIDs for this purpose.

    Benoit.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Logging all calls for IceGrid node servers
    By cfrauenberger in forum Help Center
    Replies: 4
    Last Post: 01-24-2011, 04:33 AM
  2. Replies: 6
    Last Post: 12-11-2008, 03:34 AM
  3. icegrid servers current path
    By paolo in forum Help Center
    Replies: 1
    Last Post: 09-10-2007, 10:32 AM
  4. icegrid with glacier2 and replicated icestorms
    By bigtim in forum Help Center
    Replies: 3
    Last Post: 08-14-2007, 11:17 AM
  5. Starting servers with IceGrid::Admin
    By borax00 in forum Help Center
    Replies: 2
    Last Post: 03-18-2007, 11:00 PM

Posting Permissions

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