activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbert...@apache.org
Subject [3/6] activemq-artemis git commit: ARTEMIS-1117 Improving IO Resilience Part II
Date Tue, 18 Apr 2017 17:06:33 GMT
ARTEMIS-1117 Improving IO Resilience Part II

https://issues.apache.org/jira/browse/ARTEMIS-1117


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

Branch: refs/heads/master
Commit: 0a0955d0ccfd948bf9aa8c4c13a46ac92d4e9463
Parents: 23ba3e2
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Thu Apr 13 09:04:34 2017 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Apr 18 11:34:09 2017 -0400

----------------------------------------------------------------------
 .../journal/impl/JournalFilesRepository.java    | 45 +++++++++++++++-----
 1 file changed, 34 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/0a0955d0/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
index 8440d93..c0a278d 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalFilesRepository.java
@@ -90,6 +90,7 @@ public class JournalFilesRepository {
             pushOpenedFile();
          } catch (Exception e) {
             ActiveMQJournalLogger.LOGGER.errorPushingFile(e);
+            fileFactory.onIOError(e, "unable to open ", null);
          }
       }
    };
@@ -412,21 +413,35 @@ public class JournalFilesRepository {
          logger.trace("enqueueOpenFile with openedFiles.size=" + openedFiles.size());
       }
 
-      if (openFilesExecutor == null) {
-         pushOpenRunnable.run();
-      } else {
-         openFilesExecutor.execute(pushOpenRunnable);
-      }
+      // First try to get an open file, that's prepared and already open
+      JournalFile nextFile = openedFiles.poll();
 
-      JournalFile nextFile = openedFiles.poll(5, TimeUnit.SECONDS);
       if (nextFile == null) {
-         fileFactory.onIOError(ActiveMQJournalBundle.BUNDLE.fileNotOpened(), "unable to open
", null);
-         // We need to reconnect the current file with the timed buffer as we were not able
to roll the file forward
-         // If you don't do this you will get a NPE in TimedBuffer::checkSize where it uses
the bufferobserver
-         fileFactory.activateBuffer(journal.getCurrentFile().getFile());
-         throw ActiveMQJournalBundle.BUNDLE.fileNotOpened();
+         // if there's none, push to open
+
+         pushOpen();
+
+         nextFile = openedFiles.poll(5, TimeUnit.SECONDS);
+      }
+
+      if (openedFiles.isEmpty()) {
+         // if empty, push to open one.
+         pushOpen();
       }
 
+      if (nextFile == null) {
+
+         logger.debug("Could not get a file in 5 seconds, it will retry directly, without
an executor");
+         try {
+            nextFile = takeFile(true, true, true, false);
+         } catch (Exception e) {
+            fileFactory.onIOError(e, "unable to open ", null);
+            // We need to reconnect the current file with the timed buffer as we were not
able to roll the file forward
+            // If you don't do this you will get a NPE in TimedBuffer::checkSize where it
uses the bufferobserver
+            fileFactory.activateBuffer(journal.getCurrentFile().getFile());
+            throw ActiveMQJournalBundle.BUNDLE.fileNotOpened();
+         }
+      }
       if (logger.isTraceEnabled()) {
          logger.trace("Returning file " + nextFile);
       }
@@ -434,6 +449,14 @@ public class JournalFilesRepository {
       return nextFile;
    }
 
+   private void pushOpen() {
+      if (openFilesExecutor == null) {
+         pushOpenRunnable.run();
+      } else {
+         openFilesExecutor.execute(pushOpenRunnable);
+      }
+   }
+
    /**
     * Open a file and place it into the openedFiles queue
     */


Mime
View raw message