com.sleepycat.je.DatabaseConfig Java Examples
The following examples show how to use
com.sleepycat.je.DatabaseConfig.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestKDTreeSplit.java From bboxdb with Apache License 2.0 | 6 votes |
public TestKDTreeSplit(final File tmpDir, final List<Pair<String, String>> filesAndFormats, final List<Integer> experimentSize) { this.filesAndFormats = filesAndFormats; this.experimentSize = experimentSize; this.elements = new HashMap<>(); this.elementCounter = new HashMap<>(); this.boxDimension = new HashMap<>(); // Setup database dir tmpDir.mkdirs(); FileUtil.deleteDirOnExit(tmpDir.toPath()); final EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setTransactional(false); envConfig.setAllowCreate(true); envConfig.setSharedCache(true); dbEnv = new Environment(tmpDir, envConfig); dbConfig = new DatabaseConfig(); dbConfig.setTransactional(false); dbConfig.setAllowCreate(true); }
Example #2
Source File: BdbNonPersistentEnvironmentCreator.java From timbuctoo with GNU General Public License v3.0 | 6 votes |
@Override public <KeyT, ValueT> BdbWrapper<KeyT, ValueT> getDatabase(String userId, String dataSetId, String databaseName, boolean allowDuplicates, EntryBinding<KeyT> keyBinder, EntryBinding<ValueT> valueBinder, IsCleanHandler<KeyT, ValueT> isCleanHandler) throws BdbDbCreationException { try { DatabaseConfig config = new DatabaseConfig(); config.setAllowCreate(true); config.setDeferredWrite(true); config.setSortedDuplicates(allowDuplicates); String environmentKey = environmentKey(userId, dataSetId); File envHome = new File(dbHome, environmentKey); envHome.mkdirs(); Environment dataSetEnvironment = new Environment(envHome, configuration); Database database = dataSetEnvironment.openDatabase(null, databaseName, config); databases.put(environmentKey + "_" + databaseName, database); environmentMap.put(environmentKey, dataSetEnvironment); return new BdbWrapper<>(dataSetEnvironment, database, config, keyBinder, valueBinder, isCleanHandler); } catch (DatabaseException e) { throw new BdbDbCreationException(e); } }
Example #3
Source File: BerkeleyKeyValueStore.java From BIMserver with GNU Affero General Public License v3.0 | 6 votes |
public void openIndexTable(DatabaseSession databaseSession, String tableName, boolean transactional) throws BimserverDatabaseException { if (tables.containsKey(tableName)) { throw new BimserverDatabaseException("Table " + tableName + " already opened"); } DatabaseConfig databaseConfig = new DatabaseConfig(); databaseConfig.setKeyPrefixing(keyPrefixing); databaseConfig.setAllowCreate(false); boolean finalTransactional = transactional && useTransactions; // if (!transactional) { // databaseConfig.setCacheMode(CacheMode.EVICT_BIN); // } databaseConfig.setDeferredWrite(!finalTransactional); databaseConfig.setTransactional(finalTransactional); databaseConfig.setSortedDuplicates(true); Database database = environment.openDatabase(null, tableName, databaseConfig); if (database == null) { throw new BimserverDatabaseException("Table " + tableName + " not found in database"); } tables.put(tableName, new TableWrapper(database, finalTransactional)); }
Example #4
Source File: BerkeleyKeyValueStore.java From BIMserver with GNU Affero General Public License v3.0 | 6 votes |
public boolean openTable(DatabaseSession databaseSession, String tableName, boolean transactional) throws BimserverDatabaseException { if (tables.containsKey(tableName)) { throw new BimserverDatabaseException("Table " + tableName + " already opened"); } DatabaseConfig databaseConfig = new DatabaseConfig(); databaseConfig.setKeyPrefixing(keyPrefixing); databaseConfig.setAllowCreate(false); boolean finalTransactional = transactional && useTransactions; // if (!transactional) { // databaseConfig.setCacheMode(CacheMode.EVICT_BIN); // } databaseConfig.setDeferredWrite(!finalTransactional); databaseConfig.setTransactional(finalTransactional); databaseConfig.setSortedDuplicates(false); Database database = environment.openDatabase(null, tableName, databaseConfig); if (database == null) { throw new BimserverDatabaseException("Table " + tableName + " not found in database"); } tables.put(tableName, new TableWrapper(database, finalTransactional)); return true; }
Example #5
Source File: BerkeleyKeyValueStore.java From BIMserver with GNU Affero General Public License v3.0 | 6 votes |
public boolean createIndexTable(String tableName, DatabaseSession databaseSession, boolean transactional) throws BimserverDatabaseException { if (tables.containsKey(tableName)) { throw new BimserverDatabaseException("Table " + tableName + " already created"); } DatabaseConfig databaseConfig = new DatabaseConfig(); databaseConfig.setKeyPrefixing(keyPrefixing); databaseConfig.setAllowCreate(true); boolean finalTransactional = transactional && useTransactions; // if (!transactional) { // databaseConfig.setCacheMode(CacheMode.EVICT_BIN); // } databaseConfig.setDeferredWrite(!finalTransactional); databaseConfig.setTransactional(finalTransactional); databaseConfig.setSortedDuplicates(true); Database database = environment.openDatabase(null, tableName, databaseConfig); if (database == null) { return false; } tables.put(tableName, new TableWrapper(database, finalTransactional)); return true; }
Example #6
Source File: BerkeleyKeyValueStore.java From BIMserver with GNU Affero General Public License v3.0 | 6 votes |
public boolean createTable(String tableName, DatabaseSession databaseSession, boolean transactional) throws BimserverDatabaseException { if (tables.containsKey(tableName)) { throw new BimserverDatabaseException("Table " + tableName + " already created"); } DatabaseConfig databaseConfig = new DatabaseConfig(); databaseConfig.setKeyPrefixing(keyPrefixing); databaseConfig.setAllowCreate(true); boolean finalTransactional = transactional && useTransactions; databaseConfig.setDeferredWrite(!finalTransactional); // if (!transactional) { // databaseConfig.setCacheMode(CacheMode.EVICT_BIN); // } databaseConfig.setTransactional(finalTransactional); databaseConfig.setSortedDuplicates(false); Database database = environment.openDatabase(null, tableName, databaseConfig); if (database == null) { return false; } tables.put(tableName, new TableWrapper(database, finalTransactional)); return true; }
Example #7
Source File: ClassCatalog.java From Rel with Apache License 2.0 | 6 votes |
ClassCatalog(String directory, EnvironmentConfig environmentConfig, DatabaseConfig dbConfig) { // This should be main database directory dirClassLoader = new DirClassLoader(directory); // Open the environment in subdirectory of the above String classesDir = directory + java.io.File.separator + "classes"; RelDatabase.mkdir(classesDir); environment = new Environment(new File(classesDir), environmentConfig); // Open the class catalog db. This is used to optimize class serialization. classCatalogDb = environment.openDatabase(null, "_ClassCatalog", dbConfig); // Create our class catalog classCatalog = new StoredClassCatalog(classCatalogDb); // Need a serial binding for metadata relvarMetadataBinding = new SerialBinding<RelvarMetadata>(classCatalog, RelvarMetadata.class); // Need serial binding for data tupleBinding = new SerialBinding<ValueTuple>(classCatalog, ValueTuple.class) { public ClassLoader getClassLoader() { return dirClassLoader; } }; }
Example #8
Source File: DefaultIndexImpl.java From hypergraphdb with Apache License 2.0 | 6 votes |
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); } }
Example #9
Source File: AbstractFrontier.java From codes-scratch-crawler with Apache License 2.0 | 6 votes |
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); }
Example #10
Source File: JE_Repository.java From tddl5 with Apache License 2.0 | 6 votes |
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; }
Example #11
Source File: FileLineIndex.java From bboxdb with Apache License 2.0 | 6 votes |
/** * Open the Berkeley DB * @throws IOException */ protected void openDatabase() throws IOException { final EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setTransactional(false); envConfig.setAllowCreate(true); envConfig.setSharedCache(true); tmpDatabaseDir = Files.createTempDirectory(null); dbEnv = new Environment(tmpDatabaseDir.toFile(), envConfig); logger.info("Database dir is {}", tmpDatabaseDir); // Delete database on exit FileUtil.deleteDirOnExit(tmpDatabaseDir); final DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setTransactional(false); dbConfig.setAllowCreate(true); dbConfig.setDeferredWrite(true); database = dbEnv.openDatabase(null, "lines", dbConfig); }
Example #12
Source File: BDBLinkStore.java From qpid-broker-j with Apache License 2.0 | 6 votes |
private Database getLinksVersionDb() { Database linksVersionDb; try { DatabaseConfig config = new DatabaseConfig().setTransactional(true).setAllowCreate(false); linksVersionDb = getEnvironmentFacade().openDatabase(LINKS_VERSION_DB_NAME, config); } catch (DatabaseNotFoundException e) { updateVersion(null, BrokerModel.MODEL_VERSION); linksVersionDb = getEnvironmentFacade().openDatabase(LINKS_VERSION_DB_NAME, DEFAULT_DATABASE_CONFIG); } return linksVersionDb; }
Example #13
Source File: BerkeleyDBHandle.java From SPADE with GNU General Public License v3.0 | 6 votes |
@Override public void clear() throws Exception{ if(environmentHandle == null){ throw new Exception("NULL enviroment handle"); }else{ Environment environment = environmentHandle.getEnvironment(); if(environment == null){ throw new Exception("NULL enviroment"); }else{ database.close(); environment.removeDatabase(null, dbName); DatabaseConfig databaseConfig = new DatabaseConfig(); databaseConfig.setAllowCreate(true).setExclusiveCreate(true); database = environment.openDatabase(null, dbName, databaseConfig); } } }
Example #14
Source File: StandardEnvironmentFacadeTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testOpenDatabaseReusesCachedHandle() throws Exception { DatabaseConfig createIfAbsentDbConfig = DatabaseConfig.DEFAULT.setAllowCreate(true); EnvironmentFacade ef = createEnvironmentFacade(); Database handle1 = ef.openDatabase("myDatabase", createIfAbsentDbConfig); assertNotNull(handle1); Database handle2 = ef.openDatabase("myDatabase", createIfAbsentDbConfig); assertSame("Database handle should be cached", handle1, handle2); ef.closeDatabase("myDatabase"); Database handle3 = ef.openDatabase("myDatabase", createIfAbsentDbConfig); assertNotSame("Expecting a new handle after database closure", handle1, handle3); }
Example #15
Source File: UpgraderTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
private int getStoreVersion(Environment environment) { DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setTransactional(true); dbConfig.setAllowCreate(true); int storeVersion = -1; try(Database versionDb = environment.openDatabase(null, Upgrader.VERSION_DB_NAME, dbConfig); Cursor cursor = versionDb.openCursor(null, null)) { DatabaseEntry key = new DatabaseEntry(); DatabaseEntry value = new DatabaseEntry(); while (cursor.getNext(key, value, null) == OperationStatus.SUCCESS) { int version = IntegerBinding.entryToInt(key); if (storeVersion < version) { storeVersion = version; } } } return storeVersion; }
Example #16
Source File: UpgraderFailOnNewerVersionTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
private int getStoreVersion() { DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setTransactional(true); dbConfig.setAllowCreate(true); int storeVersion = -1; try(Database versionDb = _environment.openDatabase(null, Upgrader.VERSION_DB_NAME, dbConfig); Cursor cursor = versionDb.openCursor(null, null)) { DatabaseEntry key = new DatabaseEntry(); DatabaseEntry value = new DatabaseEntry(); while (cursor.getNext(key, value, null) == OperationStatus.SUCCESS) { int version = IntegerBinding.entryToInt(key); if (storeVersion < version) { storeVersion = version; } } } return storeVersion; }
Example #17
Source File: DatabaseTemplateTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testExecuteWithTwoDatabases() { String targetDatabaseName = "targetDatabase"; Database targetDatabase = mock(Database.class); Transaction txn = mock(Transaction.class); when(_environment.openDatabase(same(txn), same(targetDatabaseName), isA(DatabaseConfig.class))) .thenReturn(targetDatabase); DatabaseTemplate databaseTemplate = new DatabaseTemplate(_environment, SOURCE_DATABASE, targetDatabaseName, txn); DatabaseRunnable databaseOperation = mock(DatabaseRunnable.class); databaseTemplate.run(databaseOperation); verify(databaseOperation).run(_sourceDatabase, targetDatabase, txn); verify(_sourceDatabase).close(); verify(targetDatabase).close(); }
Example #18
Source File: ReplicatedEnvironmentFacadeTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testReplicaWriteExceptionIsConvertedIntoConnectionScopedRuntimeException() throws Exception { ReplicatedEnvironmentFacade master = createMaster(); String nodeName2 = TEST_NODE_NAME + "_2"; String host = "localhost"; int port = _portHelper.getNextAvailable(); String node2NodeHostPort = host + ":" + port; final ReplicatedEnvironmentFacade replica = createReplica(nodeName2, node2NodeHostPort, new NoopReplicationGroupListener() ); // close the master master.close(); try { replica.openDatabase("test", DatabaseConfig.DEFAULT.setAllowCreate(true) ); fail("Replica write operation should fail"); } catch(ReplicaWriteException e) { RuntimeException handledException = master.handleDatabaseException("test", e); final boolean condition = handledException instanceof ConnectionScopedRuntimeException; assertTrue("Unexpected exception", condition); } }
Example #19
Source File: ReplicatedEnvironmentFacadeTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testOpenDatabaseWhenFacadeIsNotOpened() throws Exception { DatabaseConfig createIfAbsentDbConfig = DatabaseConfig.DEFAULT.setAllowCreate(true); EnvironmentFacade ef = createMaster(); ef.close(); try { ef.openDatabase("myDatabase", createIfAbsentDbConfig ); fail("Database open should fail"); } catch(ConnectionScopedRuntimeException e) { assertEquals("Unexpected exception", "Environment facade is not in opened state", e.getMessage()); } }
Example #20
Source File: ReplicatedEnvironmentFacadeTest.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Test public void testOpenDatabaseReusesCachedHandle() throws Exception { DatabaseConfig createIfAbsentDbConfig = DatabaseConfig.DEFAULT.setAllowCreate(true); EnvironmentFacade ef = createMaster(); Database handle1 = ef.openDatabase("myDatabase", createIfAbsentDbConfig); assertNotNull(handle1); Database handle2 = ef.openDatabase("myDatabase", createIfAbsentDbConfig); assertSame("Database handle should be cached", handle1, handle2); ef.closeDatabase("myDatabase"); Database handle3 = ef.openDatabase("myDatabase", createIfAbsentDbConfig); assertNotSame("Expecting a new handle after database closure", handle1, handle3); }
Example #21
Source File: DatabaseTemplate.java From qpid-broker-j with Apache License 2.0 | 6 votes |
public <T> T call(DatabaseCallable<T> databaseCallable) { Database sourceDatabase = null; Database targetDatabase = null; try { DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setTransactional(true); dbConfig.setAllowCreate(true); sourceDatabase = _environment.openDatabase(_parentTransaction, _sourceDatabaseName, dbConfig); if (_targetDatabaseName != null) { targetDatabase = _environment.openDatabase(_parentTransaction, _targetDatabaseName, dbConfig); } return databaseCallable.call(sourceDatabase, targetDatabase, _parentTransaction); } finally { closeDatabase(sourceDatabase); closeDatabase(targetDatabase); } }
Example #22
Source File: StandardEnvironmentFacade.java From qpid-broker-j with Apache License 2.0 | 6 votes |
@Override public Database openDatabase(String name, DatabaseConfig databaseConfig) { Database cachedHandle = _cachedDatabases.get(name); if (cachedHandle == null) { Database handle = getEnvironment().openDatabase(null, name, databaseConfig); Database existingHandle = _cachedDatabases.putIfAbsent(name, handle); if (existingHandle == null) { cachedHandle = handle; } else { cachedHandle = existingHandle; handle.close(); } } return cachedHandle; }
Example #23
Source File: OrphanConfigurationRecordPurger.java From qpid-broker-j with Apache License 2.0 | 6 votes |
private int getVersion(final Environment env, final DatabaseConfig dbConfig) { try (Database versionDb = env.openDatabase(null, VERSION_DB_NAME, dbConfig); Cursor cursor = versionDb.openCursor(null, null)) { DatabaseEntry key = new DatabaseEntry(); DatabaseEntry value = new DatabaseEntry(); int version = 0; while (cursor.getNext(key, value, null) == OperationStatus.SUCCESS) { int ver = IntegerBinding.entryToInt(key); if (ver > version) { version = ver; } } return version; } }
Example #24
Source File: DatabaseTemplateTest.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { _environment = mock(Environment.class); _sourceDatabase = mock(Database.class); when(_environment.openDatabase(any(Transaction.class), same(SOURCE_DATABASE), isA(DatabaseConfig.class))) .thenReturn(_sourceDatabase); when(_environment.openDatabase(isNull(), same(SOURCE_DATABASE), isA(DatabaseConfig.class))) .thenReturn(_sourceDatabase); }
Example #25
Source File: BdbWrapper.java From timbuctoo with GNU General Public License v3.0 | 5 votes |
public BdbWrapper(Environment dbEnvironment, Database database, DatabaseConfig databaseConfig, EntryBinding<KeyT> keyBinder, EntryBinding<ValueT> valueBinder, IsCleanHandler<KeyT, ValueT> isCleanHandler) { this.dbEnvironment = dbEnvironment; this.database = database; this.databaseConfig = databaseConfig; this.keyBinder = keyBinder; this.valueBinder = valueBinder; this.isCleanHandler = isCleanHandler; }
Example #26
Source File: PQ.java From multimedia-indexing with Apache License 2.0 | 5 votes |
/** * Advanced constructor. * * @param vectorLength * The dimensionality of the VLAD vectors being indexed * @param maxNumVectors * The maximum allowable size (number of vectors) of the index * @param readOnly * If true the persistent store will opened only for read access (allows multiple opens) * @param BDBEnvHome * The BDB environment home directory * @param numSubVectors * The number of subvectors * @param numProductCentroids * The number of centroids used to quantize each sub-vector * @param transformation * The type of transformation to perform on each vector * @param countSizeOnLoad * Whether the load counter will be initialized by the size of the persistent store * @param loadCounter * The initial value of the load counter * @param loadIndexInMemory * Whether to load the index in memory, we can avoid loading the index in memory when we only * want to perform indexing * @throws Exception */ public PQ(int vectorLength, int maxNumVectors, boolean readOnly, String BDBEnvHome, int numSubVectors, int numProductCentroids, TransformationType transformation, boolean countSizeOnLoad, int loadCounter, boolean loadIndexInMemory, long cacheSize) throws Exception { super(vectorLength, maxNumVectors, readOnly, countSizeOnLoad, loadCounter, loadIndexInMemory, cacheSize); this.numSubVectors = numSubVectors; if (vectorLength % numSubVectors > 0) { throw new Exception("The given number of subvectors is not valid!"); } this.subVectorLength = vectorLength / numSubVectors; this.numProductCentroids = numProductCentroids; this.transformation = transformation; if (transformation == TransformationType.RandomRotation) { this.rr = new RandomRotation(seed, vectorLength); } else if (transformation == TransformationType.RandomPermutation) { this.rp = new RandomPermutation(seed, vectorLength); } createOrOpenBDBEnvAndDbs(BDBEnvHome); // configuration of the persistent index DatabaseConfig dbConf = new DatabaseConfig(); dbConf.setReadOnly(readOnly); dbConf.setTransactional(transactional); dbConf.setAllowCreate(true); // db will be created if it does not exist iidToPqDB = dbEnv.openDatabase(null, "adc", dbConf); // create/open the db using config if (loadIndexInMemory) { // initialize the in-memory data structures and load any existing persistent index in memory loadIndexInMemory(); } }
Example #27
Source File: AbstractSearchStructure.java From multimedia-indexing with Apache License 2.0 | 5 votes |
/** * This method creates and/or opens the BDB databases with the appropriate parameters. * * @throws Exception */ private void createOrOpenBDBDbs() throws Exception { // configuration for the mapping dbs DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setAllowCreate(true); // db will be created if it does not exist dbConfig.setReadOnly(readOnly); dbConfig.setTransactional(transactional); // create/open mapping dbs using config iidToIdDB = dbEnv.openDatabase(null, "idToName", dbConfig); // if countSizeOnLoad is true, the id-name mappings are counted and the loadCounter is initialized if (countSizeOnLoad) { System.out.println(new Date() + " counting index size started "); int idToNameMappings = (int) iidToIdDB.count(); loadCounter = Math.min(idToNameMappings, maxNumVectors); System.out.println(new Date() + " counting index size ended "); System.out.println("Index size: " + loadCounter); } idToIidDB = dbEnv.openDatabase(null, "nameToId", dbConfig); if (useGeolocation) {// create/open geolocation db using config iidToGeolocationDB = dbEnv.openDatabase(null, "idToGeolocation", dbConfig); } if (useMetaData) { StoreConfig storeConfig = new StoreConfig(); // configuration of the entity store storeConfig.setAllowCreate(true); // store will be created if it does not exist storeConfig.setReadOnly(readOnly); storeConfig.setTransactional(transactional); iidToMetadataDB = new EntityStore(dbEnv, "idToMetadata", storeConfig); // int nameToMetadataMappings = (int) nameToMetadataBDB.getPrimaryIndex(String.class, // MediaFeedData.class).count(); // counting the size of an EntityStore } }
Example #28
Source File: UpgradeFrom6To7.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Override public void performUpgrade(Environment environment, UpgradeInteractionHandler handler, ConfiguredObject<?> parent) { reportStarting(environment, 6); DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setTransactional(true); dbConfig.setAllowCreate(true); Database versionDb = environment.openDatabase(null, "CONFIG_VERSION", dbConfig); if(versionDb.count() == 0L) { DatabaseEntry key = new DatabaseEntry(); DatabaseEntry value = new DatabaseEntry(); IntegerBinding.intToEntry(DEFAULT_CONFIG_VERSION, value); ByteBinding.byteToEntry((byte) 0, key); OperationStatus status = versionDb.put(null, key, value); if (status != OperationStatus.SUCCESS) { throw new StoreException("Error initialising config version: " + status); } } versionDb.close(); reportFinished(environment, 7); }
Example #29
Source File: StandardEnvironmentFacade.java From qpid-broker-j with Apache License 2.0 | 5 votes |
@Override public Database clearDatabase(Transaction txn, String databaseName, DatabaseConfig databaseConfig) { closeDatabase(databaseName); getEnvironment().removeDatabase(txn, databaseName); return getEnvironment().openDatabase(txn, databaseName, databaseConfig); }
Example #30
Source File: BerkeleyDBStore.java From hypergraphdb with Apache License 2.0 | 5 votes |
@Override public void init(HazelcastInstance hazelcastInstance, Properties properties, String mapName) { _hazelcastInstance = hazelcastInstance; _properties = properties; _mapName = mapName; DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setAllowCreate(true); dbConfig.setDeferredWrite(true); //延迟写 dbConfig.setSortedDuplicates(false); dbConfig.setTransactional(false); _db = _env.openDatabase(null, _mapName, dbConfig); _dbMap.put(_mapName, _db); if (_scheduleSync == null) { try { _syncinterval = Integer.parseInt(_properties.getProperty("syncinterval")); } catch (Exception e) { _syncinterval = 3; _logger.log(Level.WARNING, e.getMessage(), e); } if (_syncinterval > 0) { _scheduleSync = Executors.newSingleThreadScheduledExecutor(); //同步磁盘的Scheduled _scheduleSync.scheduleWithFixedDelay(this, 1, _syncinterval, TimeUnit.SECONDS); } } _logger.log(Level.INFO, this.getClass().getCanonicalName() + ":" + _mapName + ":count:" + _db.count()); _logger.log(Level.INFO, this.getClass().getCanonicalName() + ":" + _mapName + ":初始化完成!"); //预先把数据加载进Hazelcast集群中 IMap map = _hazelcastInstance.getMap(mapName); Set<K> keySet = privateLoadAllKeys(); for (K key : keySet) { map.putTransient(key, load(key), 0, TimeUnit.SECONDS); } _logger.log(Level.INFO, this.getClass().getCanonicalName() + ":" + _mapName + ":预先加载数据完成!"); }