当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseConfig类代码示例

本文整理汇总了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;
       }
}
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:28,代码来源:BerkeleyDb.java

示例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));
}
 
开发者ID:HY-ZhengWei,项目名称:hy.common.berkeley,代码行数:23,代码来源:JU_Berkeley.java

示例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");
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:25,代码来源:BerkeleyDBIdentifierMap.java

示例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;
}
 
开发者ID:jronrun,项目名称:benayn,代码行数:29,代码来源:Berkeley.java

示例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();
  }

}
 
开发者ID:BiosemanticsDotOrg,项目名称:GeneDiseasePaper,代码行数:27,代码来源:IntegerSetStore.java

示例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();
  }

}
 
开发者ID:BiosemanticsDotOrg,项目名称:GeneDiseasePaper,代码行数:27,代码来源:CooccurrenceDatabase.java

示例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);
}
 
开发者ID:BiosemanticsDotOrg,项目名称:GeneDiseasePaper,代码行数:24,代码来源:SleepyCatStoreCache.java

示例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;
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:20,代码来源:JE_Repository.java

示例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);
}
 
开发者ID:classtag,项目名称:scratch_crawler,代码行数:19,代码来源:AbstractFrontier.java

示例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);
	}
}
 
开发者ID:hypergraphdb,项目名称:hypergraphdb,代码行数:20,代码来源:DefaultIndexImpl.java

示例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;
    }
}
 
开发者ID:SyncFree,项目名称:SwiftCloud,代码行数:23,代码来源:DCBerkeleyDBDatabase.java

示例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();
}
 
开发者ID:nologic,项目名称:nabs,代码行数:22,代码来源:SR11297Test.java

示例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);
   }
 
开发者ID:nologic,项目名称:nabs,代码行数:19,代码来源:KeyRangeTest.java

示例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);
}
 
开发者ID:nologic,项目名称:nabs,代码行数:21,代码来源:SecondarySplitTestMain.java

示例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;
}
 
开发者ID:nologic,项目名称:nabs,代码行数:26,代码来源:Store.java


注:本文中的com.sleepycat.je.DatabaseConfig类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。