KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > scenario > standalone > group > GroupCommunicationFailure


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk.
22  * Contributor(s): ______________________.
23  */

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 /**
35  * This class defines a GroupCommunicationFailure
36  *
37  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk</a>
38  * @version 1.0
39  */

40 public class GroupCommunicationFailure extends TestCase
41 {
42   /**
43    * Test close channel
44    *
45    * @throws Exception if fails
46    */

47   public void testCloseChannel() throws Exception JavaDoc
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     /**
61      *
62      * Creates a new <code>JGroupsChannelTest</code> object
63      *
64      *
65      */

66     public JGroupsChannelTest()
67     {
68       String JavaDoc 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 JavaDoc e)
88       {
89         System.out.println("Error channel " + e);
90       }
91     }
92
93     /**
94      *
95      * @see org.jgroups.UpHandler#up(org.jgroups.Event)
96      */

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