1 8 9 package com.sleepycat.je.recovery; 10 11 import java.util.Hashtable ; 12 13 import com.sleepycat.je.EnvironmentConfig; 14 import com.sleepycat.je.Environment; 15 import com.sleepycat.je.Transaction; 16 import com.sleepycat.je.config.EnvironmentParams; 17 import com.sleepycat.je.util.TestUtils; 18 19 public class RecoveryDuplicatesTest extends RecoveryTestBase { 20 21 public void testDuplicates() 22 throws Throwable { 23 24 createEnvAndDbs(1 << 20, true, NUM_DBS); 25 int numRecs = 10; 26 int numDups = N_DUPLICATES_PER_KEY; 27 28 try { 29 30 Hashtable expectedData = new Hashtable (); 31 32 33 Transaction txn = env.beginTransaction(null, null); 34 insertData(txn, 0, numRecs - 1, expectedData, 35 numDups, true, NUM_DBS); 36 txn.commit(); 37 closeEnv(); 38 recoverAndVerify(expectedData, NUM_DBS); 39 } catch (Throwable t) { 40 t.printStackTrace(); 41 throw t; 42 } 43 } 44 45 public void testDuplicatesWithDeletion() 46 throws Throwable { 47 48 createEnvAndDbs(1 << 20, true, NUM_DBS); 49 int numRecs = 10; 50 int nDups = N_DUPLICATES_PER_KEY; 51 52 try { 53 54 Hashtable expectedData = new Hashtable (); 55 56 57 Transaction txn = env.beginTransaction(null, null); 58 insertData(txn, 0, numRecs -1, expectedData, nDups, true, NUM_DBS); 59 60 61 deleteData(txn, expectedData, false, true, NUM_DBS); 62 txn.commit(); 63 64 65 67 closeEnv(); 68 69 recoverAndVerify(expectedData, NUM_DBS); 70 } catch (Throwable t) { 71 t.printStackTrace(); 72 throw t; 73 } 74 } 75 76 94 public void testSR11455() 95 throws Throwable { 96 97 createEnvAndDbs(1 << 20, true, 1); 98 int numRecs = 1; 99 int nDups = 3; 100 101 try { 102 103 Hashtable expectedData = new Hashtable (); 104 105 106 Transaction txn = env.beginTransaction(null, null); 107 insertData(txn, 0, numRecs -1, expectedData, nDups, true, 1); 108 txn.commit(); 109 110 txn = env.beginTransaction(null, null); 111 112 deleteData(txn, expectedData, false, false, 1); 113 txn.abort(); 114 closeEnv(); 115 116 117 EnvironmentConfig recoveryConfig = TestUtils.initEnvConfig(); 118 recoveryConfig.setTransactional(true); 119 recoveryConfig.setConfigParam 120 (EnvironmentParams.ENV_RUN_CLEANER.getName(), "false"); 121 recoveryConfig.setConfigParam 122 (EnvironmentParams.ENV_RUN_EVICTOR.getName(), "false"); 123 env = new Environment(envHome, recoveryConfig); 124 125 txn = env.beginTransaction(null, null); 126 assertEquals(6, txn.getId()); 127 txn.commit(); 128 env.close(); 129 130 } catch (Throwable t) { 131 t.printStackTrace(); 132 throw t; 133 } 134 } 135 136 public void testDuplicatesWithAllDeleted() 137 throws Throwable { 138 139 createEnvAndDbs(1 << 20, true, NUM_DBS); 140 int numRecs = 10; 141 int nDups = N_DUPLICATES_PER_KEY; 142 143 try { 144 145 Hashtable expectedData = new Hashtable (); 146 147 148 Transaction txn = env.beginTransaction(null, null); 149 insertData(txn, 0, numRecs - 1, expectedData, nDups, 150 true, NUM_DBS); 151 152 153 deleteData(txn, expectedData, true, true, NUM_DBS); 154 txn.commit(); 155 156 157 closeEnv(); 159 160 recoverAndVerify(expectedData, NUM_DBS); 161 } catch (Throwable t) { 162 t.printStackTrace(); 163 throw t; 164 } 165 } 166 } 167 | Popular Tags |