Lateral UDP Discovery
Rather than list all the other lateral servers in the configuration
file, you can configure the TCP lateral to use UDP
discovery. In discovery mode, lateral TCP caches will broadcast
to a multicast address and port, letting all listeners know where they are.
On startup each lateral will issue a special message requesting a
broadcast from the other caches. Normal broadcasts occur every
15 seconds. (This is to be made configurable.) Regions that don't
receive, are running in send only mode, don't broadcast anything but requests.
The normal broadcasts publish the address and port of the service.
This can be configured as TcpListenerHost and
TcpListenerPort , respectively. If the service address
is not set, the service tries to detect a suitable address using the
same interface as the one that is used for multicast. If the multicast
uses IPv6, a link-local IPv6 address is selected if one exists.
Otherwise, a site-local IPv4 address is chosen. If that attempt also
fails, the first address on any non-loopback interface is used.
When a lateral receives a discovery message it will try to add
the lateral to the nowait facade for the region. If it already exists
nothing happens. If a region is not configured to send laterally, nothing
happens, since it doesn't have a no wait.
This allows you to have the same configuration on every machine.
Configuration
The configuration is fairly straightforward and is done in the
auxiliary cache section of the cache.ccf
configuration file. In the example below, a TCP
Lateral Auxiliary Cache referenced by LTCP is created. It uses
UDP Discovery to locate other servers. It broadcasts to
multicast address 228.5.6.8 and port 6780 .
It listens to port 1110 . The UDP datagram time-to-live
is 4 hops.
jcs.auxiliary.LTCP=org.apache.commons.jcs3.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory
jcs.auxiliary.LTCP.attributes=org.apache.commons.jcs3.auxiliary.lateral.socket.tcp.TCPLateralCacheAttributes
jcs.auxiliary.LTCP.attributes.TcpListenerPort=1110
jcs.auxiliary.LTCP.attributes.PutOnlyMode=true
jcs.auxiliary.LTCP.attributes.UdpDiscoveryAddr=228.5.6.8
jcs.auxiliary.LTCP.attributes.UdpDiscoveryPort=6780
jcs.auxiliary.LTCP.attributes.UdpDiscoveryEnabled=true
jcs.auxiliary.LTCP.attributes.UdpTTL=4
Multi-homed hosts
On machines that have several network interfaces, it might be
desirable to fix the interface that is used for multicast.
For this purpose, the network interface can be specified in the
configuration (see below).
If the network interface is not specified, JCS tries to detect a
suitable interface. The selected interface is logged on INFO level.
Search for the message "Using network interface" in your log file.
jcs.auxiliary.LTCP=org.apache.commons.jcs3.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory
jcs.auxiliary.LTCP.attributes=org.apache.commons.jcs3.auxiliary.lateral.socket.tcp.TCPLateralCacheAttributes
jcs.auxiliary.LTCP.attributes.TcpListenerPort=1110
jcs.auxiliary.LTCP.attributes.PutOnlyMode=true
jcs.auxiliary.LTCP.attributes.UdpDiscoveryInterface=en0
jcs.auxiliary.LTCP.attributes.UdpDiscoveryAddr=228.5.6.8
jcs.auxiliary.LTCP.attributes.UdpDiscoveryPort=6780
jcs.auxiliary.LTCP.attributes.UdpDiscoveryEnabled=true
jcs.auxiliary.LTCP.attributes.UdpTTL=4
|