| | |
| | | import com.sleepycat.je.EnvironmentConfig; |
| | | import com.sleepycat.je.OperationStatus; |
| | | import com.sleepycat.je.Transaction; |
| | | import com.sleepycat.je.TransactionConfig; |
| | | |
| | | /** Berkeley DB Java Edition (JE for short) database implementation of the {@link Storage} engine. */ |
| | | public final class JEStorage implements Storage, Backupable, ConfigurationChangeListener<JEBackendCfg>, |
| | |
| | | } |
| | | |
| | | @Override |
| | | public void delete() throws NoSuchElementException, UnsupportedOperationException |
| | | { |
| | | throwIfNotSuccess(); |
| | | try |
| | | { |
| | | cursor.delete(); |
| | | } |
| | | catch (DatabaseException e) |
| | | { |
| | | throw new StorageRuntimeException(e); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean positionToKey(final ByteSequence key) |
| | | { |
| | | clearCurrentKeyAndValue(); |
| | |
| | | } |
| | | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | /** Use read committed isolation instead of the default which is repeatable read. */ |
| | | private static final TransactionConfig TXN_READ_COMMITTED = new TransactionConfig().setReadCommitted(true); |
| | | |
| | | private final ServerContext serverContext; |
| | | private final File backendDirectory; |
| | | private JEBackendCfg config; |
| | |
| | | tree = trees.get(treeName); |
| | | if (tree == null) |
| | | { |
| | | tree = env.openDatabase(txn, toDatabaseName(treeName), dbConfig()); |
| | | tree = env.openDatabase(null, toDatabaseName(treeName), dbConfig()); |
| | | trees.put(treeName, tree); |
| | | } |
| | | } |
| | |
| | | { |
| | | if (envConfig.getTransactional()) |
| | | { |
| | | final Transaction txn = env.beginTransaction(null, null); |
| | | final Transaction txn = env.beginTransaction(null, TXN_READ_COMMITTED); |
| | | logger.trace("beginTransaction txnid=%d", txn.getId()); |
| | | return txn; |
| | | } |