KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > scenario > raidb1 > recovery > Raidb1BackupMetadataScenario


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.raidb1.recovery;
26
27 import java.sql.Connection JavaDoc;
28 import java.sql.ResultSet JavaDoc;
29 import java.util.ArrayList JavaDoc;
30
31 import org.objectweb.cjdbc.scenario.templates.Raidb1RecoveryTemplate;
32 import org.objectweb.cjdbc.scenario.tools.ScenarioUtility;
33
34 /**
35  * This class defines a Raidb1BackupScenario We had a problem where some tasks
36  * were left on the backend pending requests and thus we could not start the
37  * backup process.
38  *
39  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modryzk </a>
40  * @version 1.0
41  */

42 public class Raidb1BackupMetadataScenario extends Raidb1RecoveryTemplate
43 {
44   private static final String JavaDoc BACKUP_LOGIN = "user";
45   private static final String JavaDoc BACKUP_PASSWORD = "";
46   private static final String JavaDoc BACKUPER = "Octopus";
47   private static final String JavaDoc BACKUP_PATH = "../backup";
48
49   /**
50    * Test recovery scenario
51    *
52    * @throws Exception if fails
53    */

54   public void testBasicRecoveryScenario() throws Exception JavaDoc
55   {
56     String JavaDoc dump1 = "dump1" + System.currentTimeMillis();
57     String JavaDoc dump2 = "dump2" + System.currentTimeMillis();
58     mainVdb.backupBackend("localhost", BACKUP_LOGIN, BACKUP_PASSWORD, dump1,
59         BACKUPER, BACKUP_PATH, null);
60     mainVdb.restoreDumpOnBackend("localhost", BACKUP_LOGIN, BACKUP_PASSWORD,
61         dump1, null);
62     mainVdb.enableBackendFromCheckpoint("localhost");
63
64     Connection JavaDoc con = getCJDBCConnection();
65     ResultSet JavaDoc rs = con.createStatement().executeQuery("select * from document");
66     ArrayList JavaDoc list1 = ScenarioUtility.convertResultSet(rs);
67     rs.close();
68
69     mainVdb.backupBackend("localhost", BACKUP_LOGIN, BACKUP_PASSWORD, dump2,
70         BACKUPER, BACKUP_PATH, null);
71     mainVdb.restoreDumpOnBackend("localhost", BACKUP_LOGIN, BACKUP_PASSWORD,
72         dump2, null);
73     mainVdb.enableBackendFromCheckpoint("localhost");
74
75     mainVdb.forceDisableBackend("localhost2");
76
77     rs = con.createStatement().executeQuery("select * from document");
78     ArrayList JavaDoc list2 = ScenarioUtility.convertResultSet(rs);
79     rs.close();
80     assertEquals("ResultSets are different", list1, list2);
81   }
82 }
83
Popular Tags