KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > scenario > raidb2 > Raidb2BasicFailoverScenario


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.raidb2;
26
27 import java.sql.Connection JavaDoc;
28
29 import org.objectweb.cjdbc.scenario.templates.SimpleRaidb2Template;
30 import org.objectweb.cjdbc.scenario.tools.testlet.AbstractTestLet;
31 import org.objectweb.cjdbc.scenario.tools.testlet.FailoverOn2BackendsTestLet;
32
33 /**
34  * This class defines a Raidb1BasicFailoverScenario
35  *
36  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
37  * @version 1.0
38  */

39 public class Raidb2BasicFailoverScenario extends SimpleRaidb2Template
40 {
41   /**
42    * Test CJDBC failover in raidb1 with variable pool
43    * @throws Exception if fails
44    */

45   public void testFailOverWithVariablePool() throws Exception JavaDoc
46   {
47       //Load database
48
cm.loadVirtualDatabases(controller, "myDB",
49           "hsqldb-raidb2-variablepool.xml");
50       mainVdb = controller.getVirtualDatabase("myDB");
51       mainVdb.enableAllBackends();
52       execute();
53   }
54
55   /**
56    * Test CJDBC failover in raidb1 with randomwait pool
57    * @throws Exception if fails
58    */

59   public void testFailOverWithRandomWaitPool() throws Exception JavaDoc
60   {
61       //Load database
62
cm.loadVirtualDatabases(controller, "myDB",
63           "hsqldb-raidb2-randomwaitpool.xml");
64       mainVdb = controller.getVirtualDatabase("myDB");
65       mainVdb.enableAllBackends();
66       execute();
67   }
68
69   /**
70    * Test CJDBC failover in raidb1 with fail fast pool
71    * @throws Exception if fails
72    */

73   public void testFailOverWithFailFastPool() throws Exception JavaDoc
74   {
75       //Load database
76
cm.loadVirtualDatabases(controller, "myDB",
77           "hsqldb-raidb2-failfastpool.xml");
78       mainVdb = controller.getVirtualDatabase("myDB");
79       mainVdb.enableAllBackends();
80       execute();
81   }
82
83   /**
84    * Test CJDBC failover in raidb1 with simple connection manager
85    * @throws Exception if fails
86    */

87   public void testFailOverWithNoPool() throws Exception JavaDoc
88   {
89       //Load database
90
cm.loadVirtualDatabases(controller, "myDB", "hsqldb-raidb2-nopool.xml");
91       mainVdb = controller.getVirtualDatabase("myDB");
92       mainVdb.enableAllBackends();
93       execute();
94   }
95
96   /**
97    * Execute the test for failover once the database is loaded
98    */

99   private void execute() throws Exception JavaDoc
100   {
101     // Execute a request
102
Connection JavaDoc con = getCJDBCConnection();
103     FailoverOn2BackendsTestLet let = new FailoverOn2BackendsTestLet(con);
104     let.set(AbstractTestLet.LIST_FAILOVER_BACKENDS,new Object JavaDoc[]{hm1,hm2});
105     let.execute();
106   }
107 }
108
Popular Tags