/** Create a populated tree, delete all records, then begin to insert again. */ private void setupWrittenByCompression(Database db) throws DatabaseException { setStepwiseStart(); DatabaseEntry key = new DatabaseEntry(); DatabaseEntry data = new DatabaseEntry(); /* Populate a tree so it grows to 2 levels, with 2 BINs. */ for (int i = 0; i < 10; i++) { IntegerBinding.intToEntry(i, key); IntegerBinding.intToEntry(i, data); assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); } Trace.trace(DbInternal.getEnvironmentImpl(env), "After inserts"); env.checkpoint(FORCE_CONFIG); if (DEBUG) { System.out.println(db.getStats(new StatsConfig())); } /* Now delete all of 1 BIN. */ for (int i = 0; i < 5; i++) { IntegerBinding.intToEntry(i, key); assertEquals(OperationStatus.SUCCESS, db.delete(null, key)); } /* Compress, removing a BIN. */ env.compress(); if (DEBUG) { System.out.println("After compress"); System.out.println(db.getStats(new StatsConfig())); } /* Checkpoint again. */ env.checkpoint(FORCE_CONFIG); }
/** Create a populated tree, delete all records, then begin to insert again. */ private void setupEvictedRoot(Database db) throws DatabaseException { setStepwiseStart(); DatabaseEntry key = new DatabaseEntry(); DatabaseEntry data = new DatabaseEntry(); /* Populate a tree so it grows to 2 levels, with 2 BINs. */ for (int i = 0; i < 10; i++) { IntegerBinding.intToEntry(i, key); IntegerBinding.intToEntry(i, data); assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); } Trace.trace(DbInternal.getEnvironmentImpl(env), "After inserts"); env.checkpoint(FORCE_CONFIG); /* * Add another record so that the eviction below will log * a different versions of the IN nodes. */ IntegerBinding.intToEntry(10, key); IntegerBinding.intToEntry(10, data); assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); /* Evict */ TestHook<Boolean> evictHook = new TestHook<Boolean>() { public void doIOHook() { throw new UnsupportedOperationException(); } public void doHook() { throw new UnsupportedOperationException(); } public Boolean getHookValue() { return Boolean.TRUE; } public void hookSetup() { throw new UnsupportedOperationException(); } public void doHook(Boolean obj) { throw new UnsupportedOperationException(); } }; DbInternal.getEnvironmentImpl(env).getEvictor().setRunnableHook(evictHook); env.evictMemory(); /* Checkpoint again. */ env.checkpoint(FORCE_CONFIG); }
private void setupWrittenBySplits(Database db) throws DatabaseException { setStepwiseStart(); DatabaseEntry key = new DatabaseEntry(); DatabaseEntry data = new DatabaseEntry(); /* Create a tree and checkpoint. */ IntegerBinding.intToEntry(0, key); IntegerBinding.intToEntry(0, data); assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); env.checkpoint(FORCE_CONFIG); Trace.trace(DbInternal.getEnvironmentImpl(env), "After creation"); /* Populate a tree so it splits. */ for (int i = 1; i < 6; i++) { IntegerBinding.intToEntry(i, key); IntegerBinding.intToEntry(i, data); assertEquals(OperationStatus.SUCCESS, db.put(null, key, data)); } Trace.trace(DbInternal.getEnvironmentImpl(env), "After inserts"); env.checkpoint(FORCE_CONFIG); }
private void fillLogWithTraceMsgs(Environment env, int numToAdd) { EnvironmentImpl envImpl = DbInternal.getEnvironmentImpl(env); FileManager fileManager = envImpl.getFileManager(); Long beforeTracing = getLastFileNum(env); logger.info("BeforeTracing end file = 0x" + Long.toHexString(beforeTracing)); do { for (int i = 0; i <= 100; i++) { Trace.trace(envImpl, STUFF + i); } } while (fileManager.getLastFileNum() <= (beforeTracing + numToAdd)); Long afterTracing = fileManager.getLastFileNum(); logger.info("AfterTracing end file = 0x" + Long.toHexString(afterTracing)); /* Check that we've grown the log by a good bit - at least 40 files */ assertTrue((afterTracing - beforeTracing) > 40); }