Confused with IcePack

amrufonamrufon AlexOrganization: ISTProject: jDatabaseMember ✭✭
Hello.

I was able to get my Ice project going the standard client and server mechanism where the in the client, the IP address of the server is explicitly declared during initialization or direct binding.

So now, I want to use the IcePack facility ... unfortunately, I'm getting bewildered with the documentation and when I looked into the IcePack Hello demo ... I got more confused.

As a background, what I want to do are two things:
1. Indirect binding with one server adapter and many clients.
2. Indirect binding where on one server, I'll run multiple copies of my Ice server application but with different (but well defined) adapter names. ex. jsockets01, jsockets02, jsockets03, etc. Of course the clients should be able to connect to specific adapters that they need.
NOTE: I dont need IcePack NODES. I manually start the servers.

So what am I confused about? Well, I'll list them:
1. What to put into the config file?
- I understand the the config file should be passed as parameter to the icepackregistry program but what do I put into it to address my requirements.

2. How do I change the server so that it would use this facility?
- I currently initialize my server with the following code:
Ice::ObjectAdapterPtr adapter =
communicator()->createObjectAdapterWithEndpoints(
"jclCommandAdapter", "default -p 7012 -z");
Ice::ObjectPtr object = new jSocketsI;
adapter->add(object,
Ice::stringToIdentity("jclCommand"));
adapter->activate();
The IcePack/Hello demo shows that to initialize the server:
Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("Hello");

string id = communicator()->getProperties()->getProperty("Identity");

Ice::ObjectPtr object = new HelloFactoryI();
adapter->add(object, Ice::stringToIdentity(id));
adapter->activate();
but checking the CONFIG file that came with the demo, theres no declaration for the adapter called "Hello". In my case, I sort of want to dynamically change the name during startup that I would have 10 servers with adapter names like jsocket01 to jsocket10.

3. How do I change the client initialization to use the IcePack adapter?
- I initialize the client codes with this:
// Create a proxy for the root directory
std::string proxy;
proxy+= "jclCommand:default -h ";
proxy+= hostname;
proxy+= " -p 7012 -z";

Ice::ObjectPrx base = ic->stringToProxy(proxy);
unfortunately, I'm having a hard time understanding again the docs and the sample in IcePack/Hello/Client.cpp file is no help.

Can somebody explain what is actually required in a straight forward manner?

Thanks for any help.

Alex

P.S.
I think I need to sleep. Its already 3:15am and I'm tired and grouchy.

Comments

  • benoitbenoit Rennes, FranceBenoit FoucherOrganization: ZeroC, Inc.Project: IceAdministrators, ZeroC Staff ZeroC Staff
    Re: Confused with IcePack
    Originally posted by amrufon
    Hello.

    I was able to get my Ice project going the standard client and server mechanism where the in the client, the IP address of the server is explicitly declared during initialization or direct binding.

    So now, I want to use the IcePack facility ... unfortunately, I'm getting bewildered with the documentation and when I looked into the IcePack Hello demo ... I got more confused.

    As a background, what I want to do are two things:
    1. Indirect binding with one server adapter and many clients.
    2. Indirect binding where on one server, I'll run multiple copies of my Ice server application but with different (but well defined) adapter names. ex. jsockets01, jsockets02, jsockets03, etc. Of course the clients should be able to connect to specific adapters that they need.
    NOTE: I dont need IcePack NODES. I manually start the servers.

    So what am I confused about? Well, I'll list them:
    1. What to put into the config file?
    - I understand the the config file should be passed as parameter to the icepackregistry program but what do I put into it to address my requirements.

    You need to put the following properties in the IcePack registry configuration file (let's assume it's called config_icepack):
    IcePack.Registry.Client.Endpoints=default -p 11000
    IcePack.Registry.Server.Endpoints=default
    IcePack.Registry.Admin.Endpoints=default
    IcePack.Registry.Data=<path to the directory of the IcePack registry database directory>
    IcePack.Registry.DynamicRegistration=1
    

    The endpoint properties will configure IcePack endpoints, only the client endpoint needs to have a fixed port. The database directory must exist to start the registry. The DynamicRegistration property needs to be set to 1 to allow non-registered adapters to be added when they are activated. Start the IcePack registry with this configuration file in a terminal:

    bash$ mkdir db
    bash$ icepackregistry --Ice.Config=config_icepack

    2. How do I change the server so that it would use this facility?

    I would change your server code to the following:
     Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("jclCommandAdapter");
     Ice::ObjectPtr object = new jSocketsI;
     adapter->add(object, Ice::stringToIdentity("jclCommand"));
     adapter->activate();
    

    Then you start each server with the following configuration file (let's assume it's called config_server):
    jclCommandAdapter.Endpoints=default -z
    jclCommandAdapter.AdapterId=jsocket01
    Ice.Default.Locator=IcePack/Locator:default -h <registry host name> -p 11000
    

    Of course, you need to change the AdapterId property for each of your servers and "<registry host name>" should be replaced by the host name where the IcePack registry is running. Start each server with this configuration file (i.e.: by passing the --Ice.Config=config_server command line argument).


    3. How do I change the client initialization to use the IcePack adapter?


    I would recommend to use a property in your client to configure the proxy of the object you want to use:
    // Create a proxy for the root directory
    std::string proxy = ic->getProperties()->getProperty("Proxy");
    Ice::ObjectPrx base = ic->stringToProxy(proxy);
    

    In your client configuration file (let's assume it's called config_client), you need to set the following properties:
    [email protected]
    Ice.Default.Locator=IcePack/Locator:default -h <registry host name> -p 11000
    

    Start your client with this configuration file (i.e.: by passing the --Ice.Config=config_client command line argument...).


    unfortunately, I'm having a hard time understanding again the docs and the sample in IcePack/Hello/Client.cpp file is no help.

    Can somebody explain what is actually required in a straight forward manner?

    Thanks for any help.

    Yes, forget about the IcePack/Hello demo :). This demo demonstrates the use of the IcePack registry, node and deployment mechanism which is a little more complicated than just using the registry with manually launched servers.

    The Ice/hello demo actually contains some configuration to use the hello world demo in a similar scenario (i.e.: indirect binding, manually launched server). Here's some instructions on how to use it (I assume your current directory is Ice-1.1.0/demo/Ice/hello):
    • In a terminal, start the IcePack registry:
      bash$ mkdir db
      bash$ icepackregistry --Ice.Config=config
    • Edit the demo/Ice/hello/config file to uncomment the last 4 lines (these lines configure the Hello server and client to use the IcePack registry)
    • In another terminal start the server:
      bash$ ./server
    • In another terminal start the client:
      bash$ ./client --Ice.Trace.Location=1

    Let me know if these instructions are not clear enough!

    Benoit.
  • amrufonamrufon AlexOrganization: ISTProject: jDatabaseMember ✭✭
    Hello Benoit,

    I really appreciate your help. Things really get clearer after you get some sleep. ;)

    I was actually converting my codes as to your suggestion ... unfortunately, I found-out that I dont have the IcePack binaries. I'm using windows and .NET and when I looked at the Visual Studio Solution file that came with version 1.1.0 ... its not defined.

    Thanks again for the help.

    Alex
  • OrNotOrNot Bin.LiOrganization: GE HealthcareProject: Enterprise solutionMember
    I am coufused by the property"IcePack.Registry.Server.Endpoints".

    The doc said:
    Defines the endpoints of the IcePack server interface. The server endpoints must be accessible to Ice servers that are using IcePack to register their object adapter
    endpoints.


    So I think that these endpoints are used by ice servers to communicate to register their adapters or objects.

    According to this idea, I try the fellowing configurations,

    ------- config--icepackregistry
    IcePack.Registry.Client.Endpoints=default -p 10006
    IcePack.Registry.Server.Endpoints=default -p 10000
    IcePack.Registry.Internal.Endpoints=default
    IcePack.Registry.Admin.Endpoints=default
    IcePack.Registry.Data=db
    IcePack.Registry.DynamicRegistration=1


    -------- config-client
    [email protected]
    Ice.Default.Locator=IcePack/Locator:default -p 10006


    ---------config-server
    Hello.Endpoints=tcp:udp:ssl
    Hello.AdapterId=HelloAdapter
    Ice.Default.Locator=IcePack/Locator:default -p 10000



    But When I run the server.exe, I got errors:


    .\Outgoing.cpp:359: Ice::ObjectNotExistException:
    object does not exist
    identity: IcePack/Locator
    facet:
    operation: getRegistry

    It seems that I misunderstood something about the property. Can anyone help me?
  • matthewmatthew NL, CanadaMatthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications EngineMember ✭✭✭
    The servers configuration file is incorrect. The locator proxy is always set to the client endpoint. The fact that you are configuring a "server" is irrelevant. The "IcePack.Registry.Server.Endpoints" is using for internal communications, and does not need to have a fixed port endpoint -- that is just "default" will work fine.

    Regards, Matthew
  • OrNotOrNot Bin.LiOrganization: GE HealthcareProject: Enterprise solutionMember
    Thanks a lot.

    But , I still feel confused by this property. Could you give me some examples in that we have to set the "IcePack.Registry.Server.Endpoints" instead of the default value?

    And , How to understand the "Client" and "Server" concepts in this circumstance of icpackregistry?

    Sorry,I can not deeply understand the property discribed by the doc due to my English.


    Best regards.
  • matthewmatthew NL, CanadaMatthew NewhookOrganization: ZeroC, Inc.Project: Internet Communications EngineMember ✭✭✭
    An IcePack "client" is an application that uses IcePack the IcePack query interface. This can happen explicitely (namely a direct application call on the IcePack::Query interface), or by the runtime through indirect binding.

    An IcePack "server' is an application that is managed by IcePack. That is a server that is described in a deployment descriptor, and then subsequently started either on-demand by an icepacknode, or started by hand if the process is a manual service.

    The only circumstance that I can think you'd want to directly set the port on the endpoints other than client (which must run on a fixed port) is if you have some firewall rules within your internal network.

    Regards, Matthew
  • OrNotOrNot Bin.LiOrganization: GE HealthcareProject: Enterprise solutionMember
    Thank you.
    I will try to dig into the souce codes to find more answers.
Sign In or Register to comment.