activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andytay...@apache.org
Subject [4/5] activemq-artemis git commit: Support sync=true in JDBCJournal append record
Date Thu, 04 Feb 2016 18:21:51 GMT
Support sync=true in JDBCJournal append record


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/0e4a164b
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/0e4a164b
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/0e4a164b

Branch: refs/heads/master
Commit: 0e4a164b39e0fcd59751f737c97440541f376892
Parents: 5eecd87
Author: Martyn Taylor <mtaylor@redhat.com>
Authored: Thu Feb 4 14:44:26 2016 +0000
Committer: Martyn Taylor <mtaylor@redhat.com>
Committed: Thu Feb 4 16:24:47 2016 +0000

----------------------------------------------------------------------
 .../artemis/jdbc/store/journal/JDBCJournalImpl.java   | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0e4a164b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
index 2f56add..632d7a3 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/journal/JDBCJournalImpl.java
@@ -42,13 +42,14 @@ import org.apache.activemq.artemis.core.journal.PreparedTransactionInfo;
 import org.apache.activemq.artemis.core.journal.RecordInfo;
 import org.apache.activemq.artemis.core.journal.TransactionFailureCallback;
 import org.apache.activemq.artemis.core.journal.impl.JournalFile;
+import org.apache.activemq.artemis.core.journal.impl.SimpleWaitIOCallback;
 import org.apache.activemq.artemis.jdbc.store.JDBCUtils;
 import org.apache.activemq.artemis.journal.ActiveMQJournalLogger;
 
 public class JDBCJournalImpl implements Journal {
 
    // Sync Delay in ms
-   public static final int SYNC_DELAY = 500;
+   public static final int SYNC_DELAY = 5;
 
    private static int USER_VERSION = 1;
 
@@ -285,7 +286,14 @@ public class JDBCJournalImpl implements Journal {
       t.start();
    }
 
-   private synchronized void appendRecord(JDBCJournalRecord record) {
+   private void appendRecord(JDBCJournalRecord record) throws Exception {
+
+      SimpleWaitIOCallback callback = null;
+      if (record.isSync() && record.getIoCompletion() == null) {
+         callback = new SimpleWaitIOCallback();
+         record.setIoCompletion(callback);
+      }
+
       try {
          journalLock.writeLock().lock();
          if (record.isTransactional() || record.getRecordType() == JDBCJournalRecord.PREPARE_RECORD)
{
@@ -296,6 +304,8 @@ public class JDBCJournalImpl implements Journal {
       finally {
          journalLock.writeLock().unlock();
       }
+
+      if (callback != null) callback.waitCompletion();
    }
 
    private void addTxRecord(JDBCJournalRecord record) {


Mime
View raw message