activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: [ARTEMIS-444] Extend AIOSequentialFileFactory to check underlying FS
Date Mon, 04 Apr 2016 16:27:53 GMT
[ARTEMIS-444] Extend AIOSequentialFileFactory to check underlying FS


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

Branch: refs/heads/master
Commit: 078d38bc3738af7b27e60a5879d414185e044498
Parents: db56f27
Author: Dominik Pospisil <dpospisi@redhat.com>
Authored: Mon Mar 21 12:25:45 2016 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Mon Apr 4 12:23:36 2016 -0400

----------------------------------------------------------------------
 .../core/io/aio/AIOSequentialFileFactory.java   | 32 ++++++++++++++++++++
 .../activemq/artemis/jlibaio/LibaioContext.java |  2 +-
 .../core/server/ActiveMQServerLogger.java       |  5 +++
 .../core/server/impl/ActiveMQServerImpl.java    | 12 ++++++--
 4 files changed, 47 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/078d38bc/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java
b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java
index b7bb47e..93c09ee 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/aio/AIOSequentialFileFactory.java
@@ -50,6 +50,8 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor
 
    private final AtomicBoolean running = new AtomicBoolean(false);
 
+   private static final String AIO_TEST_FILE = ".aio-test";
+
    // This method exists just to make debug easier.
    // I could replace log.trace by log.info temporarily while I was debugging
    // Journal
@@ -114,6 +116,36 @@ public final class AIOSequentialFileFactory extends AbstractSequentialFileFactor
       return LibaioContext.isLoaded();
    }
 
+   public static boolean isSupported(File journalPath) {
+      if (!isSupported()) {
+         return false;
+      }
+
+      File aioTestFile = new File(journalPath, AIO_TEST_FILE);
+      try {
+         int fd = LibaioContext.open(aioTestFile.getAbsolutePath(), true);
+         LibaioContext.close(fd);
+         aioTestFile.delete();
+      }
+      catch (Exception e) {
+         // try to handle the file using plain Java
+         // return false if and only if we can create/remove the file using
+         // plain Java but not using AIO
+         try {
+            if (!aioTestFile.exists()) {
+               if (!aioTestFile.createNewFile()) return true;
+            }
+            if (!aioTestFile.delete()) return true;
+         }
+         catch (Exception ie) {
+            // we can not even create the test file using plain java
+            return true;
+         }
+         return false;
+      }
+      return true;
+   }
+
    @Override
    public ByteBuffer allocateDirectBuffer(final int size) {
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/078d38bc/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java
----------------------------------------------------------------------
diff --git a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java
b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java
index 75db50d..df4c61b 100644
--- a/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java
+++ b/artemis-native/src/main/java/org/apache/activemq/artemis/jlibaio/LibaioContext.java
@@ -390,7 +390,7 @@ public class LibaioContext<Callback extends SubmitInfo> implements
Closeable {
     */
    public static native int open(String path, boolean direct);
 
-   static native void close(int fd);
+   public static native void close(int fd);
 
    /**
     */

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/078d38bc/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
index 4f82f2e..55f7268 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
@@ -1479,4 +1479,9 @@ public interface ActiveMQServerLogger extends BasicLogger {
    @LogMessage(level = Logger.Level.DEBUG)
    @Message(id = 224070, value = "Received Interrupt Exception whilst waiting for component
to shutdown: {0}", format = Message.Format.MESSAGE_FORMAT)
    void interruptWhilstStoppingComponent(String componentClassName);
+
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 224072, value = "libaio was found but the filesystem does not support AIO.
Switching the configuration into NIO. Journal path: {0}", format = Message.Format.MESSAGE_FORMAT)
+   void switchingNIOonPath(String journalPath);
+
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/078d38bc/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 69d13bf..d7eda42 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -1682,9 +1682,15 @@ public class ActiveMQServerImpl implements ActiveMQServer {
       // Create the pools - we have two pools - one for non scheduled - and another for scheduled
       initializeExecutorServices();
 
-      if (configuration.getJournalType() == JournalType.ASYNCIO && !AIOSequentialFileFactory.isSupported())
{
-         ActiveMQServerLogger.LOGGER.switchingNIO();
-         configuration.setJournalType(JournalType.NIO);
+      if (configuration.getJournalType() == JournalType.ASYNCIO) {
+         if (!AIOSequentialFileFactory.isSupported()) {
+            ActiveMQServerLogger.LOGGER.switchingNIO();
+            configuration.setJournalType(JournalType.NIO);
+         }
+         else if (!AIOSequentialFileFactory.isSupported(configuration.getJournalLocation()))
{
+            ActiveMQServerLogger.LOGGER.switchingNIOonPath(configuration.getJournalLocation().getAbsolutePath());
+            configuration.setJournalType(JournalType.NIO);
+         }
       }
 
       managementService = new ManagementServiceImpl(mbeanServer, configuration);


Mime
View raw message