/* Test mutable and persistent configurations. */ @Test public void testPersistentAndMutableConfigs() throws Exception { final String dbName = "foo"; EnvironmentConfig envConfig = TestUtils.initEnvConfig(); envConfig.setAllowCreate(true); envConfig.setTransactional(true); env = create(envHome, envConfig); DbConfigManager configMgr = DbInternal.getEnvironmentImpl(env).getConfigManager(); int defaultNodeMaxEntries = configMgr.getInt(EnvironmentParams.NODE_MAX); int defaultNodeDupTreeMaxEntries = configMgr.getInt(EnvironmentParams.NODE_MAX_DUPTREE); /* Check the default node max entries setting. */ assertEquals(defaultNodeMaxEntries, 128); assertEquals(defaultNodeDupTreeMaxEntries, 128); DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setAllowCreate(true); dbConfig.setTransactional(true); /* Do updates on each persistent and mutable config. */ /* Check whether BtreeComparator setting is persisted. */ dbConfig.setOverrideBtreeComparator(true); dbConfig.setBtreeComparator(TestComparator.class); DatabaseConfig newConfig = setAndGetDbConfig(env, dbConfig, dbName); assertTrue(newConfig.getBtreeComparator() instanceof TestComparator); /* Check whether DuplicateComparator setting is persisted. */ dbConfig.setOverrideDuplicateComparator(true); dbConfig.setDuplicateComparator(new TestSerialComparator()); newConfig = setAndGetDbConfig(env, dbConfig, dbName); assertTrue(newConfig.getDuplicateComparator() instanceof TestSerialComparator); /* Check whether KeyPrefixing setting is persisted. */ dbConfig.setKeyPrefixing(true); newConfig = setAndGetDbConfig(env, dbConfig, dbName); assertTrue(newConfig.getKeyPrefixing()); /* Check whether NodeMaxEntries setting is persisted. */ dbConfig.setNodeMaxEntries(512); newConfig = setAndGetDbConfig(env, dbConfig, dbName); assertTrue(newConfig.getNodeMaxEntries() == 512); close(env); }
/* * @SuppressWarnings is used to stifle a type safety complaint about the * assignment of lockTables = new Map[nLockTables]. There's no way to * specify the type of the array. */ @SuppressWarnings("unchecked") public LockManager(EnvironmentImpl envImpl) { DbConfigManager configMgr = envImpl.getConfigManager(); nLockTables = configMgr.getInt(EnvironmentParams.N_LOCK_TABLES); oldLockExceptions = configMgr.getBoolean(EnvironmentParams.LOCK_OLD_LOCK_EXCEPTIONS); lockTables = new Map[nLockTables]; lockTableLatches = new Latch[nLockTables]; for (int i = 0; i < nLockTables; i++) { lockTables[i] = new HashMap<Long, Lock>(); lockTableLatches[i] = new Latch("Lock Table " + i); } this.envImpl = envImpl; memoryBudget = envImpl.getMemoryBudget(); stats = new StatGroup(GROUP_NAME, GROUP_DESC); nRequests = new LongStat(stats, LOCK_REQUESTS); nWaits = new LongStat(stats, LOCK_WAITS); /* Initialize mutable properties and register for notifications. */ envConfigUpdate(configMgr, null); envImpl.addConfigObserver(this); if (envImpl.isReplicated()) { threadLockers = new ConcurrentHashMap<Thread, TinyHashSet<ThreadLocker>>(); } else { threadLockers = null; } }
protected ReadWindow(int readBufferSize, EnvironmentImpl envImpl) { DbConfigManager configManager = envImpl.getConfigManager(); maxReadBufferSize = configManager.getInt(EnvironmentParams.LOG_ITERATOR_MAX_SIZE); this.envImpl = envImpl; fileManager = envImpl.getFileManager(); readBuffer = ByteBuffer.allocate(readBufferSize); threadSafeBufferFlip(readBuffer); }