1 8 package com.sleepycat.je.recovery; 9 10 import java.util.HashSet ; 11 import java.util.logging.Level ; 12 13 import com.sleepycat.bind.tuple.IntegerBinding; 14 import com.sleepycat.je.CheckpointConfig; 15 import com.sleepycat.je.Database; 16 import com.sleepycat.je.DatabaseConfig; 17 import com.sleepycat.je.DatabaseEntry; 18 import com.sleepycat.je.DatabaseException; 19 import com.sleepycat.je.DbInternal; 20 import com.sleepycat.je.EnvironmentConfig; 21 import com.sleepycat.je.OperationStatus; 22 import com.sleepycat.je.config.EnvironmentParams; 23 import com.sleepycat.je.util.TestUtils; 24 import com.sleepycat.je.utilint.Tracer; 25 26 public class CheckSplitAuntTest extends CheckBase { 27 28 private static final String DB_NAME = "simpleDB"; 29 private boolean useDups; 30 31 33 public void testSplitAunt() 34 throws Throwable { 35 36 EnvironmentConfig envConfig = TestUtils.initEnvConfig(); 37 turnOffEnvDaemons(envConfig); 38 envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), 39 "4"); 40 envConfig.setAllowCreate(true); 41 envConfig.setTransactional(true); 42 43 DatabaseConfig dbConfig = new DatabaseConfig(); 44 dbConfig.setAllowCreate(true); 45 dbConfig.setTransactional(true); 46 47 EnvironmentConfig restartConfig = TestUtils.initEnvConfig(); 48 turnOffEnvDaemons(envConfig); 49 envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), 50 "4"); 51 envConfig.setTransactional(true); 52 53 testOneCase(DB_NAME, 54 envConfig, 55 dbConfig, 56 new TestGenerator(true){ 57 void generateData(Database db) 58 throws DatabaseException { 59 setupSplitData(db); 60 } 61 }, 62 restartConfig, 63 new DatabaseConfig()); 64 65 70 HashSet currentExpected = new HashSet (); 71 if (TestUtils.runLongTests()) { 72 stepwiseLoop(DB_NAME, envConfig, dbConfig, currentExpected, 0); 73 } 74 } 75 76 private void setupSplitData(Database db) 77 throws DatabaseException { 78 79 setStepwiseStart(); 80 81 int max = 12; 82 83 DatabaseEntry key = new DatabaseEntry(); 84 DatabaseEntry data = new DatabaseEntry(); 85 86 87 for (int i = 0; i < max; i ++) { 88 IntegerBinding.intToEntry(i*10, key); 89 IntegerBinding.intToEntry(i*10, data); 90 assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); 91 } 92 93 CheckpointConfig ckptConfig = new CheckpointConfig(); 94 Tracer.trace(Level.SEVERE, DbInternal.envGetEnvironmentImpl(env), 95 "First sync"); 96 env.sync(); 97 98 Tracer.trace(Level.SEVERE, DbInternal.envGetEnvironmentImpl(env), 99 "Second sync"); 100 env.sync(); 101 102 Tracer.trace(Level.SEVERE, DbInternal.envGetEnvironmentImpl(env), 103 "Third sync"); 104 env.sync(); 105 106 Tracer.trace(Level.SEVERE, DbInternal.envGetEnvironmentImpl(env), 107 "Fourth sync"); 108 env.sync(); 109 110 Tracer.trace(Level.SEVERE, DbInternal.envGetEnvironmentImpl(env), 111 "Fifth sync"); 112 env.sync(); 113 114 Tracer.trace(Level.SEVERE, DbInternal.envGetEnvironmentImpl(env), 115 "Sync6"); 116 env.sync(); 117 118 Tracer.trace(Level.SEVERE, DbInternal.envGetEnvironmentImpl(env), 119 "After sync"); 120 121 122 IntegerBinding.intToEntry(5, key); 123 IntegerBinding.intToEntry(5, data); 124 assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); 125 Tracer.trace(Level.SEVERE, DbInternal.envGetEnvironmentImpl(env), 126 "After single key insert"); 127 128 ckptConfig.setForce(true); 129 ckptConfig.setMinimizeRecoveryTime(true); 130 env.checkpoint(ckptConfig); 131 132 Tracer.trace(Level.SEVERE, DbInternal.envGetEnvironmentImpl(env), 133 "before split"); 134 135 136 137 for (int i = 51; i < 57; i ++) { 138 IntegerBinding.intToEntry(i, key); 139 IntegerBinding.intToEntry(i, data); 140 assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); 141 } 142 143 Tracer.trace(Level.SEVERE, DbInternal.envGetEnvironmentImpl(env), 144 "after split"); 145 } 146 } 147 | Popular Tags |