IceDiscovery
6 min read
6 min read
6 min read
6 min read
6 min read
6 min read
6 min read
6 min read
6 min read
IceDiscovery Overview
IceDiscovery provides a location service using UDP multicast that allows Ice applications to discover objects and object adapters.
IceDiscovery is an Ice plug-in that you install in both clients and servers. It installs a locator in the communicator: your clients use indirect proxies, such as greeter@greeterAdapter or greeter, with no server endpoints and no locator endpoints in their configuration. In a server, an object adapter with an adapter ID registers its endpoints with this locator. In a client, this locator resolves an indirect proxy by sending a lookup request over multicast to the servers; the server that hosts this object adapter or this object replies to the client.
IceDiscovery and IceGrid both provide a location service. IceDiscovery needs no additional process: the clients and servers of your application find each other on the local network with UDP multicast, as long as the servers are running. IceGrid provides its location service through a registry that you deploy and configure, and also manages your servers, with features such as on-demand server activation, replication and remote administration. To discover an IceGrid registry with multicast, use IceLocatorDiscovery.
Installing IceDiscovery
Install the IceDiscovery plug-in in every client that needs to locate objects and in every server that hosts those objects. IceDiscovery sends its lookup requests with UDP multicast, so your network must support it.
You should install IceDiscovery in your communicator using the pluginFactories field of InitializationData:
#include <IceDiscovery/IceDiscovery.h>
Ice::InitializationData initData;initData.properties = Ice::createProperties(argc, argv);initData.pluginFactories = {IceDiscovery::discoveryPluginFactory()};
Ice::CommunicatorPtr communicator = Ice::initialize(initData);Alternatively, you can install the IceDiscovery plug-in at runtime using configuration:
Ice.Plugin.IceDiscovery=IceDiscovery:createIceDiscoveryWhen you use pluginFactories, link your application with the IceDiscovery library.
You should install IceDiscovery in your communicator using the pluginFactories field of InitializationData:
var initData = new Ice.InitializationData{ properties = new Ice.Properties(ref args), pluginFactories = [new IceDiscovery.PluginFactory()]};
await using Ice.Communicator communicator = Ice.Util.initialize(initData);Alternatively, you can install the IceDiscovery plug-in at runtime using configuration:
Ice.Plugin.IceDiscovery=IceDiscovery:IceDiscovery.PluginFactoryYou should install IceDiscovery in your communicator using the pluginFactories field of InitializationData:
InitializationData initData = new InitializationData();initData.properties = new com.zeroc.Ice.Properties(args);initData.pluginFactories = java.util.List.of(new com.zeroc.IceDiscovery.PluginFactory());
try (Communicator communicator = new Communicator(initData)) { // Use the communicator.}Alternatively, you can install the IceDiscovery plug-in at runtime using configuration:
Ice.Plugin.IceDiscovery=com.zeroc.IceDiscovery.PluginFactoryThis mapping includes the IceDiscovery factory. Enable it with:
Ice.Plugin.IceDiscovery=1Configuring IceDiscovery
Applications configure IceDiscovery with properties. IceDiscovery installs its own locator as the default locator of the communicator: do not set Ice.Default.Locator in an application that installs IceDiscovery.
IceDiscovery Property Overview
IceDiscovery works without any configuration: all the clients and servers use the same default multicast address and port.
The main properties are:
- IceDiscovery.DomainId separates unrelated applications that use the same multicast address and port: a client includes its domain ID in each lookup request, and a server ignores the requests for another domain ID.
- IceDiscovery.Address and IceDiscovery.Port set the multicast address and port. The clients and servers of an application must use the same values.
- IceDiscovery.Interface restricts the plug-in to one network interface. By default, the plug-in uses all interfaces.
For example, to use a different multicast address and port:
IceDiscovery.Address=239.255.0.99IceDiscovery.Port=8000See IceDiscovery Properties for the complete list.
Configuring IceDiscovery in Servers
Install the plug-in in your server and, if your application changes the default multicast address, port or domain ID, set these properties in the server as well. Then configure an adapter ID for each object adapter whose objects clients discover. For example, for an object adapter named GreeterAdapter, set its AdapterId property:
GreeterAdapter.AdapterId=greeterAdapterThe adapter ID must be unique among the servers that share the same address and domain settings. The object adapter registers its endpoints when you activate it.
To replicate an object adapter, also set its ReplicaGroupId property:
GreeterAdapter.AdapterId=greeter-1234GreeterAdapter.ReplicaGroupId=greeterPoolThe indirect proxy greeter@greeter-1234 refers to the object greeter in this particular object adapter, whereas greeter@greeterPool refers to the object greeter in any of the object adapters of the replica group greeterPool.
Configuring IceDiscovery in Clients
Install the plug-in in your client and, if your application changes the default multicast address, port or domain ID, set these properties in the client as well. The client uses an indirect proxy for the object, in one of two forms:
greeter@greeterAdapter: an identity with an adapter ID or a replica group ID.greeter: a well-known proxy, which holds only the identity.
Discovery Process
When the Ice runtime resolves an indirect proxy for the first time, the client's plug-in sends a lookup request over multicast and waits for the reply of a server. The plug-in waits for IceDiscovery.Timeout milliseconds, and sends the request again up to IceDiscovery.RetryCount times. For a replica group, the plug-in also waits for the replies of the other replicas, for a duration derived from the time the first reply took and IceDiscovery.LatencyMultiplier, and returns the endpoints of all the replicas that replied. For a well-known proxy, a server replies when one of its object adapters with an adapter ID hosts the object, through a servant in its Active Servant Map, a default servant or a servant locator; the plug-in then resolves this adapter ID with a second lookup.
The Ice runtime keeps the result in its locator cache, and the client communicates directly with the server from then on.