1 24 25 package org.objectweb.cjdbc.scenario.standalone.group; 26 27 import junit.framework.TestCase; 28 29 import org.jgroups.Channel; 30 import org.jgroups.Event; 31 import org.jgroups.JChannel; 32 import org.jgroups.UpHandler; 33 34 40 public class GroupCommunicationFailure extends TestCase 41 { 42 47 public void testCloseChannel() throws Exception 48 { 49 System.setProperty("org.apache.commons.logging.Log", 50 "org.apache.commons.logging.impl.SimpleLog"); 51 JGroupsChannelTest test = new JGroupsChannelTest(); 52 System.out.println("done:"+test.toString()); 53 } 54 55 class JGroupsChannelTest implements UpHandler 56 { 57 58 JChannel jChannel = null; 59 60 66 public JGroupsChannelTest() 67 { 68 String props = "TCP(start_port=7800;bind_addr=localhost;loopback=true):" 69 + "TCPGOSSIP(timeout=3000;initial_hosts=localhost[7500]num_initial_members=3):" 70 + "FD(timeout=2000;max_tries=4):" 71 + "VERIFY_SUSPECT(timeout=1500;down_thread=false;up_thread=false):" 72 + "pbcast.NAKACK(gc_lag=100;retransmit_timeout=600,1200,2400,4800):" 73 + "pbcast.GMS(print_local_addr=true;join_timeout=5000;join_retry_timeout=2000;" 74 + "shun=true)"; 75 try 76 { 77 jChannel = new JChannel(props); 78 jChannel.setOpt(Channel.LOCAL, Boolean.FALSE); 79 jChannel.setOpt(Channel.VIEW, Boolean.TRUE); 80 jChannel.setUpHandler(this); 81 jChannel.connect("testGroup"); 82 83 System.out.println(jChannel.printProtocolSpec(true)); 84 85 jChannel.close(); 86 } 87 catch (Exception e) 88 { 89 System.out.println("Error channel " + e); 90 } 91 } 92 93 97 public void up(Event evt) 98 { 99 if (Event.VIEW_CHANGE == evt.getType()) 100 { 101 System.out.println("got view change"); 102 jChannel.close(); 103 System.out.println("channel closed"); 104 } 105 } 106 107 } 108 109 } | Popular Tags |