本文整理汇总了Java中com.sleepycat.je.DatabaseConfig类的典型用法代码示例。如果您正苦于以下问题:Java DatabaseConfig类的具体用法?Java DatabaseConfig怎么用?Java DatabaseConfig使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseConfig类属于com.sleepycat.je包,在下文中一共展示了DatabaseConfig类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDb
import com.sleepycat.je.DatabaseConfig; //导入依赖的package包/类
/**
* 根据数据库名取得数据库实例
* @param dbName
* @return
* @throws Exception
*/
private Database getDb(String dbName) throws Exception {
initAndCheck();
Database db = dbMap.get(dbName);
if (db != null) {
return db;
}
synchronized (lock) {
db = dbMap.get(dbName);
if (db != null) {
return db;
}
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setOverrideBtreeComparator(true);
dbConfig.setBtreeComparator(KeyComparator.class);
dbConfig.setAllowCreate(true);
dbConfig.setTransactional(true);
db = env.openDatabase(null, dbName, dbConfig);
dbMap.put(dbName, db);
return db;
}
}
示例2: main
import com.sleepycat.je.DatabaseConfig; //导入依赖的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));
}
示例3: BerkeleyDBIdentifierMap
import com.sleepycat.je.DatabaseConfig; //导入依赖的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");
}
示例4: connection
import com.sleepycat.je.DatabaseConfig; //导入依赖的package包/类
/**
* Returns a new {@link BerkeleyQueue} with given parameters
*/
public BerkeleyQueue<E> connection(String queueName, Class<E> valueClass, int cacheSize) {
DatabaseConfig databaseConfig =
defaultDatabaseConfig()
.setTransactional(false)
.setDeferredWrite(true);
queueDB = berkeleyEnv.connection(queueName, databaseConfig, null);
theCacheSize = cacheSize;
headIdxEntry = queueDB.getEntry(headIdx, getPrimitiveBinding(String.class));
tailIdxEntry = queueDB.getEntry(tailIdx, getPrimitiveBinding(String.class));
Long tmpHeadIndex = queueDB.get(headIdx, headIdxValBinding = getPrimitiveBinding(Long.class));
Long tmpTailIndex = queueDB.get(tailIdx, tailIdxValBinding = getPrimitiveBinding(Long.class));
if (null != tmpHeadIndex && null != tmpTailIndex) {
headIndex = new AtomicLong(tmpHeadIndex);
tailIndex = new AtomicLong(tmpTailIndex);
}
checkNotNull(valueClass, "The queue value class cannot be null.");
queueMap = queueDB.getStoredSortedMap(
getPrimitiveBinding(Long.class), queueDB.getBinding(valueClass), true);
return this;
}
示例5: init
import com.sleepycat.je.DatabaseConfig; //导入依赖的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();
}
}
示例6: init
import com.sleepycat.je.DatabaseConfig; //导入依赖的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();
}
}
示例7: initialize
import com.sleepycat.je.DatabaseConfig; //导入依赖的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);
}
示例8: getDatabase
import com.sleepycat.je.DatabaseConfig; //导入依赖的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;
}
示例9: AbstractFrontier
import com.sleepycat.je.DatabaseConfig; //导入依赖的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: open
import com.sleepycat.je.DatabaseConfig; //导入依赖的package包/类
public void open()
{
try
{
DatabaseConfig dbConfig = storage.getConfiguration().getDatabaseConfig().clone();
dbConfig.setSortedDuplicates(sort_duplicates);
if (keyComparator != null)
{
dbConfig.setBtreeComparator((Comparator<byte[]>) keyComparator);
}
db = storage.getBerkleyEnvironment().openDatabase(null, DB_NAME_PREFIX + name, dbConfig);
}
catch (Throwable t)
{
throw new HGException("While attempting to open index ;" + name + "': " + t.toString(), t);
}
}
示例11: getDatabase
import com.sleepycat.je.DatabaseConfig; //导入依赖的package包/类
private Database getDatabase(String tableName) {
Database db = null;
synchronized (databases) {
db = databases.get(tableName);
if (db == null) {
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(true);
dbConfig.setAllowCreate(true);
// dbConfig.setType(DatabaseType.HASH);
try {
db = env.openDatabase(null, // txn handle
tableName, // db file name
dbConfig);
databases.put(tableName, db);
} catch (DatabaseException e) {
throw new RuntimeException("Cannot create database : " + tableName, e);
}
}
return db;
}
}
示例12: checkFirstRecord
import com.sleepycat.je.DatabaseConfig; //导入依赖的package包/类
/**
* First and only record in db1 should be {3,0}.
*/
private void checkFirstRecord()
throws DatabaseException {
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(false);
dbConfig.setReadOnly(true);
dbConfig.setSortedDuplicates(true);
Database db = env.openDatabase(null, "db1", dbConfig);
Cursor cursor = db.openCursor(null, null);
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
OperationStatus status = cursor.getFirst(key, data, null);
assertEquals(OperationStatus.SUCCESS, status);
assertEquals(3, value(key));
assertEquals(0, value(data));
cursor.close();
db.close();
}
示例13: openDb
import com.sleepycat.je.DatabaseConfig; //导入依赖的package包/类
private void openDb(Comparator comparator)
throws Exception {
File dir = DbTestUtil.getNewDir();
ByteArrayBinding dataBinding = new ByteArrayBinding();
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
DbCompat.setInitializeCache(envConfig, true);
env = new Environment(dir, envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
DbCompat.setTypeBtree(dbConfig);
dbConfig.setAllowCreate(true);
if (comparator != null) {
DbCompat.setBtreeComparator(dbConfig, comparator);
}
store = DbCompat.openDatabase(env, null, "test.db", null, dbConfig);
view = new DataView(store, dataBinding, dataBinding, null, true, null);
}
示例14: open
import com.sleepycat.je.DatabaseConfig; //导入依赖的package包/类
private void open()
throws DatabaseException {
EnvironmentConfig envConfig = TestUtils.initEnvConfig();
envConfig.setAllowCreate(true);
env = new Environment(envHome, envConfig);
DatabaseConfig priConfig = new DatabaseConfig();
priConfig.setAllowCreate(true);
priDb = env.openDatabase(null, "pri", priConfig);
SecondaryConfig secConfig = new SecondaryConfig();
secConfig.setAllowCreate(true);
secConfig.setSortedDuplicates(true);
secConfig.setKeyCreator(new KeyCreator());
secDb = env.openSecondaryDatabase(null, "sec", priDb, secConfig);
}
示例15: getSequence
import com.sleepycat.je.DatabaseConfig; //导入依赖的package包/类
public synchronized Sequence getSequence(String name)
throws DatabaseException {
checkOpen();
if (storeConfig.getReadOnly()) {
throw new IllegalStateException("Store is read-only");
}
Sequence seq = sequenceMap.get(name);
if (seq == null) {
if (sequenceDb == null) {
String dbName = storePrefix + SEQUENCE_DB;
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(storeConfig.getTransactional());
dbConfig.setAllowCreate(true);
sequenceDb = env.openDatabase(null, dbName, dbConfig);
}
DatabaseEntry entry = new DatabaseEntry();
StringBinding.stringToEntry(name, entry);
seq = sequenceDb.openSequence(null, entry, getSequenceConfig(name));
sequenceMap.put(name, seq);
}
return seq;
}