本文整理匯總了Java中com.sleepycat.je.Environment類的典型用法代碼示例。如果您正苦於以下問題:Java Environment類的具體用法?Java Environment怎麽用?Java Environment使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Environment類屬於com.sleepycat.je包,在下文中一共展示了Environment類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: open
import com.sleepycat.je.Environment; //導入依賴的package包/類
/**
* 打開數據庫環境及數據庫本身
*
* 寫在open()之後的方法,都必須調用open()方法之後才能正常使用
*/
public void open()
{
try
{
this.environment = new Environment(new File(this.environmentHome) ,this.environmentConfig);
this.database = this.environment.openDatabase(null ,this.databaseName ,this.databaseConfig);
this.classBerkeley = new ClassBerkeley(this ,this.databaseName + "_ClassCatalog");
}
catch (Exception exce)
{
exce.printStackTrace();
}
}
示例2: BerkeleyDBIdentifierMap
import com.sleepycat.je.Environment; //導入依賴的package包/類
public BerkeleyDBIdentifierMap(final Environment dbEnvironment, final FudgeContext fudgeContext) {
ArgumentChecker.notNull(dbEnvironment, "dbEnvironment");
ArgumentChecker.notNull(fudgeContext, "fudgeContext");
_fudgeContext = fudgeContext;
_valueSpecificationToIdentifier = new AbstractBerkeleyDBComponent(dbEnvironment, VALUE_SPECIFICATION_TO_IDENTIFIER_DATABASE) {
@Override
protected DatabaseConfig getDatabaseConfig() {
return BerkeleyDBIdentifierMap.this.getDatabaseConfig();
}
};
_identifierToValueSpecification = new AbstractBerkeleyDBComponent(dbEnvironment, IDENTIFIER_TO_VALUE_SPECIFICATION_DATABASE) {
@Override
protected DatabaseConfig getDatabaseConfig() {
return BerkeleyDBIdentifierMap.this.getDatabaseConfig();
}
@Override
protected void postStartInitialization() {
_nextIdentifier.set(_identifierToValueSpecification.getDatabase().count() + 1);
}
};
_newIdentifierMeter = OpenGammaMetricRegistry.getDetailedInstance().meter("BerkeleyDBIdentifierMap.newIdentifier");
_getIdentifierTimer = OpenGammaMetricRegistry.getDetailedInstance().timer("BerkeleyDBIdentifierMap.getIdentifier");
}
示例3: UpdateGroundhogScript
import com.sleepycat.je.Environment; //導入依賴的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();
}
示例4: init
import com.sleepycat.je.Environment; //導入依賴的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();
}
}
示例5: init
import com.sleepycat.je.Environment; //導入依賴的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();
}
}
示例6: initialize
import com.sleepycat.je.Environment; //導入依賴的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);
}
示例7: getDatabase
import com.sleepycat.je.Environment; //導入依賴的package包/類
public Database getDatabase(String name, boolean isTmp, boolean isSortedDuplicates) {
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
Environment _env = env;
if (isTmp) {
dbConfig.setTemporary(true);
dbConfig.setSortedDuplicates(isSortedDuplicates);
_env = getTmpEnv();
} else {
if (!config.isTransactional()) {
dbConfig.setDeferredWrite(config.isCommitSync());
} else {
dbConfig.setTransactional(true);
}
}
Database database = buildPrimaryIndex(dbConfig, _env, name);
return database;
}
示例8: init
import com.sleepycat.je.Environment; //導入依賴的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();
}
示例9: WebGraph
import com.sleepycat.je.Environment; //導入依賴的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");
}
示例10: AbstractFrontier
import com.sleepycat.je.Environment; //導入依賴的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);
}
示例11: createEnv
import com.sleepycat.je.Environment; //導入依賴的package包/類
private Environment createEnv(boolean readOnly, File envDir)
throws DatabaseException {
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
DbInternal.disableParameterValidation(envConfig);
envConfig.setAllowCreate(true);
envConfig.setReadOnly(readOnly);
envConfig.setConfigParam(EnvironmentParams.LOG_FILE_MAX.getName(),
"400");
envConfig.setConfigParam(EnvironmentParams.ENV_RUN_CLEANER.getName(),
"false");
Environment env = new Environment(envDir, envConfig);
return env;
}
示例12: setup
import com.sleepycat.je.Environment; //導入依賴的package包/類
public void setup(File envHome, boolean readOnly)
throws DatabaseException {
EnvironmentConfig myEnvConfig = new EnvironmentConfig();
StoreConfig storeConfig = new StoreConfig();
myEnvConfig.setReadOnly(readOnly);
storeConfig.setReadOnly(readOnly);
// If the environment is opened for write, then we want to be
// able to create the environment and entity store if
// they do not exist.
myEnvConfig.setAllowCreate(!readOnly);
storeConfig.setAllowCreate(!readOnly);
// Allow transactions if we are writing to the store.
myEnvConfig.setTransactional(!readOnly);
storeConfig.setTransactional(!readOnly);
// Open the environment and entity store
myEnv = new Environment(envHome, myEnvConfig);
store = new EntityStore(myEnv, "EntityStore", storeConfig);
}
示例13: open
import com.sleepycat.je.Environment; //導入依賴的package包/類
/**
* ???
*/
public void open() {
if (!isClosed()) {
NeoLogger.warn("This backend is already open");
}
try {
environment = new Environment(file, environmentConfig);
this.containers = environment.openDatabase(null, KEY_CONTAINER, databaseConfig);
this.instances = environment.openDatabase(null, KEY_INSTANCE_OF, databaseConfig);
this.features = environment.openDatabase(null, KEY_FEATURES, databaseConfig);
this.multivaluedFeatures = environment.openDatabase(null, KEY_MULTIVALUED_FEATURES, databaseConfig);
isClosed = false;
}
catch (DatabaseException e) {
NeoLogger.error(e);
}
}
示例14: setUp
import com.sleepycat.je.Environment; //導入依賴的package包/類
public void setUp()
throws IOException, DatabaseException {
TestUtils.removeFiles("Setup", envHome, FileManager.JE_SUFFIX);
/*
* Run environment without in compressor on so we can check the
* compressor queue in a deterministic way.
*/
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setTransactional(true);
envConfig.setConfigParam(EnvironmentParams.NODE_MAX.getName(), "6");
envConfig.setConfigParam(EnvironmentParams.
ENV_RUN_INCOMPRESSOR.getName(),
"false");
envConfig.setAllowCreate(true);
env = new Environment(envHome, envConfig);
}
示例15: renameDatabase
import com.sleepycat.je.Environment; //導入依賴的package包/類
/**
* Returns false if the database is not found.
*/
public static boolean renameDatabase(Environment env,
Transaction txn,
String oldFileName,
String oldDbName,
String newFileName,
String newDbName) {
assert oldFileName == null;
assert newFileName == null;
try {
env.renameDatabase(txn, oldDbName, newDbName);
return true;
} catch (DatabaseNotFoundException e) {
return false;
}
}