use of com.sleepycat.je.TransactionConfig in project qpid-broker-j by apache.
the class ReplicatedEnvironmentFacadeTest method putRecord.
private void putRecord(final ReplicatedEnvironmentFacade master, final Database db, final int keyValue, final String dataValue) {
DatabaseEntry key = new DatabaseEntry();
DatabaseEntry data = new DatabaseEntry();
TransactionConfig transactionConfig = new TransactionConfig();
transactionConfig.setDurability(master.getRealMessageStoreDurability());
Transaction txn = master.beginTransaction(transactionConfig);
IntegerBinding.intToEntry(keyValue, key);
StringBinding.stringToEntry(dataValue, data);
db.put(txn, key, data);
txn.commit();
}
use of com.sleepycat.je.TransactionConfig in project GeoGig by boundlessgeo.
the class JEObjectDatabase method newTransaction.
@Nullable
private Transaction newTransaction() {
final boolean transactional = objectDb.getConfig().getTransactional();
if (transactional) {
TransactionConfig txConfig = new TransactionConfig();
txConfig.setReadUncommitted(true);
Optional<String> durability = configDB.get(OBJECT_DURABILITY_CONFIG_KEY);
if (!durability.isPresent()) {
durability = configDB.getGlobal(OBJECT_DURABILITY_CONFIG_KEY);
}
if ("safe".equals(durability.orNull())) {
txConfig.setDurability(Durability.COMMIT_SYNC);
} else {
txConfig.setDurability(Durability.COMMIT_WRITE_NO_SYNC);
}
Transaction transaction = env.beginTransaction(null, txConfig);
return transaction;
}
return null;
}
use of com.sleepycat.je.TransactionConfig in project qpid-broker-j by apache.
the class ReplicatedEnvironmentFacadeTest method testBeginTransaction.
@Test
public void testBeginTransaction() throws Exception {
ReplicatedEnvironmentFacade facade = createMaster();
Transaction txn = null;
try {
TransactionConfig transactionConfig = new TransactionConfig();
transactionConfig.setDurability(facade.getRealMessageStoreDurability());
txn = facade.beginTransaction(transactionConfig);
assertNotNull("Transaction is not created", txn);
txn.commit();
txn = null;
} finally {
if (txn != null) {
txn.abort();
}
}
}
use of com.sleepycat.je.TransactionConfig in project janusgraph by JanusGraph.
the class BerkeleyJEStoreManager method beginTransaction.
@Override
public BerkeleyJETx beginTransaction(final BaseTransactionConfig txCfg) throws BackendException {
try {
Transaction tx = null;
Configuration effectiveCfg = new MergedConfiguration(txCfg.getCustomOptions(), getStorageConfig());
if (transactional) {
TransactionConfig txnConfig = new TransactionConfig();
ConfigOption.getEnumValue(effectiveCfg.get(ISOLATION_LEVEL), IsolationLevel.class).configure(txnConfig);
tx = environment.beginTransaction(null, txnConfig);
} else {
if (txCfg instanceof TransactionConfiguration) {
if (!((TransactionConfiguration) txCfg).isSingleThreaded()) {
// Non-transactional cursors can't shared between threads, more info ThreadLocker.checkState
throw new PermanentBackendException("BerkeleyJE does not support non-transactional for multi threaded tx");
}
}
}
BerkeleyJETx btx = new BerkeleyJETx(tx, ConfigOption.getEnumValue(effectiveCfg.get(LOCK_MODE), LockMode.class), ConfigOption.getEnumValue(effectiveCfg.get(CACHE_MODE), CacheMode.class), txCfg);
if (log.isTraceEnabled()) {
log.trace("Berkeley tx created", new TransactionBegin(btx.toString()));
}
return btx;
} catch (DatabaseException e) {
throw new PermanentBackendException("Could not start BerkeleyJE transaction", e);
}
}
use of com.sleepycat.je.TransactionConfig in project qpid-broker-j by apache.
the class ReplicatedEnvironmentFacadeTest method putRecord.
private void putRecord(final ReplicatedEnvironmentFacade master, final Database db, final int key, final String value, final boolean commitNosync) {
final DatabaseEntry keyEntry = new DatabaseEntry();
IntegerBinding.intToEntry(key, keyEntry);
final DatabaseEntry dataEntry = new DatabaseEntry();
StringBinding.stringToEntry(value, dataEntry);
final TransactionConfig transactionConfig = new TransactionConfig();
transactionConfig.setDurability(master.getRealMessageStoreDurability());
final Transaction txn = master.beginTransaction(transactionConfig);
db.put(txn, keyEntry, dataEntry);
if (commitNosync) {
master.commitNoSync(txn);
} else {
master.commit(txn);
}
}
Aggregations