activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-1237 - Hard coded timeout on Journal file open
Date Thu, 22 Jun 2017 16:05:01 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/1.x 6b1bd7862 -> 5b0a13386


ARTEMIS-1237 - Hard coded timeout on Journal file open

Make timeout configurable

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


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

Branch: refs/heads/1.x
Commit: 333959dc002ec4769225feab06f86081f084a66d
Parents: 6b1bd78
Author: Andy Taylor <andy.tayls67@gmail.com>
Authored: Mon Jun 19 12:04:21 2017 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Thu Jun 22 12:03:16 2017 -0400

----------------------------------------------------------------------
 .../config/ActiveMQDefaultConfiguration.java    |  7 +++++
 .../journal/impl/JournalFilesRepository.java    |  8 +++--
 .../artemis/core/journal/impl/JournalImpl.java  | 33 ++++++++++++++++++--
 .../artemis/core/config/Configuration.java      | 10 ++++++
 .../core/config/impl/ConfigurationImpl.java     | 13 ++++++++
 .../deployers/impl/FileConfigurationParser.java |  2 ++
 .../impl/journal/JournalStorageManager.java     |  2 +-
 .../resources/schema/artemis-configuration.xsd  |  8 +++++
 .../core/config/impl/FileConfigurationTest.java |  1 +
 .../resources/ConfigurationTest-full-config.xml |  1 +
 10 files changed, 80 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/333959dc/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
index 7f2bb77..5b4a37d 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/api/config/ActiveMQDefaultConfiguration.java
@@ -258,6 +258,9 @@ public final class ActiveMQDefaultConfiguration {
    // The percentage of live data on which we consider compacting the journal
    private static int DEFAULT_JOURNAL_COMPACT_PERCENTAGE = 30;
 
+   // The time to wait when opening a new journal file before failing
+   private static int DEFAULT_JOURNAL_FILE_OPEN_TIMEOUT = 5;
+
    // The minimal number of data files before we can start compacting
    private static int DEFAULT_JOURNAL_COMPACT_MIN_FILES = 10;
 
@@ -782,6 +785,10 @@ public final class ActiveMQDefaultConfiguration {
       return DEFAULT_JOURNAL_COMPACT_PERCENTAGE;
    }
 
+   public static int getDefaultJournalFileOpenTimeout() {
+      return DEFAULT_JOURNAL_FILE_OPEN_TIMEOUT;
+   }
+
    /**
     * The minimal number of data files before we can start compacting
     */

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/333959dc/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..3942837 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
@@ -81,6 +81,8 @@ public class JournalFilesRepository {
 
    private final AtomicInteger freeFilesCount = new AtomicInteger(0);
 
+   private final int journalFileOpenTimeout;
+
    private Executor openFilesExecutor;
 
    private final Runnable pushOpenRunnable = new Runnable() {
@@ -102,7 +104,8 @@ public class JournalFilesRepository {
                                  final int maxAIO,
                                  final int fileSize,
                                  final int minFiles,
-                                 final int poolSize) {
+                                 final int poolSize,
+                                 final int journalFileOpenTimeout) {
       if (filePrefix == null) {
          throw new IllegalArgumentException("filePrefix cannot be null");
       }
@@ -121,6 +124,7 @@ public class JournalFilesRepository {
       this.poolSize = poolSize;
       this.userVersion = userVersion;
       this.journal = journal;
+      this.journalFileOpenTimeout = journalFileOpenTimeout;
    }
 
    // Public --------------------------------------------------------
@@ -418,7 +422,7 @@ public class JournalFilesRepository {
          openFilesExecutor.execute(pushOpenRunnable);
       }
 
-      JournalFile nextFile = openedFiles.poll(5, TimeUnit.SECONDS);
+      JournalFile nextFile = openedFiles.poll(journalFileOpenTimeout, 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

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/333959dc/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
index 75c7fd1..775ef4b 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/journal/impl/JournalImpl.java
@@ -234,7 +234,35 @@ public class JournalImpl extends JournalBase implements TestableJournal,
Journal
                       final String fileExtension,
                       final int maxAIO,
                       final int userVersion) {
-      this(null, fileSize, minFiles, poolSize, compactMinFiles, compactPercentage, fileFactory,
filePrefix, fileExtension, maxAIO, userVersion);
+      this(null, fileSize, minFiles, poolSize, compactMinFiles, compactPercentage, 5, fileFactory,
filePrefix, fileExtension, maxAIO, userVersion);
+   }
+
+   public JournalImpl(final int fileSize,
+                      final int minFiles,
+                      final int poolSize,
+                      final int compactMinFiles,
+                      final int compactPercentage,
+                      final int journalFileOpenTimeout,
+                      final SequentialFileFactory fileFactory,
+                      final String filePrefix,
+                      final String fileExtension,
+                      final int maxAIO,
+                      final int userVersion) {
+      this(null, fileSize, minFiles, poolSize, compactMinFiles, compactPercentage, journalFileOpenTimeout,
fileFactory, filePrefix, fileExtension, maxAIO, userVersion);
+   }
+
+   public JournalImpl(final ExecutorFactory ioExecutors,
+                      final int fileSize,
+                      final int minFiles,
+                      final int poolSize,
+                      final int compactMinFiles,
+                      final int compactPercentage,
+                      final SequentialFileFactory fileFactory,
+                      final String filePrefix,
+                      final String fileExtension,
+                      final int maxAIO,
+                      final int userVersion) {
+      this(ioExecutors, fileSize, minFiles, poolSize, compactMinFiles, compactPercentage,
5, fileFactory, filePrefix, fileExtension, maxAIO, userVersion);
    }
 
    public JournalImpl(final ExecutorFactory ioExecutors,
@@ -243,6 +271,7 @@ public class JournalImpl extends JournalBase implements TestableJournal,
Journal
                       final int poolSize,
                       final int compactMinFiles,
                       final int compactPercentage,
+                      final int journalFileOpenTimeout,
                       final SequentialFileFactory fileFactory,
                       final String filePrefix,
                       final String fileExtension,
@@ -275,7 +304,7 @@ public class JournalImpl extends JournalBase implements TestableJournal,
Journal
 
       this.fileFactory = fileFactory;
 
-      filesRepository = new JournalFilesRepository(fileFactory, this, filePrefix, fileExtension,
userVersion, maxAIO, fileSize, minFiles, poolSize);
+      filesRepository = new JournalFilesRepository(fileFactory, this, filePrefix, fileExtension,
userVersion, maxAIO, fileSize, minFiles, poolSize, journalFileOpenTimeout);
 
       this.userVersion = userVersion;
    }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/333959dc/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
index 28f3623..a1bc2b6 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
@@ -620,6 +620,16 @@ public interface Configuration {
    int getJournalCompactPercentage();
 
    /**
+    * @return How long to wait when opening a new Journal file before failing
+    */
+   int getJournalFileOpenTimeout();
+
+   /**
+   * Sets the journal file open timeout
+   */
+   Configuration setJournalFileOpenTimeout(int journalFileOpenTimeout);
+
+   /**
     * Sets the percentage of live data before compacting the journal.
     */
    Configuration setJournalCompactPercentage(int percentage);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/333959dc/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
index 1f57327..da2e769 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
@@ -167,6 +167,8 @@ public class ConfigurationImpl implements Configuration, Serializable
{
 
    protected int journalCompactPercentage = ActiveMQDefaultConfiguration.getDefaultJournalCompactPercentage();
 
+   protected int journalFileOpenTimeout = ActiveMQDefaultConfiguration.getDefaultJournalFileOpenTimeout();
+
    protected int journalFileSize = ActiveMQDefaultConfiguration.getDefaultJournalFileSize();
 
    protected int journalPoolFiles = ActiveMQDefaultConfiguration.getDefaultJournalPoolFiles();
@@ -1114,6 +1116,17 @@ public class ConfigurationImpl implements Configuration, Serializable
{
    }
 
    @Override
+   public int getJournalFileOpenTimeout() {
+      return journalFileOpenTimeout;
+   }
+
+   @Override
+   public Configuration setJournalFileOpenTimeout(int journalFileOpenTimeout) {
+      this.journalFileOpenTimeout = journalFileOpenTimeout;
+      return this;
+   }
+
+   @Override
    public ConfigurationImpl setJournalCompactPercentage(final int percentage) {
       journalCompactPercentage = percentage;
       return this;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/333959dc/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
index ab700a5..cc30163 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
@@ -510,6 +510,8 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
          config.setJournalMaxIO_NIO(journalMaxIO);
       }
 
+      config.setJournalFileOpenTimeout(getInteger(e, "journal-file-open-timeout", ActiveMQDefaultConfiguration.getDefaultJournalFileOpenTimeout(),
Validators.GT_ZERO));
+
       config.setJournalMinFiles(getInteger(e, "journal-min-files", config.getJournalMinFiles(),
Validators.GT_ZERO));
 
       config.setJournalPoolFiles(getInteger(e, "journal-pool-files", config.getJournalPoolFiles(),
Validators.MINUS_ONE_OR_GT_ZERO));

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/333959dc/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java
index 4f041a8..c286e67 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java
@@ -121,7 +121,7 @@ public class JournalStorageManager extends AbstractJournalStorageManager
{
       bindingsFF = new NIOSequentialFileFactory(config.getBindingsLocation(), criticalErrorListener,
config.getJournalMaxIO_NIO());
       bindingsFF.setDatasync(config.isJournalDatasync());
 
-      Journal localBindings = new JournalImpl(ioExecutors, 1024 * 1024, 2, config.getJournalCompactMinFiles(),
config.getJournalPoolFiles(), config.getJournalCompactPercentage(), bindingsFF, "activemq-bindings",
"bindings", 1, 0);
+      Journal localBindings = new JournalImpl(ioExecutors, 1024 * 1024, 2, config.getJournalCompactMinFiles(),
config.getJournalPoolFiles(), config.getJournalCompactPercentage(), config.getJournalFileOpenTimeout(),
bindingsFF, "activemq-bindings", "bindings", 1, 0);
 
       bindingsJournal = localBindings;
       originalBindingsJournal = localBindings;

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/333959dc/artemis-server/src/main/resources/schema/artemis-configuration.xsd
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/resources/schema/artemis-configuration.xsd b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
index 8bebdeb..b00298a 100644
--- a/artemis-server/src/main/resources/schema/artemis-configuration.xsd
+++ b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
@@ -688,6 +688,14 @@
             </xsd:annotation>
          </xsd:element>
 
+         <xsd:element name="journal-file-open-timeout" type="xsd:int" maxOccurs="1" minOccurs="0">
+            <xsd:annotation>
+               <xsd:documentation>
+                  the length of time to wait when opening a new Journal file before timing
out and failing
+               </xsd:documentation>
+            </xsd:annotation>
+         </xsd:element>
+
          <xsd:element name="server-dump-interval" type="xsd:long" default="-1" maxOccurs="1"
minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/333959dc/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
index ac63a05..ac054fc 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
@@ -93,6 +93,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
       Assert.assertEquals(10000, conf.getJournalBufferSize_NIO());
       Assert.assertEquals(1000, conf.getJournalBufferTimeout_NIO());
       Assert.assertEquals(56546, conf.getJournalMaxIO_NIO());
+      Assert.assertEquals(9876, conf.getJournalFileOpenTimeout());
 
       Assert.assertEquals(false, conf.isJournalSyncTransactional());
       Assert.assertEquals(true, conf.isJournalSyncNonTransactional());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/333959dc/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
index c621472..a701fb7 100644
--- a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
+++ b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
@@ -231,6 +231,7 @@
       <journal-compact-percentage>33</journal-compact-percentage>
       <journal-compact-min-files>123</journal-compact-min-files>
       <journal-max-io>56546</journal-max-io>
+      <journal-file-open-timeout>9876</journal-file-open-timeout>
       <perf-blast-pages>5</perf-blast-pages>
       <run-sync-speed-test>true</run-sync-speed-test>
       <server-dump-interval>5000</server-dump-interval>


Mime
View raw message