本文整理匯總了Java中com.sleepycat.je.EnvironmentConfig.setTransactional方法的典型用法代碼示例。如果您正苦於以下問題:Java EnvironmentConfig.setTransactional方法的具體用法?Java EnvironmentConfig.setTransactional怎麽用?Java EnvironmentConfig.setTransactional使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sleepycat.je.EnvironmentConfig
的用法示例。
在下文中一共展示了EnvironmentConfig.setTransactional方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: UpdateGroundhogScript
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public UpdateGroundhogScript(File datadir) throws DatabaseException {
environmentConfig = new EnvironmentConfig();
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(true);
environmentConfig.setCacheSize(302400000);
// perform other environment configurations
environment = new Environment(datadir, environmentConfig);
List<String> names = environment.getDatabaseNames();
if (names.contains(datadir.getName())) {
environment.renameDatabase(null, datadir.getName(), databaseName);
}
environment.close();
}
示例2: init
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
private void init(File datadir){
try {
environmentConfig = new EnvironmentConfig();
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(true);
environmentConfig.setCacheSize(30240000);
environment = new Environment(datadir, environmentConfig);
databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(true);
databaseConfig.setTransactional(true);
openDB();
myIntegerBinding = TupleBinding.getPrimitiveBinding(Integer.class);
myDataBinding = new IntegerToSetOfIntegersBinding();
sh = new IntegerSetStoreShutdown();
sh.g = this;
Runtime.getRuntime().addShutdownHook(sh);
} catch (DatabaseException e) {
e.printStackTrace();
}
}
示例3: init
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
private void init(File datadir){
try {
environmentConfig = new EnvironmentConfig();
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(true);
environmentConfig.setCacheSize(30240000);
environment = new Environment(datadir, environmentConfig);
databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(true);
databaseConfig.setTransactional(true);
openDB();
myIntegerBinding = TupleBinding.getPrimitiveBinding(Integer.class);
myDataBinding = new Integer2Integer2IntegerMapBinding();
sh = new CooccurrenceDatabaseShutdown();
sh.c = this;
Runtime.getRuntime().addShutdownHook(sh);
} catch (DatabaseException e) {
e.printStackTrace();
}
}
示例4: initialize
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
private void initialize() throws DatabaseException{
environmentConfig = new EnvironmentConfig();
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(false);
environmentConfig.setCacheSize(cachesize);
// perform other environment configurations
environment = new Environment(datadir, environmentConfig);
databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(true);
databaseConfig.setTransactional(false);
// perform other database configurations
openDB();
// add a shutdown hook to close the database when the VM is terminated
sh = new Shutdown();
sh.cache = this;
Runtime.getRuntime().addShutdownHook(sh);
}
示例5: init
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
@Override
public void init() {
EnvironmentConfig envConfig = new EnvironmentConfig();
commonConfig(envConfig);
envConfig.setCachePercent(config.getCachePercent());
envConfig.setAllowCreate(true);
if (config.isTransactional()) {
envConfig.setCachePercent(config.getCachePercent());
envConfig.setTransactional(config.isTransactional());
envConfig.setTxnTimeout(config.getTxnTimeout(), TimeUnit.SECONDS);
this.durability = config.isCommitSync() ? Durability.COMMIT_SYNC : Durability.COMMIT_NO_SYNC;
envConfig.setDurability(this.durability);
}
File repo_dir = new File(config.getRepoDir());
if (!repo_dir.exists()) {
repo_dir.mkdirs();
}
this.env = new Environment(repo_dir, envConfig);
cef = new CommandHandlerFactoryBDBImpl();
cursorFactoryBDBImp = new CursorFactoryBDBImp();
}
示例6: WebGraph
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
/**
* 構造函數
*/
public WebGraph(String dbDir) throws DatabaseException {
File envDir = new File(dbDir);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(false);
envConfig.setAllowCreate(true);
Environment env = new Environment(envDir, envConfig);
StoreConfig storeConfig = new StoreConfig();
storeConfig.setAllowCreate(true);
storeConfig.setTransactional(false);
store = new EntityStore(env, "classDb", storeConfig);
outLinkIndex = store.getPrimaryIndex(String.class, Link.class);
inLinkIndex = store.getSecondaryIndex(outLinkIndex, String.class, "toURL");
}
示例7: AbstractFrontier
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
public AbstractFrontier(String homeDirectory) {
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// 設置databaseconfig
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// 打開
catalogdatabase = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogdatabase);
// 設置databaseconfig
DatabaseConfig dbConfig0 = new DatabaseConfig();
dbConfig0.setTransactional(true);
dbConfig0.setAllowCreate(true);
database = env.openDatabase(null, "URL", dbConfig0);
}
示例8: openEnv
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
private static void openEnv() throws DatabaseException {
System.out.println("opening env and store");
// Set up the environment.
EnvironmentConfig myEnvConfig = new EnvironmentConfig();
myEnvConfig.setAllowCreate(true);
myEnvConfig.setTransactional(true);
// Environment handles are free-threaded by default in JE,
// so we do not have to do anything to cause the
// environment handle to be free-threaded.
// Set up the entity store
StoreConfig myStoreConfig = new StoreConfig();
myStoreConfig.setAllowCreate(true);
myStoreConfig.setTransactional(true);
// Open the environment
myEnv = new Environment(new File(myEnvPath), // Env home
myEnvConfig);
// Open the store
myStore = new EntityStore(myEnv, storeName, myStoreConfig);
}
示例9: testGreaterVersionNotAllowed
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
/**
* Tests that an exception is thrown when a log header is read with a newer
* version than the current version. The maxversion.jdb log file is loaded
* as a resource by this test and written as a regular log file. When the
* environment is opened, we expect a LogException.
*/
public void testGreaterVersionNotAllowed()
throws DatabaseException, IOException {
TestUtils.loadLog(getClass(), Utils.MAX_VERSION_NAME, envHome);
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setAllowCreate(false);
envConfig.setTransactional(true);
try {
Environment env = new Environment(envHome, envConfig);
try {
env.close();
} catch (Exception ignore) {}
} catch (DatabaseException e) {
if (e.getCause() instanceof LogException) {
/* Got LogException as expected. */
return;
}
}
fail("Expected LogException");
}
示例10: SessionDatabase
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
/**
* Open all storage containers and catalogs.
*/
public SessionDatabase(String homeDirectory)
throws DatabaseException {
// Open the Berkeley DB environment in transactional mode.
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(new File(homeDirectory), envConfig);
// Set the Berkeley DB config for opening all stores.
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// Create the Serial class catalog. This holds the serialized class
// format for all database records of serial format.
//
Database catalogDb = env.openDatabase(null, CLASS_CATALOG, dbConfig);
javaCatalog = new StoredClassCatalog(catalogDb);
// Open the Berkeley DB database for the monitor session
// store. The store is opened with no duplicate keys allowed.
sessionDb = env.openDatabase(null, SESSION_STORE, dbConfig);
}
示例11: setUp
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
public void setUp() throws IOException, DatabaseException {
TestUtils.removeFiles("Setup", envHome, FileManager.JE_SUFFIX);
/*
* Properties for creating an environment.
* Disable the evictor for this test, use larger BINS
*/
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setTransactional(true);
envConfig.setConfigParam(EnvironmentParams.ENV_RUN_EVICTOR.getName(), "true");
envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "50");
envConfig.setConfigParam(EnvironmentParams.BIN_DELTA_PERCENT.getName(), "50");
envConfig.setAllowCreate(true);
env = new Environment(envHome, envConfig);
logManager = DbInternal.envGetEnvironmentImpl(env).getLogManager();
}
示例12: initEnv
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
private void initEnv()
throws DatabaseException {
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "4");
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
env = new Environment(envHome, envConfig);
String databaseName = "testDb";
Transaction txn = env.beginTransaction(null, null);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(true);
db = env.openDatabase(txn, databaseName, dbConfig);
txn.commit();
}
示例13: main
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
/** Creates the environment and runs a transaction */
public static void main(String[] argv)
throws Exception {
String dir = "./tmp";
// environment is transactional
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
if (create) {
envConfig.setAllowCreate(true);
}
Environment env = new Environment(new File(dir), envConfig);
// create the application and run a transaction
HelloDatabaseWorld worker = new HelloDatabaseWorld(env);
TransactionRunner runner = new TransactionRunner(env);
try {
// open and access the database within a transaction
runner.run(worker);
} finally {
// close the database outside the transaction
worker.close();
}
}
示例14: openEnv
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
private void openEnv()
throws DatabaseException {
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
DbInternal.disableParameterValidation(envConfig);
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
envConfig.setTxnNoSync(Boolean.getBoolean(TestUtils.NO_SYNC));
envConfig.setConfigParam
(EnvironmentParams.CLEANER_MIN_UTILIZATION.getName(), "80");
envConfig.setConfigParam
(EnvironmentParams.LOG_FILE_MAX.getName(),
Integer.toString(FILE_SIZE));
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CLEANER.getName(), "false");
envConfig.setConfigParam
(EnvironmentParams.ENV_RUN_CHECKPOINTER.getName(), "false");
env = new Environment(envHome, envConfig);
envImpl = DbInternal.envGetEnvironmentImpl(env);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
db = env.openDatabase(null, "ReadOnlyLockingTest", dbConfig);
}
示例15: initEngine
import com.sleepycat.je.EnvironmentConfig; //導入方法依賴的package包/類
public boolean initEngine(File envHome)
{
EnvironmentConfig envConfig = new EnvironmentConfig();
m_DbConfig = new DatabaseConfig();
// If the environment is read-only, then
// make the databases read-only too.
envConfig.setReadOnly(false);
m_DbConfig.setReadOnly(false);
// If the environment is opened for write, then we want to be
// able to create the environment and databases if
// they do not exist.
envConfig.setAllowCreate(true);
m_DbConfig.setAllowCreate(true);
// Allow transactions if we are writing to the database
envConfig.setTransactional(false);
m_DbConfig.setTransactional(false);
m_DbConfig.setDeferredWrite(true);
envConfig.setLocking(false); // No locking
m_DbConfig.setBtreeComparator(BtreeKeyComparator.class);
// Open the environment
try
{
m_env = new Environment(envHome, envConfig);
return true;
}
catch(DatabaseException e)
{
return false;
}
}