Permalink
Browse files

Removed transaction filtering

  • Loading branch information...
TheNavigateur committed Nov 8, 2011
1 parent 9749655 commit 79854f2c979d41ab34c7bec65a9b6dccb9cdfddd
@@ -50,15 +50,15 @@ public Object deserialize(Serializer journalSerializer) {
}
/**
- * Executes a freshly deserialized copy of the transaction if this is being called via the royal food taster or if <code>configureTransactionDeepCopy</code> wasn't set to <code>false</code> on your <code>PrevaylerFactory</code>. Otherwise, this will execute the transaction directly. The execution will synchronize on the prevalentSystem.
+ * Executes a freshly deserialized copy of the transaction by default. If <code>configureTransactionDeepCopy</code> was set to <code>true</code> on your <code>PrevaylerFactory</code>, this will execute the transaction directly. The execution will synchronize on the prevalentSystem.
*/
- public void executeOn(Object prevalentSystem, Date executionTime, Serializer journalSerializer, boolean guaranteeTransactionDeepCopy) {
+ public void executeOn(Object prevalentSystem, Date executionTime, Serializer journalSerializer) {
Object transaction;
- if(guaranteeTransactionDeepCopy || _transaction == null){
- transaction = deserialize(journalSerializer);
+ if(_transaction != null){
+ transaction = _transaction;
}
else{
- transaction = _transaction;
+ transaction = deserialize(journalSerializer);
}
synchronized (prevalentSystem) {
@@ -20,7 +20,6 @@
private long _systemVersion; // All access is synchronized on "this"
private boolean _ignoreRuntimeExceptions; // All access is synchronized on "this"
private final Serializer _journalSerializer;
- private boolean _guaranteeTransactionDeepCopy = false;
public PrevalentSystemGuard(P prevalentSystem, long systemVersion, Serializer journalSerializer) {
_prevalentSystem = prevalentSystem;
@@ -37,10 +36,6 @@ public P prevalentSystem() {
return _prevalentSystem;
}
}
-
- public void guaranteeTransactionDeepCopy(){
- _guaranteeTransactionDeepCopy = true;
- }
public void subscribeTo(TransactionPublisher publisher) throws IOException, ClassNotFoundException {
long initialTransaction;
@@ -76,7 +71,7 @@ public void receive(TransactionTimestamp transactionTimestamp) {
try {
// Don't synchronize on _prevalentSystem here so that the capsule can deserialize a fresh
// copy of the transaction without blocking queries.
- capsule.executeOn(_prevalentSystem, executionTime, _journalSerializer, _guaranteeTransactionDeepCopy);
+ capsule.executeOn(_prevalentSystem, executionTime, _journalSerializer);
} catch (RuntimeException rx) {
if (!_ignoreRuntimeExceptions) throw rx; //TODO Guarantee that transactions received from pending transaction recovery don't ever throw RuntimeExceptions. Maybe use a wrapper for that.
} catch (Error error) {
@@ -12,14 +12,12 @@
import org.prevayler.implementation.TransactionTimestamp;
import org.prevayler.implementation.clock.PausableClock;
import org.prevayler.implementation.journal.Journal;
-import org.prevayler.implementation.publishing.censorship.TransactionCensor;
import java.io.IOException;
public class CentralPublisher extends AbstractPublisher {
private final PausableClock _pausableClock;
- private final TransactionCensor _censor;
private final Journal _journal;
private volatile int _pendingPublications = 0;
@@ -30,11 +28,10 @@
private final Object _nextTurnMonitor = new Object();
- public CentralPublisher(Clock clock, TransactionCensor censor, Journal journal) {
+ public CentralPublisher(Clock clock, Journal journal) {
super(new PausableClock(clock));
_pausableClock = (PausableClock) _clock; //This is just to avoid casting the inherited _clock every time.
- _censor = censor;
_journal = journal;
}
@@ -69,9 +66,7 @@ private TransactionGuide approve(Capsule capsule) {
synchronized (_nextTurnMonitor) {
TransactionTimestamp timestamp = new TransactionTimestamp(capsule, _nextTransaction, _pausableClock.realTime());
- _censor.approve(timestamp);
-
- // Only count this transaction once approved.
+ // Count this transaction
Turn turn = _nextTurn;
_nextTurn = _nextTurn.next();
_nextTransaction++;
@@ -1,14 +0,0 @@
-//Prevayler(TM) - The Free-Software Prevalence Layer.
-//Copyright (C) 2001-2003 Klaus Wuestefeld
-//This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-package org.prevayler.implementation.publishing.censorship;
-
-import org.prevayler.implementation.TransactionTimestamp;
-
-public class LiberalTransactionCensor implements TransactionCensor {
-
- public void approve(TransactionTimestamp transactionTimestamp) throws RuntimeException, Error {
- }
-
-}
@@ -1,62 +0,0 @@
-//Prevayler(TM) - The Free-Software Prevalence Layer.
-//Copyright (C) 2001-2003 Klaus Wuestefeld
-//This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-//Contributions: Jon Tirs�n.
-
-package org.prevayler.implementation.publishing.censorship;
-
-import java.io.Serializable;
-
-import org.prevayler.foundation.serialization.Serializer;
-import org.prevayler.implementation.PrevalentSystemGuard;
-import org.prevayler.implementation.TransactionTimestamp;
-import org.prevayler.implementation.snapshot.GenericSnapshotManager;
-
-public class StrictTransactionCensor<P> implements TransactionCensor {
-
- private final PrevalentSystemGuard<P> _king;
- private PrevalentSystemGuard<P> _royalFoodTaster;
- private final Serializer _snapshotSerializer;
-
- public StrictTransactionCensor(GenericSnapshotManager<P> snapshotManager) {
- _king = snapshotManager.recoveredPrevalentSystem();
- // The _royalFoodTaster cannot be initialized here, or else the pending transactions will not be applied to it.
- _snapshotSerializer = snapshotManager.primarySerializer();
- }
-
- public void approve(TransactionTimestamp transactionTimestamp) throws RuntimeException, Error {
- try {
- TransactionTimestamp timestampCopy = transactionTimestamp.cleanCopy();
- PrevalentSystemGuard<P> royalFoodTaster = royalFoodTaster(transactionTimestamp.systemVersion() - 1);
- royalFoodTaster.receive(timestampCopy);
- } catch (RuntimeException rx) {
- letTheFoodTasterDie();
- throw rx;
- } catch (Error error) {
- letTheFoodTasterDie();
- throw error;
- }
- }
-
- private void letTheFoodTasterDie() {
- _royalFoodTaster = null; // At this moment there might be transactions that have already been approved by this censor but have not yet been applied to the _king. It is a requirement, therefore, that the _royalFoodTaster must not be initialized now, but only when the next transaction arrives to be approved.
- }
-
- private PrevalentSystemGuard<P> royalFoodTaster(long systemVersion) {
- if (_royalFoodTaster == null) produceNewFoodTaster(systemVersion);
- return _royalFoodTaster;
- }
-
- private void produceNewFoodTaster(long systemVersion) {
- try {
- _royalFoodTaster = _king.deepCopy(systemVersion, _snapshotSerializer);
- _royalFoodTaster.guaranteeTransactionDeepCopy();
- } catch (Exception ex) {
- ex.printStackTrace();
- throw new RuntimeException("Unable to produce a copy of the prevalent system for trying out transactions before applying them to the real system.");
- }
- }
-
-}
-
-
@@ -1,15 +0,0 @@
-//Prevayler(TM) - The Free-Software Prevalence Layer.
-//Copyright (C) 2001-2003 Klaus Wuestefeld
-//This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
-package org.prevayler.implementation.publishing.censorship;
-
-import org.prevayler.implementation.TransactionTimestamp;
-
-// START SNIPPET: censor
-public interface TransactionCensor {
-
- public void approve(TransactionTimestamp transactionTimestamp) throws RuntimeException, Error;
-
-}
-//END SNIPPET: censor

0 comments on commit 79854f2

Please sign in to comment.