summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/repo/sleepycat
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2008-02-04 05:42:54 +0000
committerBrian S. O'Neill <bronee@gmail.com>2008-02-04 05:42:54 +0000
commita786db8ab53c879858268da6a0cbe4ba9956d160 (patch)
treeedc01d19dbe5b706b51c8d6dfd5d17fd8f486d64 /src/main/java/com/amazon/carbonado/repo/sleepycat
parent530aa487847be05d87d9213ef669274289209c05 (diff)
Make TransactionManager creation more flexible.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo/sleepycat')
-rw-r--r--src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java16
-rw-r--r--src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java24
2 files changed, 21 insertions, 19 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java
index a0c549b..4bf4e2b 100644
--- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java
+++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBRepository.java
@@ -63,6 +63,7 @@ import com.amazon.carbonado.sequence.SequenceValueProducer;
import com.amazon.carbonado.spi.AbstractRepository;
import com.amazon.carbonado.spi.ExceptionTransformer;
import com.amazon.carbonado.spi.LobEngine;
+import com.amazon.carbonado.spi.TransactionManager;
import com.amazon.carbonado.spi.TransactionScope;
/**
@@ -93,6 +94,7 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn>
private final AtomicReference<Repository> mRootRef;
private final StorableCodecFactory mStorableCodecFactory;
private final ExceptionTransformer mExTransformer;
+ private final BDBTransactionManager<Txn> mTxnMgr;
Checkpointer mCheckpointer;
DeadlockDetector mDeadlockDetector;
@@ -141,6 +143,7 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn>
mTriggerFactories = builder.getTriggerFactories();
mRootRef = rootRef;
mExTransformer = exTransformer;
+ mTxnMgr = new BDBTransactionManager<Txn>(mExTransformer, this);
mRunCheckpointer = !builder.getReadOnly() && builder.getRunCheckpointer();
mRunDeadlockDetector = builder.getRunDeadlockDetector();
@@ -342,10 +345,6 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn>
return new SequenceValueGenerator(BDBRepository.this, name);
}
- protected BDBTransactionManager<Txn> createTransactionManager() {
- return new BDBTransactionManager<Txn>(mExTransformer, this);
- }
-
/**
* @see com.amazon.carbonado.spi.RepositoryBuilder#isMaster
*/
@@ -489,9 +488,12 @@ abstract class BDBRepository<Txn> extends AbstractRepository<Txn>
return mExTransformer.toRepositoryException(e);
}
- // Provides access to transaction scope from other classes.
- final TransactionScope<Txn> localTxnScope() {
- return localTransactionScope();
+ protected final TransactionManager<Txn> transactionManager() {
+ return mTxnMgr;
+ }
+
+ protected final TransactionScope<Txn> localTransactionScope() {
+ return mTxnMgr.localScope();
}
/**
diff --git a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java
index e7368ac..126e40f 100644
--- a/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java
+++ b/src/main/java/com/amazon/carbonado/repo/sleepycat/BDBStorage.java
@@ -203,7 +203,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
}
}
- TransactionScope<Txn> scope = localTxnScope();
+ TransactionScope<Txn> scope = localTransactionScope();
// Lock out shutdown task.
scope.getLock().lock();
@@ -317,7 +317,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
boolean reverseOrder)
throws FetchException
{
- TransactionScope<Txn> scope = localTxnScope();
+ TransactionScope<Txn> scope = localTransactionScope();
if (reverseRange) {
{
@@ -447,7 +447,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
boolean isPrimaryEmpty;
try {
- TransactionScope<Txn> scope = mRepository.localTxnScope();
+ TransactionScope<Txn> scope = mRepository.localTransactionScope();
// Lock out shutdown task.
scope.getLock().lock();
try {
@@ -572,7 +572,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
}
try {
- Txn txn = mRepository.localTxnScope().getTxn();
+ Txn txn = mRepository.localTransactionScope().getTxn();
return db_compact(txn, mPrimaryDatabase, start, end);
} catch (Exception e) {
throw mRepository.toRepositoryException(e);
@@ -667,8 +667,8 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
return mRepository.toRepositoryException(e);
}
- TransactionScope<Txn> localTxnScope() {
- return mRepository.localTxnScope();
+ TransactionScope<Txn> localTransactionScope() {
+ return mRepository.localTransactionScope();
}
/**
@@ -726,7 +726,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
* prevent threads from starting work that will likely fail along the way.
*/
void checkClosed() throws FetchException {
- TransactionScope<Txn> scope = localTxnScope();
+ TransactionScope<Txn> scope = localTransactionScope();
// Lock out shutdown task.
scope.getLock().lock();
@@ -747,7 +747,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
}
void close() throws Exception {
- TransactionScope<Txn> scope = mRepository.localTxnScope();
+ TransactionScope<Txn> scope = mRepository.localTransactionScope();
scope.getLock().lock();
try {
if (mPrimaryDatabase != null) {
@@ -998,7 +998,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
}
public byte[] tryLoad(byte[] key) throws FetchException {
- TransactionScope<Txn> scope = mStorage.localTxnScope();
+ TransactionScope<Txn> scope = mStorage.localTransactionScope();
byte[] result;
// Lock out shutdown task.
scope.getLock().lock();
@@ -1021,7 +1021,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
}
public boolean tryInsert(S storable, byte[] key, byte[] value) throws PersistException {
- TransactionScope<Txn> scope = mStorage.localTxnScope();
+ TransactionScope<Txn> scope = mStorage.localTransactionScope();
Object result;
// Lock out shutdown task.
scope.getLock().lock();
@@ -1044,7 +1044,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
}
public void store(S storable, byte[] key, byte[] value) throws PersistException {
- TransactionScope<Txn> scope = mStorage.localTxnScope();
+ TransactionScope<Txn> scope = mStorage.localTransactionScope();
// Lock out shutdown task.
scope.getLock().lock();
try {
@@ -1061,7 +1061,7 @@ abstract class BDBStorage<Txn, S extends Storable> implements Storage<S>, Storag
}
public boolean tryDelete(byte[] key) throws PersistException {
- TransactionScope<Txn> scope = mStorage.localTxnScope();
+ TransactionScope<Txn> scope = mStorage.localTransactionScope();
// Lock out shutdown task.
scope.getLock().lock();
try {