This page contains several examples of configuring distributed registry. These examples assumed that Spring framework is used as IoC container and therefore represent appropriate fragments of Spring configuration files.

However, it is possible to use DistRegistry out of Spring (using either different IoC container or simply assembling all components in plain Java code). Please refer to examples included to DistRegistry distribution to find examples of configuration of distributing registry in Java.

UDP based registry

The following examples illustrate how to configure distributed registry if UDP multicasting is used as underlying networking protocol.

Configuring ProvidingRegistry

Configuration of providing registry is quite simple. The most configuration options there are related not to ProvidingRegistry itself, but rather to details of networking communications.

Verbose configuration

The following listing illustrates the most complete configuration of ProvidingRegistry and illustrates all properties that may be configured. Such a form of configuration is useful if, for example, the same UDP multicaster is shared between different components application.

Please refer to configuration comments below to find more information for every particular element of declaration.

[1]<bean name="_ProvidingRegistry.verbose.udp"
�� ������class="org.softamis.net.registry.spring.DefaultProvidingRegistry">
[2] <property name="communicationHelper">
[3] �����<bean class="org.softamis.net.exchange.udp.UDPCommunicationHelper"
��� �����������init-method="init" destroy-method="close">
[4]� ������<property name="multicaster" ref="UDPMulticaster"/>��������� 
[5]�� �����<property name="communicationProtocol">
[6]��� ������<bean class="org.softamis.net.exchange.udp.UDPCommunicationProtocol">
[7]����������� <property name="datagramSignature" value="NIRM"/>
[8] �����������<property name="useCompression" value="false"/>
  ��������� �</bean>
  �� ��� �</property>
� ������</bean>
  � ���</property>
��</bean>
  
[9]<bean id="UDPMulticaster"
������� class="org.softamis.net.multicast.DefaultMulticaster">
[10] <property name="groupName" value="230.0.0.1"/>
[11] <property name="port" value="12890"/>
[12] <property name="timeToLive" value="2"/>
[13] <property name="active" value="true"/>
</bean>

Configuration details:

  1. Declaration of ProvidingRegistrybean;
  2. Here we declare CommunicationHelper which performs necessary network��� communications;
  3. Since we use UDP based transport layer in this example, we specify corresponding class of helper. Also, it's important that init() and destroy() methods on communication helper will be called for initialization and closing;
  4. Property which specifies instance of UDP multicaster which will be used by helper to perform network communications;
  5. Property allows to declare CommunicationProtocol used by helper to encode/decode network data;
  6. Declaration of UDP based CommunicationProtocol;
  7. Property which specifies signature of messages will be used by distributed registry (default is "NIRM");
  8. Optional property which allows to specify whether data should be compressed before sending to network;
  9. Configuration of UDP multicaster which performs issuing/receiving UDP notifications;
  10. Property that specifies UDP multicast group (multicast IP address) which is used by multicaster (default is 230.0.0.1);
  11. Property that specifies number of port should be used for multicasting (default value is 12890);
  12. Time to live (TTL) parameter which specifies how many network nodes may pass UDP datagram (default value is 2);
  13. Property that allows specifying the fact that multicaster should be in active state immediately after startup.

Short configuration

The following listing illustrates shorter configuration of ProvidingRegistry that requires shorter markup and creates appropriate instances of UDP multicaster and CommunicationProtocol internally in UDPCommunicationHelper.

Please refer to configuration comments below to find more information for every particular element of declaration.

[1]<bean name="_ProvidingRegistry.short.udp"
������� class="org.softamis.net.registry.spring.DefaultProvidingRegistry">
[2]<property name="communicationHelper">
[3]��� <bean class="org.softamis.net.exchange.udp.UDPCommunicationHelper"
�� ����������init-method="init" destroy-method="close">
[4]��� ��<property name="defaultGroupName" value="230.0.0.1"/>
[5]����� <property name="defaultPort" value="10000"/>
[6]����� <property name="defaultTimeToLive" value="20"/>
[7]����� <property name="defaultMessageSignature" value="NIRM"/>
����� �</bean>
��� </property>
</bean>

Configuration details:

  1. Declaration of ProvidingRegistry bean;
  2. Here we declare CommunicationHelper which performs necessary network��� communications;
  3. Since we use UDP based transport layer in this example, we specify corresponding class of helper. Also, it's important that init() and destroy() methods on communication helper will be called for initialization and closing;
  4. Property that specifies UDP multicast group (multicast IP address) which is used by multicaster (default is 230.0.0.1);
  5. Property that specifies number of port should be used for multicasting (default value is 12890);
  6. Time to live (TTL) parameter which specifies how many network nodes may pass UDP datagram (default value is 2);
  7. Property which specifies signature of messages will be used by distributed registry (default is "NIRM");

Minimal configuration

The following listing illustrates minimal required configuration of ProvidingRegistry and illustrates all properties that may be configured. Most of properties have internal built-in default values.

<bean name="_ProvidingRegistry.minimal.udp"
����� class="org.softamis.net.registry.spring.DefaultProvidingRegistry">
�� <property name="communicationHelper">
����� <bean class="org.softamis.net.exchange.udp.UDPCommunicationHelper"
����������� init-method="init" destroy-method="close"/>
�� </property>
</bean>

Configuring ConsumingRegistry

As soon as ProvidingRegistry is configured, it is necessary to configure ConsumingRegistry. Exactly as for ProvidingRegistry, there are, generally, three possible examples of configuration - verbose, short and minimal (built-in defaults based) ones that are illustrated by listings below.

In general, since internally ConsumingRegistry contains the same components, its configuration is very close to configuration of ProvidingRegistry.

Please note that it is important to have the same configuration of network related options (like multicast group, multicast port) as well as message signature used by distributed registry both on ProvidingRegistry��������� and ConsumingRegistry configuration to make sure that distributed registry works properly (in other case, ConsumingRegistry simply will not receive notifications from ProvidingRegistry).

Verbose configuration

The following listing illustrates the most complete configuration of ConsumingRegistry and illustrates all properties that may be configured. Such a form of configuration is useful if, for example, the same UDP multicaster is shared among different components of application.

Please refer to configuration comments below to find more information for every particular element of declaration.

[1] <bean name="_ConsumingRegistry.verbose.udp"
�� ������class="org.softamis.net.registry.spring.DefaultConsumingRegistry">
[2] <property name="communicationHelper">
����� <bean class="org.softamis.net.exchange.udp.UDPCommunicationHelper"
���������� init-method="init" destroy-method="close">
������� <property name="communicationProtocol">
��������� <bean
����������� class="org.softamis.net.exchange.udp.UDPCommunicationProtocol">
����������� <property name="datagramSignature" value="NIRM"/>
����������� <property name="useCompression" value="false"/>
��������� </bean>
������� </property>
������� <property name="multicaster" ref="UDPMulticaster"/>
����� </bean>
��� </property>�� 
[3] <property name="discoveringTimeout" value="1000"/>
[4] <property name="requestItemsOnInit" value="true"/>
[5] <property name="issueRequestForInvalidatedService" value="false"/>
� �</bean>
 
[6]<bean id="UDPMulticaster"
�� �����class="org.softamis.net.multicast.DefaultMulticaster">
��� <property name="groupName" value="230.0.0.1"/>
��� <property name="port" value="12890"/>
��� <property name="timeToLive" value="2"/>
��� <property name="active" value="true"/>
 ��</bean>

Configuration details:

  1. Declaration of ConsumingRegistry bean;
  2. Here we declare CommunicationHelper which performs necessary network��� communications - all configuration is the same as was illustrated before for ProvidingRegistry;
  3. Property that specifies timeout used to wait for responses from providing registries when request for items is issued (in milliseconds). Default is 1000;
  4. Property that controls whether registry should request for available items as soon as it configured (default value is true);
  5. Property that controls how ConsumingRegistry should process invalidation notifications from other registries (default value is false). It defines policy how COMMAND_ITEM_INVALIDATED notification should be processed by ConsumingRegistry. If this option is set to true, the ConsumingRegistry will invalidate item and then issue COMMAND_ITEM_REQUEST for invalidated item key. If this option is set to false, the ConsumingRegistry will simply invalidate item.
  6. Configuration of UDP multicaster that performs issuing/receiving UDP notifications;

Short configuration

The following listing illustrates shorter configuration of ConsumingRegistry that requires shorter markup and creates appropriate instances of UDP multicaster and CommunicationProtocol internally in UDPCommunicationHelper.

Please refer to configuration comments below to find more information for every particular element of declaration.

[1] <bean name="_ConsumingRegistry.short.udp"
������� ��class="org.softamis.net.registry.spring.DefaultConsumingRegistry">
[2]��� <property name="communicationHelper">
[3]����� <bean class="org.softamis.net.exchange.udp.UDPCommunicationHelper"
���������� ����init-method="init" destroy-method="close">
[4]������� <property name="defaultGroupName" value="230.0.0.1"/>
[5]������� <property name="defaultPort" value="10000"/>
[6]������� <property name="defaultTimeToLive" value="20"/>
[7]������� <property name="defaultMessageSignature" value="NIRM"/>
� �����</bean>
�����</property>
��</bean>

Configuration details:

  1. Declaration of ConsumingRegistry bean;
  2. Here we declare CommunicationHelper which performs necessary network��� communications;
  3. Since we use UDP based transport layer in this example, we specify corresponding class of helper. Also, it's important that init() and destroy() methods on communication helper will be called for initialization and closing;
  4. Property that specifies UDP multicast group (multicast IP address) which is used by multicaster (default is 230.0.0.1);
  5. Property that specifies number of port should be used for multicasting (default value is 12890);
  6. Time to live (TTL) parameter which specifies how many network nodes may pass UDP datagram (default value is 2);
  7. Property which specifies signature of messages will be used by distributed registry (default is "NIRM");

Minimal configuration

The following listing illustrates minimal required configuration of ConsumingRegistry and illustrates all properties that may be configured. Most of properties have internal built-in default values.

<bean name="_ConsumingRegistry.minimal.udp" 
������� class="org.softamis.net.registry.spring.DefaultConsumingRegistry">
��� <property name="communicationHelper">
����� <bean class="org.softamis.net.exchange.udp.UDPCommunicationHelper" 
����������� init-method="init" destroy-method="close"/>
��� </property>
</bean>

JGroups based registry

The following examples illustrate how to configure distributed registry if JGroups based multicasting is used as underlying networking protocol. In general, the overall way of configuration is very close to UDP based one, so in the following listings we highlight rather differences that are specific for JGroups based setup.

Configuring ProvidingRegistry

Configuration of providing registry is quite simple. The most configuration options there are related not to ProvidingRegistry itself, but rather to details of networking communications.

Verbose configuration

The following listing illustrates the most complete configuration of ProvidingRegistry and illustrates all properties that may be configured.

Please refer to configuration comments below to find more information for every particular element of declaration. >

[1]<bean name="_ProvidingRegistry.verbose.jgroups"
  �������� class="org.softamis.net.registry.spring.DefaultProvidingRegistry">
[2]<property name="communicationHelper">
[3]���� <bean class="org.softamis.net.exchange.jgroups.JGCommunicationHelper"
�� ����������init-method="init" destroy-method="close">
[4]��� ��<property name="signature" ref="NIRG"/>
[5]������ <property name="defaultGroupName" value="sa.registry"/>
[6]������ <property name="defaultProperties"> ��
������� ����<value>"UDP(mcast_addr=228.5.5.5;mcast_port=45566;
����������������� ip_ttl=4;mcast_send_buf_size=150000;�
����������������� mcast_recv_buf_size=80000)������������ 
������ �����������:PING(timeout=2000;num_initial_members=3)
                  :MERGE2(min_interval=5000;max_interval=10000)
                  :FD_SOCK:VERIFY_SUSPECT(timeout=1500)
����������������� :pbcast.NAKACK(gc_lag=50;retransmit_timeout=300,600,
����������� ������1200,2400,4800)
����������������� :UNICAST(timeout=600,1200,2400)
����������������� :pbcast.STABLE(desired_avg_gossip=20000)
����������������� :FRAG(frag_size=4096;down_thread=false;up_thread=false)���������������
����������������� :pbcast.GMS(join_timeout=5000;�����������������
����������������������������� join_retry_timeout=2000;
����������������������������� shun=false;print_local_addr=true)"

���������</value>
������� </property>
[7]���� <property name="communicationProtocol">
��������� <bean class="org.softamis.net.exchange.jgroups.JGCommunicationProtocol">����������� 
[8]�������� <property name="datagramSignature" value="NIRG"/>
����������� <property name="useCompression" value="false"/>
��������� </bean>
������� </property>
����� </bean>
�� �</property>
</bean>

Configuration details:>

  1. Declaration of ProvidingRegistry bean;
  2. Here we declare CommunicationHelper which performs necessary network��� communications;
  3. Since we use JGroups there, we specify corresponding class of helper. Also, it's important that init() and destroy() methods on communication helper will be called for initialization and closing;
  4. Property that specifies signature of message which will be used by adapter to select JGroups messages (default value is "NIRG");
  5. Property that specifies name of JGroups group used by communication channel;
  6. Property that represents configuration spring for JGroups channel;
  7. Configuration of JGroups specific CommunicationProtocol;
  8. Signature of messages which will be used by distributed registry (default is NIRG) to select own network messages;

Minimal configuration

The following listing illustrates minimal required configuration of ProvidingRegistry and illustrates all properties that may be configured. Most of properties have internal built-in default values.

<bean name="_ProvidingRegistry.minimal.jgroups" 
������� class="org.softamis.net.registry.spring.DefaultProvidingRegistry">
��� <property name="communicationHelper">
����� <bean class="org.softamis.net.exchange.jgroups.JGCommunicationHelper" 
����������� init-method="init" destroy-method="close"/>
��� </property>
</bean>

Configuring ConsumingRegistry

Following examples illustrates how to configure ConsumingRegistry if JGroups bases networking protocol is used and underlying network transport.

Since all principles of configuration are the same as for UDP based communication and to configuring ProvidingRegistry, here we illustrate only minimal required configuration.

<bean name="_ConsumingRegistry.minimal.jgroups" 
������� class="org.softamis.net.registry.spring.DefaultConsumingRegistry">
��� <property name="communicationHelper">
����� <bean class="org.softamis.net.exchange.jgroups.JGCommunicationHelper" 
  ����������� init-method="init" destroy-method="close"/>
��� </property>
</bean>

Configuring distributed cache

The following example illustrates how to configure simple distributed cache. Generally, that cache uses the same internal components and therefore the process of configuring it is very close to configuring registry. Therefore, for simplicity, here we demonstrate only configuration that utilized UDP and relies on default values of properties.

Please note that configuration of all instances of distributed cache that should share the same data should be also the same to insure that these instances may synchronize their data.

Again, configuration of cache is very simple and is shown on the listing below. �Please refer to configuration comments below to find more information for every particular element of declaration.

[1]<bean id="_SampleCache" 
��� �����class="org.softamis.net.registry.spring.DefaultDistributedCache"
���� ���destroy-method="clear">
[2]<property name="communicationHelper">
��� ��<bean class="org.softamis.net.exchange.udp.UDPCommunicationHelper"
������ �����init-method="init" destroy-method="close">
[3]����� <property name="defaultMessageSignature" value="EX.CACHE"/>
����� </bean>
 ����</property>
</bean>

Configuration details:

  1. Declaration of DistributedCache bean;
  2. Here we declare appropriate CommunicationHelper �(in this example, UDP based one is shown) which performs necessary network communications;
  3. Property that specifies signature of messages should be processed by CommunicationHelper. Here we use different signature to eliminate possible clash with network messages that are issued by distributed registry. The signature of message should be specified only if it is assumed that both distributed registry and cache has similar network setup (for example, use that same multicaster, or use multicaster with the same network settings;
  SourceForge.net Logo   Support This Project