本文整理匯總了Java中com.sleepycat.je.Environment.setMutableConfig方法的典型用法代碼示例。如果您正苦於以下問題:Java Environment.setMutableConfig方法的具體用法?Java Environment.setMutableConfig怎麽用?Java Environment.setMutableConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sleepycat.je.Environment
的用法示例。
在下文中一共展示了Environment.setMutableConfig方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: doEvict
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
private static void doEvict(Environment env)
throws DatabaseException {
/* push the cache size down by half to force eviction. */
EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
long cacheUsage = envImpl.getMemoryBudget().getCacheMemoryUsage();
EnvironmentMutableConfig c = new EnvironmentMutableConfig();
c.setCacheSize(cacheUsage/2);
env.setMutableConfig(c);
long start = System.currentTimeMillis();
env.evictMemory();
long end = System.currentTimeMillis();
DecimalFormat f = new DecimalFormat();
f.setMaximumFractionDigits(2);
System.out.println("evict time=" + f.format(end-start));
}
示例2: doEvict
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
private static void doEvict(Environment env)
throws DatabaseException {
/* push the cache size down by half to force eviction. */
EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
long cacheUsage = envImpl.getMemoryBudget().getCacheMemoryUsage();
EnvironmentMutableConfig c = new EnvironmentMutableConfig();
c.setCacheSize(cacheUsage/2);
env.setMutableConfig(c);
long start = System.currentTimeMillis();
env.evictMemory();
long end = System.currentTimeMillis();
DecimalFormat f = new DecimalFormat();
f.setMaximumFractionDigits(2);
System.out.println("evict time=" + f.format(end-start));
}
示例3: doEvict
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
@SuppressWarnings("unused")
private static void doEvict(Environment env)
throws DatabaseException {
/* Push the cache size down by half to force eviction. */
EnvironmentImpl envImpl = DbInternal.getEnvironmentImpl(env);
long cacheUsage = envImpl.getMemoryBudget().getCacheMemoryUsage();
EnvironmentMutableConfig c = new EnvironmentMutableConfig();
c.setCacheSize(cacheUsage/2);
env.setMutableConfig(c);
long start = System.currentTimeMillis();
env.evictMemory();
long end = System.currentTimeMillis();
DecimalFormat f = new DecimalFormat();
f.setMaximumFractionDigits(2);
System.out.println("evict time=" + f.format(end-start));
}
示例4: setEnvironmentMutableConfig
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
void setEnvironmentMutableConfig(Environment env)
throws DatabaseException {
EnvironmentMutableConfig config = env.getMutableConfig();
config.setTxnNoSync(envNoSync);
config.setTxnWriteNoSync(envWriteNoSync);
env.setMutableConfig(config);
}
示例5: testRemoveNonPersistentDbSR15317
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
* Check that all INs are removed from the INList for a DB that is removed
* before it is sync'ed (or checkpointed). Before the bug fix, INs were
* not removed if the DB root IN was never logged (was still null). This
* caused a DatabaseException when evicting, because the evictor expects no
* INs for deleted DBs on the INList.
*/
public void testRemoveNonPersistentDbSR15317()
throws Throwable {
Database db = null;
try {
EnvironmentConfig envConfig = getEnvConfig(true);
/* Disable compressor for test predictability. */
envConfig.setConfigParam("je.env.runINCompressor", "false");
env = new Environment(envHome, envConfig);
db = createDb(true);
/* Insert some data to cause eviction later. */
insert(db,
null, // txn
1, // start
30000, // end
new HashSet(), // expected
false); // useRandom
db.close();
env.removeDatabase(null, DBNAME);
envConfig = env.getConfig();
/* Switch to a small cache to force eviction. */
envConfig.setCacheSize(96 * 1024);
env.setMutableConfig(envConfig);
for (int i = 0; i < 10; i += 1) {
env.evictMemory();
}
} finally {
if (env != null) {
try {
env.close();
} catch (Throwable e) {
System.out.println("Ignored: " + e);
}
env = null;
}
}
}
示例6: testRemoveNonPersistentDbSR15317
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
* Check that all INs are removed from the INList for a DB that is removed
* before it is sync'ed (or checkpointed). Before the bug fix, INs were
* not removed if the DB root IN was never logged (was still null). This
* caused a DatabaseException when evicting, because the evictor expects no
* INs for deleted DBs on the INList.
*/
public void testRemoveNonPersistentDbSR15317()
throws Throwable {
Database db = null;
try {
EnvironmentConfig envConfig = getEnvConfig(true);
/* Disable compressor for test predictability. */
envConfig.setConfigParam("je.env.runINCompressor", "false");
env = new Environment(envHome, envConfig);
db = createDb(true);
/* Insert some data to cause eviction later. */
insert(db,
null, // txn
1, // start
30000, // end
new HashSet(), // expected
false); // useRandom
db.close();
env.removeDatabase(null, DBNAME);
envConfig = env.getConfig();
/* Switch to a small cache to force eviction. */
envConfig.setCacheSize(96 * 1024);
env.setMutableConfig(envConfig);
for (int i = 0; i < 10; i += 1) {
env.evictMemory();
}
} finally {
if (env != null) {
try {
env.close();
} catch (Throwable e) {
System.out.println("Ignored: " + e);
}
env = null;
}
}
}
示例7: testCleanerStop
import com.sleepycat.je.Environment; //導入方法依賴的package包/類
/**
* Tests that setting je.env.runCleaner=false stops the cleaner from
* processing more files even if the target minUtilization is not met
* [#15158].
*/
public void testCleanerStop()
throws Throwable {
final int fileSize = 1000000;
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setAllowCreate(true);
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
envConfig.setConfigParam
(EnvironmentParams.LOG_FILE_MAX.getName(),
Integer.toString(fileSize));
envConfig.setConfigParam
(EnvironmentParams.CLEANER_MIN_UTILIZATION.getName(), "80");
Environment env = new Environment(envHome, envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
Database db = env.openDatabase(null, "CleanerStop", dbConfig);
DatabaseEntry key = new DatabaseEntry(new byte[1]);
DatabaseEntry data = new DatabaseEntry(new byte[fileSize]);
for (int i = 0; i <= 10; i += 1) {
db.put(null, key, data);
}
env.checkpoint(forceConfig);
EnvironmentStats stats = env.getStats(null);
assertEquals(0, stats.getNCleanerRuns());
envConfig = env.getConfig();
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CLEANER.getName(), "true");
env.setMutableConfig(envConfig);
int iter = 0;
while (stats.getNCleanerRuns() == 0) {
iter += 1;
if (iter == 20) {
fail("Cleaner did not run after " + iter + " tries");
}
Thread.yield();
Thread.sleep(1);
stats = env.getStats(null);
}
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
env.setMutableConfig(envConfig);
int prevNFiles = stats.getNCleanerRuns();
stats = env.getStats(null);
int currNFiles = stats.getNCleanerRuns();
if (currNFiles - prevNFiles > 5) {
fail("Expected less than 5 files cleaned," +
" prevNFiles=" + prevNFiles +
" currNFiles=" + currNFiles);
}
//System.out.println("Num runs: " + stats.getNCleanerRuns());
db.close();
env.close();
}