本文整理汇总了Java中com.sleepycat.je.Environment.checkpoint方法的典型用法代码示例。如果您正苦于以下问题:Java Environment.checkpoint方法的具体用法?Java Environment.checkpoint怎么用?Java Environment.checkpoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sleepycat.je.Environment
的用法示例。
在下文中一共展示了Environment.checkpoint方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeAndClean
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
private static void removeAndClean(Environment env,
String name,
boolean doCleaning)
throws Exception {
long a, c, d, e, f;
Transaction txn = null;
CheckpointConfig force = new CheckpointConfig();
force.setForce(true);
a = System.currentTimeMillis();
env.removeDatabase(txn, name);
c = System.currentTimeMillis();
int cleanedCount = 0;
if (doCleaning) {
while (env.cleanLog() > 0) {
cleanedCount++;
}
}
d = System.currentTimeMillis();
System.out.println("cleanedCount=" + cleanedCount);
e = 0;
f = 0;
if (cleanedCount > 0) {
e = System.currentTimeMillis();
env.checkpoint(force);
f = System.currentTimeMillis();
}
System.out.println("Remove of " + name +
" remove: " + getSecs(a, c) +
" clean: " + getSecs(c, d) +
" checkpoint: " + getSecs(e, f));
}
示例2: startup
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
public void startup(HGStore store, HGConfiguration config)
{
this.store = store;
this.handleFactory = config.getHandleFactory();
this.linkBinding = new LinkBinding(handleFactory);
EnvironmentConfig envConfig = configuration.getEnvironmentConfig();
envConfig.setConfigParam(EnvironmentConfig.CLEANER_THREADS, "5");
envConfig.setClassLoader(new HGClassLoaderDelegate(config));
if (config.isTransactional())
{
configuration.configureTransactional();
}
File envDir = new File(store.getDatabaseLocation());
envDir.mkdirs();
try
{
env = new Environment(envDir, envConfig);
data_db = env.openDatabase(null, DATA_DB_NAME, configuration.getDatabaseConfig().clone());
primitive_db = env.openDatabase(null, PRIMITIVE_DB_NAME, configuration.getDatabaseConfig().clone());
DatabaseConfig incConfig = configuration.getDatabaseConfig().clone();
incConfig.setSortedDuplicates(true);
incidence_db = env.openDatabase(null, INCIDENCE_DB_NAME, incConfig);
openIndices = new HashMap<String, HGIndex<?, ?>>(); // force reset
// since startup
// can follow a
// shutdown on
// same opened
// class
if (config.isTransactional())
{
CheckpointConfig ckptConfig = new CheckpointConfig();
// System.out.println("checkpoint kbytes:" +
// ckptConfig.getKBytes());
// System.out.println("checkpoint minutes:" +
// ckptConfig.getMinutes());
env.checkpoint(null);
checkPointThread = new CheckPointThread();
checkPointThread.start();
}
}
catch (Exception ex)
{
throw new HGException("Failed to initialize HyperGraph data store: " + ex.toString(), ex);
}
}
示例3: invoke
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Invoke an operation for the given environment.
*
* @param targetEnv The target JE environment. May be null if the
* environment is not open.
* @param actionName operation name.
* @param params operation parameters. May be null.
* @param signature operation signature. May be null.
* @return the operation result
*/
public Object invoke(Environment targetEnv,
String actionName,
Object [] params,
String [] signature)
throws MBeanException {
/* Sanity checking. */
if (actionName == null) {
throw new IllegalArgumentException("actionName cannot be null");
}
try {
if (targetEnv != null) {
if (actionName.equals(OP_CLEAN)) {
int numFiles = targetEnv.cleanLog();
return new Integer(numFiles);
} else if (actionName.equals(OP_EVICT)) {
targetEnv.evictMemory();
return null;
} else if (actionName.equals(OP_CHECKPOINT)) {
CheckpointConfig config = new CheckpointConfig();
if ((params != null) && (params.length > 0)) {
Boolean force = (Boolean) params[0];
config.setForce(force.booleanValue());
}
targetEnv.checkpoint(config);
return null;
} else if (actionName.equals(OP_SYNC)) {
targetEnv.sync();
return null;
} else if (actionName.equals(OP_ENV_STAT)) {
return targetEnv.getStats(getStatsConfig(params));
} else if (actionName.equals(OP_LOCK_STAT)) {
return targetEnv.getLockStats(getStatsConfig(params));
} else if (actionName.equals(OP_TXN_STAT)) {
return targetEnv.getTransactionStats(
getStatsConfig(params));
} else if (actionName.equals(OP_DB_NAMES)) {
return targetEnv.getDatabaseNames();
} else if (actionName.equals(OP_DB_STAT)) {
return getDatabaseStats(targetEnv, params);
}
}
return new IllegalArgumentException("actionName: " +
actionName +
" is not valid");
} catch (DatabaseException e) {
/*
* Add both the message and the exception for easiest
* deciphering of the problem. Sometimes the original exception
* stacktrace gets hidden in server logs.
*/
throw new MBeanException(e, e.getMessage());
}
}
示例4: removeAndClean
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
private static void removeAndClean(Environment env,
String name,
boolean doCleaning)
throws DatabaseException {
long a, b, c, d, e, f;
// Transaction txn = env.beginTransaction(null, null);
Transaction txn = null;
CheckpointConfig force = new CheckpointConfig();
force.setForce(true);
a = System.currentTimeMillis();
env.removeDatabase(txn, name);
b = System.currentTimeMillis();
// txn.commit();
c = System.currentTimeMillis();
int cleanedCount = 0;
if (doCleaning) {
while (env.cleanLog() > 0) {
cleanedCount++;
}
}
d = System.currentTimeMillis();
System.out.println("cleanedCount=" + cleanedCount);
e = 0;
f = 0;
if (cleanedCount > 0) {
e = System.currentTimeMillis();
env.checkpoint(force);
f = System.currentTimeMillis();
}
System.out.println("Remove of " + name +
" remove: " + getSecs(a, b) +
" commit: " + getSecs(b, c) +
" clean: " + getSecs(c, d) +
" checkpoint: " + getSecs(e, f));
}
示例5: 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();
}
示例6: invoke
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Invoke an operation for the given environment.
*
* @param targetEnv The target JE environment. May be null if the
* environment is not open.
* @param actionName operation name.
* @param params operation parameters. May be null.
* @param signature operation signature. May be null.
* @return the operation result
*/
public Object invoke(Environment targetEnv,
String actionName,
Object [] params,
String [] signature)
throws MBeanException {
/* Sanity checking. */
if (actionName == null) {
throw new IllegalArgumentException("actionName cannot be null");
}
try {
if (targetEnv != null) {
if (actionName.equals(OP_CLEAN)) {
int numFiles = targetEnv.cleanLog();
return new Integer(numFiles);
} else if (actionName.equals(OP_EVICT)) {
targetEnv.evictMemory();
return null;
} else if (actionName.equals(OP_CHECKPOINT)) {
CheckpointConfig config = new CheckpointConfig();
if ((params != null) && (params.length > 0)) {
Boolean force = (Boolean) params[0];
config.setForce(force.booleanValue());
}
targetEnv.checkpoint(config);
return null;
} else if (actionName.equals(OP_SYNC)) {
targetEnv.sync();
return null;
} else if (actionName.equals(OP_ENV_STAT)) {
return targetEnv.getStats(getStatsConfig(params));
} else if (actionName.equals(OP_LOCK_STAT)) {
return targetEnv.getLockStats(getStatsConfig(params));
} else if (actionName.equals(OP_TXN_STAT)) {
return targetEnv.getTransactionStats(
getStatsConfig(params));
} else if (actionName.equals(OP_DB_NAMES)) {
return targetEnv.getDatabaseNames();
} else if (actionName.equals(OP_DB_STAT)) {
return getDatabaseStats(targetEnv, params);
}
}
return new IllegalArgumentException("actionName: " +
actionName +
" is not valid");
} catch (DatabaseException e) {
/*
* Add both the message and the exception for easiest
* deciphering of the problem. Sometimes the original exception
* stacktrace gets hidden in server logs.
*/
throw new MBeanException(e, e.getMessage());
}
}
示例7: removeAndClean
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
private static void removeAndClean(Environment env,
String name,
boolean doCleaning)
throws DatabaseException {
long a, b, c, d, e, f;
// Transaction txn = env.beginTransaction(null, null);
Transaction txn = null;
CheckpointConfig force = new CheckpointConfig();
force.setForce(true);
a = System.currentTimeMillis();
env.removeDatabase(txn, name);
b = System.currentTimeMillis();
// txn.commit();
c = System.currentTimeMillis();
int cleanedCount = 0;
if (doCleaning) {
while (env.cleanLog() > 0) {
cleanedCount++;
}
}
d = System.currentTimeMillis();
System.out.println("cleanedCount=" + cleanedCount);
e = 0;
f = 0;
if (cleanedCount > 0) {
e = System.currentTimeMillis();
env.checkpoint(force);
f = System.currentTimeMillis();
}
System.out.println("Remove of " + name +
" remove: " + getSecs(a, b) +
" commit: " + getSecs(b, c) +
" clean: " + getSecs(c, d) +
" checkpoint: " + getSecs(e, f));
}
示例8: invoke
import com.sleepycat.je.Environment; //导入方法依赖的package包/类
/**
* Invoke an operation for the given environment.
*
* @param targetEnv The target JE environment. May be null if the
* environment is not open.
* @param actionName operation name.
* @param params operation parameters. May be null.
* @param signature operation signature. May be null.
* @return the operation result
*/
public Object invoke(Environment targetEnv,
String actionName,
Object[] params,
String[] signature)
throws MBeanException {
/* Sanity checking. */
if (actionName == null) {
throw new IllegalArgumentException("actionName cannot be null");
}
try {
if (targetEnv != null) {
if (actionName.equals(OP_CLEAN)) {
int numFiles = targetEnv.cleanLog();
return new Integer(numFiles);
} else if (actionName.equals(OP_EVICT)) {
targetEnv.evictMemory();
return null;
} else if (actionName.equals(OP_CHECKPOINT)) {
CheckpointConfig config = new CheckpointConfig();
if ((params != null) && (params.length > 0)) {
Boolean force = (Boolean) params[0];
config.setForce(force.booleanValue());
}
targetEnv.checkpoint(config);
return null;
} else if (actionName.equals(OP_SYNC)) {
targetEnv.sync();
return null;
} else if (actionName.equals(OP_ENV_STAT)) {
return targetEnv.getStats
(getStatsConfig(params)).toString();
} else if (actionName.equals(OP_TXN_STAT)) {
return targetEnv.getTransactionStats
(getStatsConfig(params)).toString();
} else if (actionName.equals(OP_DB_NAMES)) {
return targetEnv.getDatabaseNames();
} else if (actionName.equals(OP_DB_STAT)) {
DatabaseStats stats = getDatabaseStats(targetEnv, params);
return stats != null ? stats.toString() : null;
}
}
return new IllegalArgumentException
("actionName: " + actionName + " is not valid");
} catch (Exception e) {
/*
* Add both the message and the exception for easiest deciphering
* of the problem. Sometimes the original exception stacktrace gets
* hidden in server logs.
*/
throw new MBeanException(e, e.getMessage());
}
}