You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2009/03/20 19:45:35 UTC
svn commit: r756704 - in
/activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store:
BrokerDatabase.java Store.java memory/MemoryStore.java
Author: chirino
Date: Fri Mar 20 18:45:34 2009
New Revision: 756704
URL: http://svn.apache.org/viewvc?rev=756704&view=rev
Log:
better Store interface.. added a flush method and a way to know when transaction get flushed.
Modified:
activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/BrokerDatabase.java
activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/Store.java
activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java
Modified: activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/BrokerDatabase.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/BrokerDatabase.java?rev=756704&r1=756703&r2=756704&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/BrokerDatabase.java (original)
+++ activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/BrokerDatabase.java Fri Mar 20 18:45:34 2009
@@ -189,7 +189,7 @@
}
}
}
- });
+ }, null);
// Wait for the operations to commit.
for (Operation processed : processedQueue) {
processed.onCommit();
Modified: activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/Store.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/Store.java?rev=756704&r1=756703&r2=756704&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/Store.java (original)
+++ activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/Store.java Fri Mar 20 18:45:34 2009
@@ -11,7 +11,7 @@
* system.
*/
public interface Store {
-
+
/**
* This interface is used to execute transacted code.
*
@@ -56,7 +56,30 @@
}
}
- public <R, T extends Exception> R execute(Callback<R,T> callback) throws T;
+ /**
+ * Executes user supplied {@link Callback}. If the {@link Callback} does not throw
+ * any Exceptions, all updates to the store are committed to the store as a single
+ * unit of work, otherwise they are rolled back.
+ *
+ * When this method returns, the transaction may be buffered by the Store implementation
+ * it increase performance throughput. The onFlush parameter can be used to know when
+ * the transaction does get flushed is guaranteed to not be lost if a system crash occurs.
+ *
+ * You can force the flushing of all previously buffered transactions using the {@link #flush} method.
+ *
+ * Any exceptions thrown by the {@link Callback} are propagated by this method.
+ *
+ * @param <T>
+ * @param closure
+ * @param onFlush if not null, it's {@link Runnable#run()} method is called once he transaction has been store on disk.
+ */
+ public <R, T extends Exception> R execute(Callback<R,T> callback, Runnable onFlush) throws T;
+
+ /**
+ * Flushes all committed buffered transactions.
+ */
+ public void flush();
+
interface RecordKey {
@@ -86,7 +109,7 @@
super(message);
}
}
-
+
// Message related methods.
public RecordKey messageAdd(AsciiBuffer messageId, Buffer message);
public RecordKey messageGetKey(AsciiBuffer messageId);
Modified: activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java
URL: http://svn.apache.org/viewvc/activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java?rev=756704&r1=756703&r2=756704&view=diff
==============================================================================
--- activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java (original)
+++ activemq/sandbox/activemq-flow/src/main/java/org/apache/activemq/broker/store/memory/MemoryStore.java Fri Mar 20 18:45:34 2009
@@ -218,7 +218,14 @@
}
}
- public <R, T extends Exception> R execute(Callback<R, T> callback) throws T {
- return callback.execute(session);
+ public <R, T extends Exception> R execute(Callback<R, T> callback, Runnable runnable) throws T {
+ R rc = callback.execute(session);
+ if( runnable!=null ) {
+ runnable.run();
+ }
+ return rc;
+ }
+
+ public void flush() {
}
}