Custom Cluster

The cluster may also be customised. The default cluster name to use is 'Jather', but an application may make use of multiple clusters by defining a cluster name to use.

The following client uses two clusters 'slow' and 'fast', which may represent cluster Executive instances running on slow or fast servers.

package jatherexample;

import jather.JatherClient;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Future;

public class MainTwoClusterClient
{
        public static void main(String[] args) throws Exception
        {
                JatherClient slowClient = new JatherClient("slow");
                JatherClient fastClient = new JatherClient("fast");                             
                
                List<Future<String>> calls = new ArrayList<Future<String>>();
                for (int i = 0; i < 5; i++)
                {
                        calls.add(slowClient.submit(new MyCallable(1000)));
                        calls.add(fastClient.submit(new MyCallable(100000)));
                }
                
                for(Future<String> f : calls)
                {
                        System.out.println(f.get());    
                }               
                
                slowClient.close();
                fastClient.close();
        }
}

To run this example with two clusters, start executives in two new processes.

        java -jar jather-<version>.jar -n slow
        java -jar jather-<version>.jar -n fast

The number of concurrent Callable threads that will be catered for by each Executive may also be set using the slot setting. The following example with run the submitted 'slow' Callable instances sequentially.

        java -jar jather-<version>.jar -n slow -s 1

The underlying JGroup settings used by the executive may also be set with the string property setting.

        java -jar jather-<version>.jar -n slow -s 1 -p "UDP(oob_thread_pool.max_threads=8;oob_thad_pool.keep_alive_time=5000;max_bundle_size=64000;mcast_send_buf_size=640000;oob_thread_pool.queue_max_size=100;mcast_recv_buf_size=25000000;use_concurrent_stack=true;tos=8;mcast_port=45588;loopback=false;thread_pool.min_threads=2;oob_thread_pool.rejection_policy=Run;thread_pool.max_threads=8;enable_diagnostics=true;thread_naming_pattern=cl;ucast_send_buf_size=640000;ucast_recv_buf_size=20000000;thread_pool.enabled=true;use_incoming_packet_handler=true;oob_thread_pool.enabled=true;ip_ttl=2;enable_bundling=true;thread_pool.rejection_policy=discard;discard_incompatible_packets=true;thread_pool.keep_alive_time=5000;thread_pool.queue_enabled=true;mcast_addr=228.10.10.10;max_bundle_timeout=30;oob_thread_pool.queue_enabled=false;oob_thread_pool.min_threads=1;thread_pool.queue_max_size=1000):PING(num_initial_members=3;timeout=2000):MERGE2(min_interval=10000;max_interval=30000):FD_SOCK:FD(max_tries=5;timeout=10000;shun=true):VERIFY_SUSPECT(timeout=1500):BARRIER:pbcast.NAKACK(use_stats_for_retransmission=false;gc_lag=0;use_mcast_xmit=true;retransmit_timeout=50,300,600,1200;exponential_backoff=150;discard_delivered_msgs=true):UNICAST(timeout=300,600,1200):pbcast.STABLE(desired_avg_gossip=50000;max_bytes=1000000;stability_delay=1000):VIEW_SYNC(avg_send_interval=60000):pbcast.GMS(print_local_addr=true;view_bundling=true;join_timeout=3000;shun=false):FC(max_credits=500000;min_threshold=0.20):FRAG2(frag_size=60000):pbcast.STATE_TRANSFER"