You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ma...@apache.org on 2017/06/26 18:12:33 UTC

[1/2] activemq-artemis git commit: ARTEMIS-1204 Replace open sync with AtomicBoolean

Repository: activemq-artemis
Updated Branches:
  refs/heads/1.x 9d48d2f1d -> 15990589a


ARTEMIS-1204 Replace open sync with AtomicBoolean

The JDBCSequentialFile blocks on the writeLock when opening.  There is
no need to block here, in fact it may cause issues when opening and
syncing concurrently.  Instead an AtomicBoolean is enough to prevent the
file from being reloaded.

(cherry picked from commit 604db9ee7e01a91ec41d95f67a37a2d21afaa74c)


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

Branch: refs/heads/1.x
Commit: 21215e4e2dc021e717e7021a70f9b4cbdd2df110
Parents: 9d48d2f
Author: Martyn Taylor <mt...@redhat.com>
Authored: Tue Jun 13 15:02:31 2017 +0100
Committer: Martyn Taylor <mt...@redhat.com>
Committed: Mon Jun 26 19:11:53 2017 +0100

----------------------------------------------------------------------
 .../jdbc/store/file/JDBCSequentialFile.java     | 32 +++++++++++---------
 .../file/JDBCSequentialFileFactoryDriver.java   |  2 +-
 2 files changed, 18 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21215e4e/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
index 018000d..9d1be1f 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFile.java
@@ -23,6 +23,7 @@ import java.sql.SQLException;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executor;
+import java.util.concurrent.atomic.AtomicBoolean;
 
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffers;
@@ -43,9 +44,9 @@ public class JDBCSequentialFile implements SequentialFile {
 
    private final String extension;
 
-   private boolean isOpen = false;
+   private AtomicBoolean isOpen = new AtomicBoolean(false);
 
-   private boolean isLoaded = false;
+   private AtomicBoolean isLoaded = new AtomicBoolean(false);
 
    private long id = -1;
 
@@ -83,12 +84,12 @@ public class JDBCSequentialFile implements SequentialFile {
 
    @Override
    public boolean isOpen() {
-      return isOpen;
+      return isOpen.get();
    }
 
    @Override
    public boolean exists() {
-      if (isLoaded) return true;
+      if (isLoaded.get()) return true;
       try {
          return fileFactory.listFiles(extension).contains(filename);
       } catch (Exception e) {
@@ -100,21 +101,20 @@ public class JDBCSequentialFile implements SequentialFile {
 
    @Override
    public void open() throws Exception {
-      load();
-      isOpen = true;
+      isOpen.compareAndSet(false, load());
    }
 
-   private void load() {
+   private boolean load() {
       try {
-         synchronized (writeLock) {
-            if (!isLoaded) {
-               dbDriver.openFile(this);
-               isLoaded = true;
-            }
+         if (isLoaded.compareAndSet(false, true)) {
+            dbDriver.openFile(this);
          }
+         return true;
       } catch (SQLException e) {
+         isLoaded.set(false);
          fileFactory.onIOError(e, "Error attempting to open JDBC file.", this);
       }
+      return false;
    }
 
    @Override
@@ -146,8 +146,9 @@ public class JDBCSequentialFile implements SequentialFile {
    public void delete() throws IOException, InterruptedException, ActiveMQException {
       try {
          synchronized (writeLock) {
-            load();
-            dbDriver.deleteFile(this);
+            if (load()) {
+               dbDriver.deleteFile(this);
+            }
          }
       } catch (SQLException e) {
          fileFactory.onIOError(e, "Error deleting JDBC file.", this);
@@ -156,6 +157,7 @@ public class JDBCSequentialFile implements SequentialFile {
 
    private synchronized int internalWrite(byte[] data, IOCallback callback) {
       try {
+         open();
          synchronized (writeLock) {
             int noBytes = dbDriver.writeToFile(this, data);
             seek(noBytes);
@@ -281,7 +283,7 @@ public class JDBCSequentialFile implements SequentialFile {
 
    @Override
    public void close() throws Exception {
-      isOpen = false;
+      isOpen.set(false);
       sync();
       fileFactory.sequentialFileClosed(this);
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/21215e4e/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java
----------------------------------------------------------------------
diff --git a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java
index 6cf54ff..fdd7c76 100644
--- a/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java
+++ b/artemis-jdbc-store/src/main/java/org/apache/activemq/artemis/jdbc/store/file/JDBCSequentialFileFactoryDriver.java
@@ -165,7 +165,7 @@ public class JDBCSequentialFileFactoryDriver extends AbstractJDBCDriver {
                if (blob != null) {
                   file.setWritePosition(blob.length());
                } else {
-                  logger.warn("ERROR NO BLOB FOR FILE" + "File: " + file.getFileName() + " " + file.getId());
+                  logger.trace("No Blob found for file: " + file.getFileName() + " " + file.getId());
                }
             }
             connection.commit();


[2/2] activemq-artemis git commit: ARTEMIS-1254 New OrderedExecutor for JDBC LargeMsg

Posted by ma...@apache.org.
ARTEMIS-1254 New OrderedExecutor for JDBC LargeMsg

(cherry picked from commit 222275dd8dc29450bce9bce0419b8a55b797673c)


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

Branch: refs/heads/1.x
Commit: 15990589a368bde944058fec9c012a71f37ca261
Parents: 21215e4
Author: Martyn Taylor <mt...@redhat.com>
Authored: Thu Jun 22 13:34:34 2017 +0100
Committer: Martyn Taylor <mt...@redhat.com>
Committed: Mon Jun 26 19:12:03 2017 +0100

----------------------------------------------------------------------
 .../core/persistence/impl/journal/JDBCJournalStorageManager.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/15990589/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JDBCJournalStorageManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JDBCJournalStorageManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JDBCJournalStorageManager.java
index 4b8392d..9923a3e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JDBCJournalStorageManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JDBCJournalStorageManager.java
@@ -66,12 +66,12 @@ public class JDBCJournalStorageManager extends JournalStorageManager {
             }
             bindingsJournal = new JDBCJournalImpl(dbConf.getDataSource(), sqlProviderFactory.create(dbConf.getBindingsTableName(), SQLProvider.DatabaseStoreType.BINDINGS_JOURNAL), dbConf.getBindingsTableName(), scheduledExecutorService, executorFactory.getExecutor(), criticalErrorListener);
             messageJournal = new JDBCJournalImpl(dbConf.getDataSource(), sqlProviderFactory.create(dbConf.getMessageTableName(), SQLProvider.DatabaseStoreType.MESSAGE_JOURNAL), dbConf.getMessageTableName(), scheduledExecutorService, executorFactory.getExecutor(), criticalErrorListener);
-            largeMessagesFactory = new JDBCSequentialFileFactory(dbConf.getDataSource(), sqlProviderFactory.create(dbConf.getLargeMessageTableName(), SQLProvider.DatabaseStoreType.LARGE_MESSAGE), executor, criticalErrorListener);
+            largeMessagesFactory = new JDBCSequentialFileFactory(dbConf.getDataSource(), sqlProviderFactory.create(dbConf.getLargeMessageTableName(), SQLProvider.DatabaseStoreType.LARGE_MESSAGE), executorFactory.getExecutor(), criticalErrorListener);
          } else {
             String driverClassName = dbConf.getJdbcDriverClassName();
             bindingsJournal = new JDBCJournalImpl(dbConf.getJdbcConnectionUrl(), driverClassName, JDBCUtils.getSQLProvider(driverClassName, dbConf.getBindingsTableName(), SQLProvider.DatabaseStoreType.BINDINGS_JOURNAL), scheduledExecutorService, executorFactory.getExecutor(), criticalErrorListener);
             messageJournal = new JDBCJournalImpl(dbConf.getJdbcConnectionUrl(), driverClassName, JDBCUtils.getSQLProvider(driverClassName, dbConf.getMessageTableName(), SQLProvider.DatabaseStoreType.MESSAGE_JOURNAL), scheduledExecutorService, executorFactory.getExecutor(), criticalErrorListener);
-            largeMessagesFactory = new JDBCSequentialFileFactory(dbConf.getJdbcConnectionUrl(), driverClassName, JDBCUtils.getSQLProvider(driverClassName, dbConf.getLargeMessageTableName(), SQLProvider.DatabaseStoreType.LARGE_MESSAGE), executor, criticalErrorListener);
+            largeMessagesFactory = new JDBCSequentialFileFactory(dbConf.getJdbcConnectionUrl(), driverClassName, JDBCUtils.getSQLProvider(driverClassName, dbConf.getLargeMessageTableName(), SQLProvider.DatabaseStoreType.LARGE_MESSAGE), executorFactory.getExecutor(), criticalErrorListener);
          }
          final int networkTimeout = dbConf.getJdbcNetworkTimeout();
          if (networkTimeout >= 0) {