1 package org.jgroups.tests; 2 3 import org.jgroups.JChannel; 4 import org.jgroups.blocks.GroupRequest; 5 import org.jgroups.blocks.MethodCall; 6 import org.jgroups.blocks.RpcDispatcher; 7 8 12 public class HammerSender { 13 private static JChannel channel = null; 14 15 private static RpcDispatcher disp; 16 17 private static String props = "UDP(mcast_addr=228.1.2.3;mcast_port=45566;ip_ttl=64;"+ 18 "ucast_recv_buf_size=16000;ucast_send_buf_size=16000;" + 19 "mcast_send_buf_size=32000;mcast_recv_buf_size=64000;loopback=true):" + 20 "PING(timeout=2000;num_initial_members=3):" + 21 "MERGE2(min_interval=5000;max_interval=10000):" + "FD:" + 22 "VERIFY_SUSPECT(timeout=1500):" + "pbcast.STABLE(desired_avg_gossip=10000):" + 23 "pbcast.NAKACK(gc_lag=50;retransmit_timeout=1000,1500,2000,3000;max_xmit_size=8192):" + 24 "UNICAST(timeout=1000,1500,2000,3000):" + 25 "FLOW_CONTROL(window_size=1000;fwd_mrgn=200;rttweight=0.125;reduction=0.75;expansion=1.25):"+ 26 "FRAG(frag_size=8192;down_thread=false;up_thread=false):" + 27 "pbcast.GMS(join_timeout=5000;join_retry_timeout=2000;shun=false;print_local_addr=true):" + 28 "pbcast.STATE_TRANSFER"; 29 30 private static MethodCall printnumMethod = null; 31 32 static { 33 initCommChannel(); 34 loadMethods(); 35 } 36 37 private static void loadMethods() 38 { 39 try { 40 java.lang.reflect.Method method = HammerListener.class.getMethod("printnum",new Class [] { Integer .class }); 41 printnumMethod = new org.jgroups.blocks.MethodCall( method, new Object []{new Integer (2)}); 42 43 } 44 45 catch(java.lang.NoSuchMethodException nsme) 46 { 47 System.err.println("No Such method:"+ nsme); 48 } 49 catch(Exception e) 50 { 51 System.err.println("Error:"+ e); 52 } 53 } 54 55 56 63 static private void initCommChannel() { 64 66 try { 67 channel = new JChannel(props); 68 System.out.println(channel.getProtocolStack().printProtocolSpec(false)); 69 disp = new RpcDispatcher(channel, null, null, null); 70 channel.connect("BOSGroup"); 71 } 72 catch (org.jgroups.ChannelException ce) { 73 System.err.println("Channel Error"+ ce); 74 } 75 } 76 77 78 79 83 public static void executeDistributedCommand() { 84 85 disp.callRemoteMethods(null, printnumMethod, GroupRequest.GET_NONE, 0); 86 } 87 88 92 static void shutdown() { 93 disp.stop(); 95 channel.close(); 96 } 97 } 98 99 | Popular Tags |