本文整理汇总了Java中com.sleepycat.je.CheckpointConfig.setForce方法的典型用法代码示例。如果您正苦于以下问题:Java CheckpointConfig.setForce方法的具体用法?Java CheckpointConfig.setForce怎么用?Java CheckpointConfig.setForce使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sleepycat.je.CheckpointConfig
的用法示例。
在下文中一共展示了CheckpointConfig.setForce方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: batchClean
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
private void batchClean()
throws DatabaseException {
int cleaned = 0;
int cleanedThisRound = 0;
do {
cleanedThisRound = env.cleanLog();
cleaned += cleanedThisRound;
} while (cleanedThisRound > 0);
if (DEBUG) {
System.out.println("numCleaned = " + cleaned);
}
assertTrue("cleaned must be > 0, was only " + cleaned +
" but may vary on machine to machine", cleaned > 0);
if (cleaned > 0) {
CheckpointConfig force = new CheckpointConfig();
force.setForce(true);
env.checkpoint(force);
}
}
示例2: doAction
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
void doAction(ReleaseLatchesTest test, int exceptionCount)
throws DatabaseException {
test.modify(exceptionCount);
CheckpointConfig config = new CheckpointConfig();
config.setForce(true);
if (DEBUG) {
System.out.println("Got to checkpoint");
}
test.getEnv().checkpoint(config);
}
示例3: doAction
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
void doAction(ReleaseLatchesTest test, int exceptionCount)
throws DatabaseException {
test.modify(exceptionCount);
CheckpointConfig config = new CheckpointConfig();
config.setForce(true);
if (DEBUG) {
System.out.println("Got to cleaning");
}
test.getEnv().cleanLog();
}
示例4: init
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
private void init() {
envHome = new File(System.getProperty(TestUtils.DEST_DIR));
Key.DUMP_TYPE = DumpType.BINARY;
envConfig = TestUtils.initEnvConfig();
forceConfig = new CheckpointConfig();
forceConfig.setForce(true);
}
示例5: invoke
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的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());
}
}
示例6: batchCleanAndVerify
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
private void batchCleanAndVerify(DatabaseId dbId)
throws Exception {
/*
* Open the environment, flip the log files to reduce mixing of new
* records and old records and add more records to force the
* utilization level of the removed records down.
*/
openEnv(true);
openDb(null, DB_NAME2);
long lsn = DbInternal.envGetEnvironmentImpl(env).forceLogFileFlip();
CheckpointConfig force = new CheckpointConfig();
force.setForce(true);
env.checkpoint(force);
writeAndCountRecords(null, RECORD_COUNT * 3);
env.checkpoint(force);
closeDb();
/* Check log files, there should be entries with this database. */
CheckReader checker = new CheckReader(env, dbId, true);
while (checker.readNextEntry()) {
}
if (DEBUG) {
System.out.println("entries for this db =" + checker.getCount());
}
assertTrue(checker.getCount() > 0);
/* batch clean. */
boolean anyCleaned = false;
while (env.cleanLog() > 0) {
anyCleaned = true;
}
assertTrue(anyCleaned);
if (anyCleaned) {
env.checkpoint(force);
}
/* Check log files, there should be no entries with this database. */
checker = new CheckReader(env, dbId, false);
while (checker.readNextEntry()) {
}
closeEnv();
}
示例7: batchCleanAndVerify
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
private void batchCleanAndVerify(DatabaseId dbId)
throws Exception {
/*
* Open the environment, flip the log files to reduce mixing of new
* records and old records and add more records to force the
* utilization level of the removed records down.
*/
openEnv(true);
openDb(null, DB_NAME2);
long lsn = DbInternal.envGetEnvironmentImpl(env).forceLogFileFlip();
CheckpointConfig force = new CheckpointConfig();
force.setForce(true);
env.checkpoint(force);
writeAndCountRecords(null, RECORD_COUNT * 3);
env.checkpoint(force);
closeDb();
/* Check log files, there should be entries with this database. */
CheckReader checker = new CheckReader(env, dbId, true);
while (checker.readNextEntry()) {
}
if (DEBUG) {
System.out.println("entries for this db =" + checker.getCount());
}
assertTrue(checker.getCount() > 0);
/* batch clean. */
boolean anyCleaned = false;
while (env.cleanLog() > 0) {
anyCleaned = true;
}
assertTrue(anyCleaned);
if (anyCleaned) {
env.checkpoint(force);
}
/* Check log files, there should be no entries with this database. */
checker = new CheckReader(env, dbId, false);
while (checker.readNextEntry()) {
}
closeEnv();
}
示例8: doTestBinDelta
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
private void doTestBinDelta(boolean useDeltas)
throws Throwable {
createEnvAndDbs(1 << 20, false, NUM_DBS);
StatsConfig statsConfig = new StatsConfig();
statsConfig.setClear(true);
CheckpointConfig deltaConfig = new CheckpointConfig();
deltaConfig.setForce(true);
deltaConfig.setMinimizeRecoveryTime(!useDeltas);
try {
/*
* Insert 4 records (nodeMax is 6), checkpoint, then insert 1
* record. The 1 record insertion will qualify for a delta,
* because the threshold percentage is 25%, and 25% of 4 is 1.
*/
int numRecs = 4;
Hashtable expectedData = new Hashtable();
Transaction txn = env.beginTransaction(null, null);
insertData(txn, 0, numRecs, expectedData, 1, true, NUM_DBS);
env.checkpoint(forceConfig);
insertData(txn, numRecs+1, numRecs+2, expectedData,
1, true, NUM_DBS);
txn.commit();
/*
* If useDeltas is true, this next checkpoint will end up using a
* BINDelta to log the last inserted record. It will have
* practically nothing but the root in the checkpoint.
*/
EnvironmentStats stats = env.getStats(statsConfig);
env.checkpoint(deltaConfig);
stats = env.getStats(statsConfig);
if (useDeltas) {
assertTrue(stats.getNDeltaINFlush() > 0);
} else {
assertTrue(stats.getNDeltaINFlush() == 0);
}
/* Shutdown, recover from a checkpoint that uses BINDeltas. */
closeEnv();
recoverAndVerify(expectedData, NUM_DBS);
} catch (Throwable t) {
t.printStackTrace();
throw t;
}
}
示例9: invoke
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
/**
* @see DynamicMBean#invoke
*/
public Object invoke(String actionName,
Object[] params,
String[] signature)
throws MBeanException {
/* Sanity checking. */
if (actionName == null) {
throw new IllegalArgumentException("ActionName can't be null.");
}
try {
if (actionName.equals(OP_CLEAN)) {
int numFiles = env.cleanLog();
return new Integer(numFiles);
} else if (actionName.equals(OP_EVICT)) {
env.evictMemory();
return null;
} else if (actionName.equals(OP_CHECKPOINT)) {
CheckpointConfig ckptConfig = new CheckpointConfig();
if ((params != null) && (params.length > 0)) {
Boolean force = (Boolean) params[0];
ckptConfig.setForce(force.booleanValue());
}
env.checkpoint(ckptConfig);
return null;
} else if (actionName.equals(OP_SYNC)) {
env.sync();
return null;
} else if (actionName.equals(OP_ENV_STAT)) {
return env.getStats(getStatsConfig(params)).toString();
} else if (actionName.equals(OP_TXN_STAT)) {
return env.getTransactionStats
(getStatsConfig(params)).toString();
} else if (actionName.equals(OP_DB_NAMES)) {
return env.getDatabaseNames();
} else if (actionName.equals(OP_DB_STAT)) {
DatabaseStats stats = getDatabaseStats(params);
return stats != null ? stats.toString() : null;
} else if (actionName.equals(OP_GET_TIPS)) {
return env.getStats
(getStatsConfig(new Object[] {false, true})).getTips();
} else if (actionName.equals(OP_ENV_CONFIG)) {
return env.getConfig().toString();
}
return new IllegalArgumentException
("ActionName: " + actionName + " is not valid.");
} catch (DatabaseException e) {
/*
* Add the message for easiest deciphering of the problem. Since
* the original exception cannot be transferred, send the exception
* stack.
*/
throw new MBeanException(new RuntimeException
(e.getMessage() +
LoggerUtils.getStackTrace(e)));
}
}
示例10: addData
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
private void addData(Database db)
throws DatabaseException {
DatabaseImpl dbImpl = DbInternal.dbGetDatabaseImpl(db);
EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
CheckpointConfig ckptConfig = new CheckpointConfig();
ckptConfig.setForce(true);
/*
* Create a one element dup tree by making a dupe and then reducing it
* back to one element.
*/
put(db, "cfhaa", "yrhwlvlgvq");
put(db, "cfhaa", "blort");
delete(db, "cfhaa", "blort");
env.compress();
env.sync();
/* Same thing for cfgaa. */
put(db, "cfgaa", "urhwlvlgvq");
put(db, "cfgaa", "blort");
delete(db, "cfgaa", "blort");
put(db, "cfiaa", "yrhwlvlgvq");
put(db, "cffaa", "yrhwlvlgvq");
env.sync();
env.sync();
/* Write out the DelDupLN and DupCountLN. */
delete(db, "cfhaa", "yrhwlvlgvq");
BIN bin = (BIN) dbImpl.getTree().search("cfhaa".getBytes(),
SearchType.NORMAL,
-1,
null,
true);
assertNotNull(bin);
int idx = bin.findEntry("cfhaa".getBytes(), false, true);
DIN din = (DIN) bin.getTarget(idx);
assertNotNull(din);
idx = din.findEntry("yrhwlvlgvq".getBytes(), false, true);
DBIN dbin = (DBIN) din.getTarget(idx);
Key.DUMP_BINARY = false;
dbin.log(envImpl.getLogManager());
din.log(envImpl.getLogManager());
bin.releaseLatch();
env.compress();
bin.log(envImpl.getLogManager());
}
示例11: addData
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
private void addData(Database db)
throws DatabaseException {
DatabaseImpl dbImpl = DbInternal.dbGetDatabaseImpl(db);
EnvironmentImpl envImpl = DbInternal.envGetEnvironmentImpl(env);
CheckpointConfig ckptConfig = new CheckpointConfig();
ckptConfig.setForce(true);
/*
* Create a one element dup tree by making a dupe and then reducing it
* back to one element.
*/
put(db, "cfhaa", "yrhwlvlgvq");
put(db, "cfhaa", "blort");
delete(db, "cfhaa", "blort");
env.compress();
env.sync();
/* Same thing for cfgaa. */
put(db, "cfgaa", "urhwlvlgvq");
put(db, "cfgaa", "blort");
delete(db, "cfgaa", "blort");
put(db, "cfiaa", "yrhwlvlgvq");
put(db, "cffaa", "yrhwlvlgvq");
env.sync();
env.sync();
/* Write out the DelDupLN and DupCountLN. */
delete(db, "cfhaa", "yrhwlvlgvq");
BIN bin = (BIN) dbImpl.getTree().search("cfhaa".getBytes(),
SearchType.NORMAL,
-1,
null,
true);
assertNotNull(bin);
int idx = bin.findEntry("cfhaa".getBytes(), false, true);
DIN din = (DIN) bin.getTarget(idx);
din.latch();
assertNotNull(din);
idx = din.findEntry("yrhwlvlgvq".getBytes(), false, true);
DBIN dbin = (DBIN) din.getTarget(idx);
Key.DUMP_BINARY = false;
dbin.latch();
dbin.log(envImpl.getLogManager());
din.log(envImpl.getLogManager());
din.releaseLatch();
dbin.releaseLatch();
bin.releaseLatch();
env.compress();
bin.latch();
bin.log(envImpl.getLogManager());
bin.releaseLatch();
}
示例12: testRollBackInsert
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
public void testRollBackInsert()
throws DatabaseException {
/* Transactional no-dups, 2 keys. */
openAndInit(true, false);
/* Add key 2, cursor appears on BIN. */
Transaction txn = env.beginTransaction(null, null);
Cursor cursor = db.openCursor(txn, null);
cursor.put(entry2, entry0);
checkBinEntriesAndCursors(bin, 3, 1);
/* Closing the cursor without abort does not compress. */
cursor.close();
env.compress();
checkBinEntriesAndCursors(bin, 3, 0);
/* Checkpoint to preserve internal nodes through recovery. */
CheckpointConfig config = new CheckpointConfig();
config.setForce(true);
env.checkpoint(config);
/* Abort without calling compress does not compress. */
txn.abort();
checkBinEntriesAndCursors(bin, 3, 0);
/*
* Shutdown and reopen to run recovery. This will call a checkpoint,
* but it doesn't compress because the child is not resident.
*/
db.close();
DbInternal.envGetEnvironmentImpl(env).close(false);
env = null;
openEnv(true, false, null);
initInternalNodes();
checkBinEntriesAndCursors(bin, 3, 0);
/* Should be no change in parent nodes. */
assertEquals(2, in.getNEntries());
/* Finally compress can compress. */
env.compress();
checkBinEntriesAndCursors(bin, 2, 0);
closeEnv();
}
示例13: reinitSelfElect
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
/**
* Establishes this node as the master, after re-initializing the group
* with this as the sole node in the group. This method is used solely
* as part of the DbResetrepGroup utility.
*/
void reinitSelfElect()
throws IOException {
/* Establish an empty group so transaction commits can proceed. */
group = repGroupDB.emptyGroup;
LoggerUtils.info(logger, repImpl, "Reinitializing group to node " +
nameIdPair);
/*
* Unilaterally transition the nodeState to Master, so that write
* transactions needed to reset the group and establish this node can
* be issued against the environment.
*/
nodeState.changeAndNotify(MASTER, masterStatus.getNodeMasterNameId());
repImpl.getVLSNIndex().initAsMaster();
/*
* Start using new log files. The file ensures that we can safely
* truncate the past VLSNs.
*/
repImpl.forceLogFileFlip();
CheckpointConfig ckptConfig = new CheckpointConfig();
ckptConfig.setForce(true);
/*
* The checkpoint ensures that we do not have to replay VLSNs from the
* prior group and that we have a complete VLSN index on disk.
*/
repImpl.getCheckpointer().doCheckpoint(ckptConfig,
"Reinit of RepGroup");
VLSN lastOldVLSN = repImpl.getVLSNIndex().getRange().getLast();
/* Now create the new rep group on disk. */
repGroupDB.reinitFirstNode(lastOldVLSN);
refreshCachedGroup();
long lastOldFile =
repImpl.getVLSNIndex().getLTEFileNumber(lastOldVLSN);
/*
* Discard the VLSN index covering the pre group reset VLSNS, to ensure
* that the pre reset part of the log is never replayed. We don't want
* to replay this part of the log, since it contains references to
* repnodes via node ids that are no longer part of the reset rep
* group. Note that we do not reuse rep node ids, that is, rep node id
* sequence continues across the reset operation and is not itself
* reset. Nodes joining the new group will need to do a network restore
* when they join the group.
*/
repImpl.getVLSNIndex().truncateFromHead(lastOldVLSN, lastOldFile);
elections.startLearner();
/* Unsync so that the run loop does not call for an election. */
masterStatus.unSync();
}
示例14: testRemoveAbort
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
/**
* Test that aborting remove generates the right number of obsolete LNs.
*/
public void testRemoveAbort()
throws Exception {
/* Create database, populate, remove, abort the remove. */
openEnv(true);
openDb(null, DB_NAME1);
writeAndCountRecords(null, RECORD_COUNT);
DatabaseImpl saveDb = dbImpl;
closeDb();
Transaction txn = env.beginTransaction(null, null);
env.removeDatabase(txn, DB_NAME1);
ObsoleteCounts beforeAbort = getObsoleteCounts();
txn.abort();
/* Make sure use count is decremented when we abort. */
assertDbInUse(saveDb, false);
verifyUtilization(beforeAbort, 0, 0);
/* All records should be there. */
openDb(null, DB_NAME1);
assertEquals(RECORD_COUNT, countRecords(null));
closeEnv();
/*
* Batch clean and then check the record count again, just to make sure
* we don't lose any valid data.
*/
openEnv(true);
while (env.cleanLog() > 0) {
}
CheckpointConfig force = new CheckpointConfig();
force.setForce(true);
env.checkpoint(force);
closeEnv();
openEnv(true);
openDb(null, DB_NAME1);
assertEquals(RECORD_COUNT, countRecords(null));
closeEnv();
}
示例15: openAndInitEmptyMiddleBIN
import com.sleepycat.je.CheckpointConfig; //导入方法依赖的package包/类
/**
* Create a tree with:
* IN
* / \
* IN IN
* / \ / \
* BIN1 BIN2 BIN3 BIN4
*
* where BIN1 has values 0,1
* BIN2 has valus 2,3,4
* BIN3 has valus 5,6,7
* BIN4 has valus 8,9,10
* Depending on configuration, the entries in BIN2 or BIN3
*/
private void openAndInitEmptyMiddleBIN(int deleteStartVal,
int deleteEndVal)
throws DatabaseException {
openEnv(false, "4");
DatabaseEntry data = new DatabaseEntry();
data.setData(new byte[] {DEFAULT_VAL});
DatabaseEntry key = new DatabaseEntry();
key.setData(new byte[] {DEFAULT_VAL});
/* Create four BINs */
OperationStatus status;
for (int i = 0; i < 11; i++) {
if (useDups) {
data = new DatabaseEntry(new byte[] { (byte) i });
} else {
key = new DatabaseEntry(new byte[] { (byte) i });
}
status = db.put(null, key, data);
assertEquals(OperationStatus.SUCCESS, status);
}
/* Empty out one of the middle ones. */
if (useDups) {
Cursor cursor = db.openCursor(null, null);
data = new DatabaseEntry(new byte[] { (byte) deleteStartVal });
assertEquals(OperationStatus.SUCCESS,
cursor.getSearchBoth(key, data, LockMode.DEFAULT));
for (int i = deleteStartVal; i <= deleteEndVal; i++) {
assertEquals(OperationStatus.SUCCESS,
cursor.delete());
assertEquals(OperationStatus.SUCCESS,
cursor.getNext(key, data, LockMode.DEFAULT));
}
cursor.close();
} else {
for (int i = deleteStartVal; i <= deleteEndVal; i++) {
key = new DatabaseEntry(new byte[] { (byte) i });
status = db.delete(null, key);
assertEquals(OperationStatus.SUCCESS, status);
}
}
CheckpointConfig config = new CheckpointConfig();
config.setForce(true);
env.checkpoint(config);
}