diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2012-11-28 00:50:54 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2012-11-28 00:50:54 +0000 |
commit | 341e3975fefdf5e2fb9a62cdf762af7738657ee6 (patch) | |
tree | c3558c277db94886da9f59c88161fe10f3ad4188 /src/main/java/com/amazon/carbonado/repo/replicated | |
parent | 6ba986731d5f9f35fd6a9f63d61cbd8288a9c12c (diff) |
ReplicatedRepository resync no longer creates a for-update transaction on the master.
Pass transaction to trigger, allowing it to change modes.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/repo/replicated')
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedStorage.java | 4 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java | 19 |
2 files changed, 15 insertions, 8 deletions
diff --git a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedStorage.java b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedStorage.java index cd65f46..f99276d 100644 --- a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedStorage.java +++ b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicatedStorage.java @@ -74,9 +74,9 @@ class ReplicatedStorage<S extends Storable> implements Storage<S> { }
/**
- * For testing only.
+ * Exposed for testing only.
*/
- ReplicatedStorage(Repository aRepository,
+ ReplicatedStorage(ReplicatedRepository aRepository,
Storage<S> replicaStorage,
Storage<S> masterStorage)
{
diff --git a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java index c646f8c..ce0ce53 100644 --- a/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java +++ b/src/main/java/com/amazon/carbonado/repo/replicated/ReplicationTrigger.java @@ -49,13 +49,13 @@ import com.amazon.carbonado.spi.TriggerManager; * @author Brian S O'Neill
*/
class ReplicationTrigger<S extends Storable> extends Trigger<S> {
- private final Repository mRepository;
+ private final ReplicatedRepository mRepository;
private final Storage<S> mReplicaStorage;
private final Storage<S> mMasterStorage;
private final TriggerManager<S> mTriggerManager;
- ReplicationTrigger(Repository repository,
+ ReplicationTrigger(ReplicatedRepository repository,
Storage<S> replicaStorage,
Storage<S> masterStorage)
{
@@ -231,9 +231,11 @@ class ReplicationTrigger<S extends Storable> extends Trigger<S> { setReplicationDisabled();
try {
- Transaction txn = mRepository.enterTransaction();
+ Transaction masterTxn = mRepository.getMasterRepository().enterTransaction();
+ Transaction replicaTxn = mRepository.getReplicaRepository().enterTransaction();
+
try {
- txn.setForUpdate(true);
+ replicaTxn.setForUpdate(true);
if (reload) {
if (masterEntry == null) {
@@ -320,13 +322,18 @@ class ReplicationTrigger<S extends Storable> extends Trigger<S> { }
}
- txn.commit();
+ replicaTxn.commit();
} catch (Throwable e) {
resyncFailed(listener, replicaEntry, masterEntry, newReplicaEntry, state);
ThrowUnchecked.fire(e);
}
} finally {
- txn.exit();
+ try {
+ masterTxn.exit();
+ } finally {
+ // Do second, favoring any exception thrown from it.
+ replicaTxn.exit();
+ }
}
} finally {
setReplicationEnabled();
|