KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > recovery > RecoveryDeleteTest


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: RecoveryDeleteTest.java,v 1.6 2006/10/30 21:14:48 bostic Exp $
7  */

8
9 package com.sleepycat.je.recovery;
10
11 import java.util.Hashtable JavaDoc;
12
13 import com.sleepycat.je.CheckpointConfig;
14 import com.sleepycat.je.DatabaseException;
15 import com.sleepycat.je.Transaction;
16 import com.sleepycat.je.config.EnvironmentParams;
17
18 public class RecoveryDeleteTest extends RecoveryTestBase {
19
20     protected void setExtraProperties()
21         throws DatabaseException {
22         envConfig.setConfigParam(
23                       EnvironmentParams.ENV_RUN_INCOMPRESSOR.getName(),
24                       "false");
25     }
26
27     /* Make sure that we can recover after the entire tree is compressed away. */
28     public void testDeleteAllAndCompress()
29         throws Throwable JavaDoc {
30
31         createEnvAndDbs(1 << 20, false, NUM_DBS);
32         int numRecs = 10;
33
34         try {
35             // Set up an repository of expected data
36
Hashtable JavaDoc expectedData = new Hashtable JavaDoc();
37             
38             // insert all the data
39
Transaction txn = env.beginTransaction(null, null);
40             insertData(txn, 0, numRecs -1 , expectedData, 1, true, NUM_DBS);
41             txn.commit();
42
43             /*
44              * Do two checkpoints here so that the INs that make up this new
45              * tree are not in the redo part of the log.
46              */

47             CheckpointConfig ckptConfig = new CheckpointConfig();
48             ckptConfig.setForce(true);
49             env.checkpoint(ckptConfig);
50             env.checkpoint(ckptConfig);
51             txn = env.beginTransaction(null, null);
52             insertData(txn, numRecs, numRecs + 1, expectedData, 1, true, NUM_DBS);
53             txn.commit();
54
55             /* delete all */
56             txn = env.beginTransaction(null, null);
57             deleteData(txn, expectedData, true, true, NUM_DBS);
58             txn.commit();
59
60             /* This will remove the root. */
61             env.compress();
62
63             closeEnv();
64             recoverAndVerify(expectedData, NUM_DBS);
65         } catch (Throwable JavaDoc t) {
66             // print stacktrace before trying to clean up files
67
t.printStackTrace();
68             throw t;
69         }
70     }
71 }
72
Popular Tags