@Override void configure(TransactionConfig cfg) { cfg.setSerializableIsolation(true); } };
private void closeOpenIterators() throws BackendException { for (Cursor cursor : openCursors) { cursor.close(); } }
@Override void configure(TransactionConfig cfg) { cfg.setReadUncommitted(true); } }, READ_COMMITTED {
protected Database openDatabase(final Environment environment, final String dbName) throws DatabaseException { DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setTransactional(false); dbConfig.setAllowCreate(true); dbConfig.setDeferredWrite(true); return environment.openDatabase(null, dbName, dbConfig); }
private void initialize(int cachePercent) throws BackendException { try { EnvironmentConfig envConfig = new EnvironmentConfig(); envConfig.setAllowCreate(true); envConfig.setTransactional(transactional); envConfig.setCachePercent(cachePercent); if (batchLoading) { envConfig.setConfigParam(EnvironmentConfig.ENV_RUN_CHECKPOINTER, "false"); envConfig.setConfigParam(EnvironmentConfig.ENV_RUN_CLEANER, "false"); } //Open the environment environment = new Environment(directory, envConfig); } catch (DatabaseException e) { throw new PermanentBackendException("Error during BerkeleyJE initialization: ", e); } }
/** * @return the key to the first item in the database * @throws DatabaseException */ protected DatabaseEntry getFirstKey() throws DatabaseException { DatabaseEntry key = new DatabaseEntry(); DatabaseEntry value = new DatabaseEntry(); Cursor cursor = pendingUrisDB.openCursor(null,null); OperationStatus status = cursor.getNext(key,value,null); cursor.close(); if(status == OperationStatus.SUCCESS) { return key; } return null; }
public void close() { urlsDB.close(); } }
protected Cursor openCursor(Transaction txn) { return urlsDB.openCursor(txn, null); }
protected static void commit(Transaction tnx) { if (tnx != null) { tnx.commit(); } }
protected Transaction beginTransaction() { return resumable ? env.beginTransaction(null, null) : null; }
private EnvironmentStats getEnvironmentStats(boolean fast) { StatsConfig config = new StatsConfig(); config.setFast(fast); return environment.getStats(config); }
public long getLength() { return urlsDB.count(); }
public DatabaseStats getBtreeStatsUncached() throws Exception { // fast stats does not provide detailed Btree structure. // This is invasive and will affect performance. return database.getStats(new StatsConfig().setFast(false)); }
public BdbNativeBackup(Environment env, boolean verifyFiles, boolean isIncremental) { this.env = env; this.verifyFiles = verifyFiles; this.isIncremental = isIncremental; this.databaseDir = env.getHome(); }
@Override void configure(TransactionConfig cfg) { cfg.setReadCommitted(true); } }, REPEATABLE_READ {
protected Database openDatabase(final Environment environment, final String dbName) throws DatabaseException { DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setTransactional(false); dbConfig.setAllowCreate(true); dbConfig.setDeferredWrite(true); return environment.openDatabase(null, dbName, dbConfig); }
private EnvironmentStats getStats(Environment environment) { StatsConfig config = new StatsConfig(); config.setFast(true); return environment.getStats(config); }
public WorkQueues(Environment env, String dbName, boolean resumable) { this.env = env; this.resumable = resumable; DatabaseConfig dbConfig = new DatabaseConfig(); dbConfig.setAllowCreate(true); dbConfig.setTransactional(resumable); dbConfig.setDeferredWrite(!resumable); urlsDB = env.openDatabase(null, dbName, dbConfig); webURLBinding = new WebURLTupleBinding(); }