The role of the discovery service is to enable dynamic domain management. Recall that domain management means management of all the servers running in the domain, from the common administration point represented by a master server.
The discovery service allows a master to detect servers starting and stopping in the domain. Moreover, a master can discover servers there were already running in the domain when it started.
The discovery service implements a greeting mechanism to enforce servers' name unicity in the domain. This mechanism prevents starting a new server in the domain, if a server having the same name is already running in the domain.
There are two available implementations for the discovery service: one based on IP multicast, the other based on JGroups. The former, introduced in JOnAS 4, is deprecated. The latter, has the advantage to allow for cluster daemons detection.
All servers and in the domain must choose the same implementation. The choice is made upon the implementation class name:
###################### JOnAS Discovery service # # Set the name of the implementation class and initialization parameters # JGropus implementation jonas.service.discovery.class=org.ow2.jonas.discovery.jgroups.JgroupsDiscoveryServiceImpl # Uncomment this to set Multicast implementation #jonas.service.discovery.class=org.ow2.jonas.discovery.internal.MulticastDiscoveryServiceImpl
You have to provide initialization parameters in jonas.properties file for:
Multicast address and port. These must be identical for all servers in the domain. Use properties:
jonas.service.discovery.multicast.address
jonas.service.discovery.multicast.port
beware that multicast adresses must be consequently allocated through the network.
The time-to-live for packets: use property:
jonas.service.discovery.ttl
this parameter indicates the number of gateway hops for packets.
if ttl = 0 the discovery scope is the host (multicast packet aren't routed to network interfaces).
if ttl =1 the discovery scope is limited to the subnetworks the host is attached to (multicast packets cross the network interfaces but will be discarded by the next gateway).
if ttl =N>1 the discovery packets may cross N-1 gateways (provided that these gateways are configured to propagate multicast packets).
In the case of a master server, the jonas.service.discovery.source.port property must be set with an available port number.
The greeting mechanism. Use properties:
jonas.service.discovery.greeting.port
jonas.service.discovery.greeting.timeout
Note that two servers on the same host must have different values in greeting.port property.
Example:
jonas.service.discovery.multicast.address=224.224.224.224 jonas.service.discovery.multicast.port=9080 jonas.service.discovery.ttl=1 # For a master server, configure the client source port with this property jonas.service.discovery.source.port=9888 # A multicast greeting message is sent out when discovery service is started. # The starting server listens at the port jonas.service.discovery.greeting.port # (default 9899) for a response for jonas.service.discovery.greeting.timeout miliseconds # (default 1000 ms). If a pre-existing server has the same server name as this one, # this server's discovery service will be terminated. jonas.service.discovery.greeting.port=9899 jonas.service.discovery.greeting.timeout=1000
JGropups configuration being more complex, a specific configuration file have to be used. The name of this file is given by the jonas.service.discovery.jgroups.conf property. Two other properties have to be initialized:
The name of the JGroups group used by the the discovery service to exchange messages.
jonas.service.discovery.group.name
The reconnection timeout for the JGroups channel.
jonas.service.discovery.group.reconnection.timeout
Example:
jonas.service.discovery.jgroups.conf=jgroups-discovery.xml jonas.service.discovery.group.name=JGroupsDiscovery jonas.service.discovery.group.reconnection.timeout=5000
You can find in JOnAS distribution, under
JONAS_ROOT/conf
, a jgroups-discovery.xml
file. This file containes a JGroups stack configuration for the UDP
protocol.
Note | |
---|---|
Refer to the clustering guide for issues related to JGroups. |
In order to be detected by a master server, a cluster daemon has to
be properly configured. This is achieved by using a
discovery entry in the clusterd.xml
configuration file. The configuration properies are:
The JGroups group name
The JGroups stack configuration file name
A boolean
allowing to activate (if
true
) the discovery.
Example:
<discovery> <group-name>JGroupsDiscovery</group-name> <stack-file>jgroups-discovery.xml</stack-file> <start-up>true</start-up> </discovery>