本文整理匯總了Java中com.sleepycat.je.EnvironmentConfig類的典型用法代碼示例。如果您正苦於以下問題:Java EnvironmentConfig類的具體用法?Java EnvironmentConfig怎麽用?Java EnvironmentConfig使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
EnvironmentConfig類屬於com.sleepycat.je包,在下文中一共展示了EnvironmentConfig類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.sleepycat.je.EnvironmentConfig; //導入依賴的package包/類
public static void main(String [] args) throws Exception
{
EnvironmentConfig v_EnvConfig = new EnvironmentConfig();
DatabaseConfig v_DBConfig = new DatabaseConfig();
Berkeley v_Berkeley = new Berkeley();
v_EnvConfig.setAllowCreate(true);
v_DBConfig.setAllowCreate(true);
v_Berkeley.setEnvironmentConfig(v_EnvConfig);
v_Berkeley.setDatabaseConfig( v_DBConfig);
v_Berkeley.setEnvironmentHome( "/Users/hy/WSS/WorkSpace_SearchDesktop/hy.common.berkeley/db");
v_Berkeley.setDatabaseName( "HY");
v_Berkeley.open();
String v_Key = "ZhengWei(HY)";
v_Berkeley.put(v_Key ,Date.getNowTime().getFullMilli());
System.out.println(v_Berkeley.get(v_Key));
}
示例2: 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();
}
示例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 IntegerToSetOfIntegersBinding();
sh = new IntegerSetStoreShutdown();
sh.g = this;
Runtime.getRuntime().addShutdownHook(sh);
} catch (DatabaseException e) {
e.printStackTrace();
}
}
示例4: 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();
}
}
示例5: 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);
}
示例6: commonConfig
import com.sleepycat.je.EnvironmentConfig; //導入依賴的package包/類
public void commonConfig(EnvironmentConfig envConfig) {
System.setProperty("JEMonitor", "true");
envConfig.setConfigParam(EnvironmentConfig.NODE_MAX_ENTRIES, "256");
envConfig.setConfigParam(EnvironmentConfig.EVICTOR_EVICT_BYTES, (1024 * 1024 * 2) + "");
envConfig.setConfigParam(EnvironmentConfig.EVICTOR_NODES_PER_SCAN, "10");
envConfig.setConfigParam(EnvironmentConfig.EVICTOR_LRU_ONLY, "false");
envConfig.setConfigParam(EnvironmentConfig.EVICTOR_FORCED_YIELD, "true");
envConfig.setConfigParam(EnvironmentConfig.EVICTOR_CORE_THREADS, Runtime.getRuntime().availableProcessors()
+ "");
envConfig.setConfigParam(EnvironmentConfig.EVICTOR_MAX_THREADS, Runtime.getRuntime().availableProcessors() + "");
envConfig.setConfigParam(EnvironmentConfig.CHECKPOINTER_BYTES_INTERVAL, 1024 * 1024 * 200 + "");
envConfig.setConfigParam(EnvironmentConfig.CLEANER_LAZY_MIGRATION, "true");
envConfig.setConfigParam(EnvironmentConfig.CLEANER_THREADS, Runtime.getRuntime().availableProcessors() + "");
envConfig.setConfigParam(EnvironmentConfig.CLEANER_LOOK_AHEAD_CACHE_SIZE, 1024 * 8 + "");
envConfig.setConfigParam(EnvironmentConfig.CLEANER_READ_SIZE, 1024 * 1024 + "");
envConfig.setConfigParam(EnvironmentConfig.LOG_FILE_MAX, 1024 * 1024 * 200 + "");
envConfig.setConfigParam(EnvironmentConfig.LOG_FILE_CACHE_SIZE, "1024");
envConfig.setConfigParam(EnvironmentConfig.LOG_USE_WRITE_QUEUE, "true");
envConfig.setConfigParam(EnvironmentConfig.LOG_WRITE_QUEUE_SIZE, 1024 * 1024 * 2 + "");
// envConfig.setConfigParam(EnvironmentConfig.HALT_ON_COMMIT_AFTER_CHECKSUMEXCEPTION,
// "true");
envConfig.setConfigParam(EnvironmentConfig.LOG_ITERATOR_READ_SIZE, 1024 * 8 + "");
envConfig.setConfigParam(EnvironmentConfig.LOCK_TIMEOUT, 2000 + "\tMILLISECONDS");
envConfig.setConfigParam(EnvironmentConfig.ENV_RECOVERY_FORCE_CHECKPOINT, "true");
}
示例7: 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();
}
示例8: 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");
}
示例9: 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);
}
示例10: resetDefaults
import com.sleepycat.je.EnvironmentConfig; //導入依賴的package包/類
private void resetDefaults(boolean readOnly)
{
envConfig.setReadOnly(readOnly);
dbConfig.setReadOnly(readOnly);
envConfig.setAllowCreate(!readOnly);
dbConfig.setAllowCreate(!readOnly);
// envConfig.setCacheSize(DEFAULT_STORE_CACHE);
envConfig.setCachePercent(30);
envConfig.setConfigParam(EnvironmentConfig.LOG_FILE_MAX,
Long.toString(10000000 * 10l));
envConfig.setConfigParam(
EnvironmentConfig.CLEANER_LOOK_AHEAD_CACHE_SIZE,
Long.toString(1024 * 1024));
envConfig.setConfigParam(EnvironmentConfig.CLEANER_READ_SIZE,
Long.toString(1024 * 1024));
}
示例11: open
import com.sleepycat.je.EnvironmentConfig; //導入依賴的package包/類
@Override
public void open() {
try {
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setCachePercent(90);
File file = new File(databaseDir_);
if (!file.exists()) {
file.mkdirs();
}
env_ = new Environment(file, envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
bdb_ = env_
.openDatabase(null, BdbBenchmark.DATABASE_NAME, dbConfig);
} catch (DatabaseException e) {
e.printStackTrace();
}
}
示例12: getConnection
import com.sleepycat.je.EnvironmentConfig; //導入依賴的package包/類
private JEConnection getConnection(String envDir) {
try {
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(true);
envConfig.setAllowCreate(true);
InitialContext iniCtx = new InitialContext();
Context enc = (Context) iniCtx.lookup("java:comp/env");
Object ref = enc.lookup("ra/JEConnectionFactory");
JEConnectionFactory dcf = (JEConnectionFactory) ref;
JEConnection dc = dcf.getConnection(envDir, envConfig);
return dc;
} catch(Exception e) {
System.err.println("Failure in getConnection " + e);
}
return null;
}
示例13: openEnvAndDb
import com.sleepycat.je.EnvironmentConfig; //導入依賴的package包/類
private void openEnvAndDb()
throws DatabaseException {
/*
* Make an environment with small nodes and no daemons.
*/
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
DbInternal.disableParameterValidation(envConfig);
envConfig.setAllowCreate(true);
envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "4");
envConfig.setConfigParam("je.env.runEvictor", "false");
envConfig.setConfigParam("je.env.runCheckpointer", "false");
envConfig.setConfigParam("je.env.runCleaner", "false");
envConfig.setConfigParam("je.env.runINCompressor", "false");
envConfig.setConfigParam
(EnvironmentParams.CLEANER_MIN_UTILIZATION.getName(), "90");
envConfig.setConfigParam(EnvironmentParams.LOG_FILE_MAX.getName(),
Integer.toString(20000));
env = new Environment(envHome, envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(true);
db = env.openDatabase(null, "foo", dbConfig);
}
示例14: setup
import com.sleepycat.je.EnvironmentConfig; //導入依賴的package包/類
/**
* Setup a Berkeley DB engine environment, and preload some example records.
*
* @throws com.sleepycat.je.DatabaseException
*/
public void setup()
throws DatabaseException {
/* Open a transactional Berkeley DB engine environment. */
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setTransactional(true);
env = new Environment(new File(envDir), envConfig);
/* Open a transactional entity store. */
StoreConfig storeConfig = new StoreConfig();
storeConfig.setAllowCreate(true);
storeConfig.setTransactional(true);
store = new EntityStore(env, "SQLAppStore", storeConfig);
/* Initialize the data access object. */
dao = new DataAccessor(store);
/* Preload some example records. */
loadDepartmentDb();
loadEmployeeDb();
}
示例15: reset
import com.sleepycat.je.EnvironmentConfig; //導入依賴的package包/類
/**
* Replaces the existing group with the new group having a single new node
* as described by the constructor arguments.
*
* @see DbResetRepGroup
*/
public void reset() {
Durability durability =
new Durability(Durability.SyncPolicy.SYNC,
Durability.SyncPolicy.SYNC,
Durability.ReplicaAckPolicy.NONE);
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setTransactional(true);
envConfig.setDurability(durability);
ReplicationConfig repConfig =
new ReplicationConfig(groupName, nodeName, nodeHostPort);
repConfig.setHelperHosts(repConfig.getNodeHostPort());
/* Force the re-initialization upon open. */
repConfig.setConfigParam(RepParams.RESET_REP_GROUP.getName(), "true");
/* Open the environment, thus replacing the group. */
ReplicatedEnvironment repEnv =
new ReplicatedEnvironment(envHome, repConfig, envConfig);
repEnv.close();
}