Results 1 to 9 of 9

Thread: simple IcePack demo?

  1. #1
    bterwijn is offline Registered User
    Name: Bas Terwijn
    Organization: University of Amsterdam
    Project: distributed systems
    Join Date
    May 2005
    Location
    Haarlem, The Netherlands, Europe
    Posts
    9

    simple IcePack demo?

    I'm trying to get the indirect binding working, with no success until now. Is there an example simular to:

    Ice-2.1.0/demo/IcePack/simple

    But then without the 'application.xml' file that is required to start the server??

    Or maybe there are instructions on how to modify the 'Server.cpp' file so that it can be run from the commandline directly using './server' so without 'icepackadmin'.

    thanks for your time,
    Bas Terwijn

  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
    Yes, you can just try this with the demo/Ice/hello demo. If you take a look at the config file you'll find the following lines at the end:

    Code:
    #                                                                               
    # Uncomment the following lines if you want to run this demo with the           
    # IcePack registry. Note that we override properties previously set             
    # above, so make sure to comment out these properties to run the demo           
    # without IcePack.                                                              
    #                                                                               
    #Hello.Proxy=hello@HelloAdapter                                                 
    #Hello.Endpoints=tcp:udp:ssl                                                    
    #Hello.AdapterId=HelloAdapter                                                   
    #Ice.Default.Locator=IcePack/Locator:default -p 10006
    These properties configure the server and client to use indirect binging. Uncomment these lines and then to run the demo:

    Code:
       $ cd Ice-2.1.1/demo/Ice/hello
       $ icepackregistry --Ice.Config=config
       $ ./server
       $ ./client
    Hope this helps!

    Benoit.

  3. #3
    bterwijn is offline Registered User
    Name: Bas Terwijn
    Organization: University of Amsterdam
    Project: distributed systems
    Join Date
    May 2005
    Location
    Haarlem, The Netherlands, Europe
    Posts
    9
    Thanks for your quick reply.

    The 'demo/Ice/hello' demo uses the 'config' file to share the name of the adapter as shown below (slightly modified):

    config:
    Ice.Default.Locator=IcePack/Locator:default -p 10006
    Hello.Endpoints=default
    Hello.AdapterId=HelloAdapter

    server:
    Ice::ObjectAdapterPtr adapter= communicator()->createObjectAdapter("Hello");
    Ice::ObjectPtr object = new HelloI;
    adapter->add(object,Ice::stringToIdentity("hello"));

    client:
    string proxy = "hello@HelloAdapter";
    Ice::ObjectPrx base = communicator()->stringToProxy(proxy);
    HelloPrx hello = HelloPrx::checkedCast(base);

    This works but I have two problems with this solution:

    1) I don't want to have the adapter defined in the config file because then I need to update this file every time I add a new object type (besides the Hello type). I tried different ways but failed. How can this be done?

    2) An adapter seems to be associated with a particular host, meaning that I have to define multiple adapters when I have multiple hosts running servers that all provide Hello objects under different names (This seems to conflict with the location transparancy). How can this be avoided?

    Ideally I'm looking for a solution simular to:

    config:
    Ice.Default.Locator=IcePack/Locator:default -p 10006
    #NO ADAPTERS SPECIFIED

    server:
    Ice::ObjectPtr object = new HelloI;
    communicator()->add(object,Ice::stringToIdentity("hello123"));
    #OBJECT PUBLISHED UNDER NAME 'hello123', NO ADAPTER USED

    client:
    string proxy = "hello123";
    Ice::ObjectPrx base = communicator()->stringToProxy(proxy);
    HelloPrx hello = HelloPrx::checkedCast(base);

    Something like this is simple, I don't see why Ice has to make things more difficult then this. Paragraph 35.3.2 of the Ice2.1.0 manual seems to describe something similar where the object is only referred to by its identity (not in combination with an adapter). Is this correct?

    Please send me any suggestions that you might have, Thanx in advance.
    Bas Terwijn

  4. #4
    bernard's Avatar
    bernard is offline ZeroC Staff
    Name: Bernard Normier
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Palm Beach Gardens, FL
    Posts
    1,294
    Hi Bas,

    You can use the same object adapter with many types of objects ... there is no need to create a separate adapter per type. If you don't want any per-adapter configuration, you can specify your endpoints programmatically: use createObjectAdapterWithEndpoints(name, endpoints) instead of createObjectAdapter(name).

    Using adapter ids instead of hostnames/IP addresses and ports in your proxies provides location transparency: you can move your server (with its adapters) to another host and the proxies will remain valid.

    IcePack maintains an Adapter table (to resolve adapter ids) and an Object table (to resolve simple proxies with just the identity like your "hello123"). You can create entries in this Object table with icepackadmin, programmatically using the IcePack::Admin interface, and with IcePack deployment descriptors (see 35.9.13 in the Ice 2.1.0 manual).

    Cheers,
    Bernard
    Last edited by bernard; 05-25-2005 at 11:49 AM.

  5. #5
    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
    Here's how your code would look like if you want to register the object using the IcePack::Admin interface:

    Code:
    config:
    -------
    Ice.Default.Locator=IcePack/Locator:default -p 10006
    
    client:
    ------
    string proxy = "hello123";
    Ice::ObjectPrx base = communicator()->stringToProxy(proxy);
    HelloPrx hello = HelloPrx::checkedCast(base);
    
    server:
    -------
    #include <IcePack/Admin.h>
    ...
    Ice::ObjectPtr object = new HelloI;
    Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapterWithEndpoints("Hello", "default");
    Ice::ObjectPrx proxy = adapter->add(object, Ice::stringToIdentity("hello123"));
    
    IcePack::AdminPrx admin = IcePack::AdminPrx::checkedCast(communicator->stringToProxy("IcePack/Admin"));
    admin->addObjectWithType(proxy, proxy->ice_id())
    Let us know if you need more information!

    Benoit.

  6. #6
    bterwijn is offline Registered User
    Name: Bas Terwijn
    Organization: University of Amsterdam
    Project: distributed systems
    Join Date
    May 2005
    Location
    Haarlem, The Netherlands, Europe
    Posts
    9

    Thanks

    hi Bernard and Benoit,

    Thanks, I got it working now, your help is greatly appreciated.

    I don't fully understand the difference yet between your suggestion and my earlier attempt,.... back to reading the manual I suppose.

    keep up the good work,
    Bas Terwijn

  7. #7
    bterwijn is offline Registered User
    Name: Bas Terwijn
    Organization: University of Amsterdam
    Project: distributed systems
    Join Date
    May 2005
    Location
    Haarlem, The Netherlands, Europe
    Posts
    9

    IcePack::AdminPrx

    dear Zeroc people,

    I have a question regrding the 'IcePack::AdminPrx' type.

    I'm trying to hide most of the complexity of writing Ice clients, servers, publishers and subscibers by putting it im my class 'IAS_Application' which is derived from the 'Ice::Application' class as shown below:

    #include <Ice/Ice.h>
    #include <IcePack/Query.h>

    using namespace std;

    class IAS_Application : virtual public Ice::Application
    {
    public:
    int main(int argc, char *argv[], const char *cp = 0)
    {
    cout<<"IAS_Application: initializing"<<endl;
    return Ice::Application::main(argc,argv,cp);
    };

    virtual int run(int argc, char *argv[])
    {
    IcePack::AdminPrx admin= IcePack::AdminPrx::checkedCast(communicator()->stringToProxy("IcePack/Admin"));
    // other initialization, e.g. IceStorm
    // Terminate cleanly on receipt of a signal
    shutdownOnInterrupt();
    cout<<"IAS_Application: done initializing"<<endl;

    return IAS_run(argc,argv);
    };

    virtual int IAS_run(int argc, char *argv[]) =0;
    }



    But when I compile (a server for example) I get the following error message:

    "error: `AdminPrx' is not a member of `IcePack'"

    I can't seem to fix this but the strange thing is that I can use 'IcePack::AdminPrx' in my server itself without any problems (as recommended above in this thread by Benoit):

    #include <IAS_Application.h>
    #include <IcePack/Admin.h>

    using namespace std;

    class MyApplication : virtual public IAS_Application
    {
    public:
    virtual int IAS_run(int argc, char *argv[]) {

    IcePack::AdminPrx admin =
    IcePack::AdminPrx::checkedCast( communicator()->stringToProxy("IcePack/Admin"));



    What could be the problem (I'm using Ice2.1.1)?
    Do you have any advise on how to try and fix it?

    thank you for your time,
    Bas Terwijn

  8. #8
    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
    Quote Originally Posted by bterwijn
    dear Zeroc people,

    I have a question regrding the 'IcePack::AdminPrx' type.

    I'm trying to hide most of the complexity of writing Ice clients, servers, publishers and subscibers by putting it im my class 'IAS_Application' which is derived from the 'Ice::Application' class as shown below:

    #include <Ice/Ice.h>
    #include <IcePack/Query.h>
    You should include <IcePack/Admin.h> here instead of <IcePack/Query.h>. Then, you just need to include <IAS_Application.h> in your server sources (no need to include <IcePack/Admin.h>).

    Hope this helps!

    Benoit.

  9. #9
    bterwijn is offline Registered User
    Name: Bas Terwijn
    Organization: University of Amsterdam
    Project: distributed systems
    Join Date
    May 2005
    Location
    Haarlem, The Netherlands, Europe
    Posts
    9
    Thank you very much for your responds.

    I now realize I have made a stupid 'copy-paste' error which I overlooked for three hours. Sorry to have bothered you with such a trivial error.

    greetings,
    Bas Terwijn

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. iceGrid/simple demo with replication
    By prettyMan in forum Help Center
    Replies: 8
    Last Post: 06-10-2010, 04:32 PM
  2. Simple IceGrid Java Demo for a total Newbie
    By zhi in forum Help Center
    Replies: 17
    Last Post: 07-09-2009, 03:15 PM
  3. Simple Ice Pack Demo
    By Narendranath in forum Help Center
    Replies: 2
    Last Post: 06-17-2005, 09:22 AM
  4. what's wrong with my IcePack demo
    By Mjollnir in forum Help Center
    Replies: 4
    Last Post: 01-01-2005, 03:27 AM
  5. IceJ-1.5.0: test of IcePack/simple fails
    By SteveWampler in forum Help Center
    Replies: 2
    Last Post: 07-28-2004, 10:54 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
  •