View Single Post
  #2 (permalink)  
Old 08-26-2003
benoit's Avatar
benoit benoit is offline
ZeroC Staff
 
Name: Benoit Foucher
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Rennes, France
Posts: 1,535
Re: Confused with IcePack

Quote:
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):

Code:
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

Quote:

2. How do I change the server so that it would use this facility?
I would change your server code to the following:

Code:
 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):

Code:
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).

Quote:


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:

Code:
// 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:

Code:
Proxy=jclCommand@jsocket01
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...).

Quote:


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.
Reply With Quote