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 14:48:55 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 37d1d5ff7 -> 902e0c49a


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/fbe27682
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/fbe27682
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/fbe27682

Branch: refs/heads/master
Commit: fbe27682a14ef5a30ec5ee5f925fca0f3842471e
Parents: 37d1d5f
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 10:48:09 2017 -0400

----------------------------------------------------------------------
 .../config/ActiveMQDefaultConfiguration.java    |  7 +++++
 .../journal/impl/JournalFilesRepository.java    | 10 ++++--
 .../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  | 14 +++++++--
 .../core/config/impl/FileConfigurationTest.java |  1 +
 .../resources/ConfigurationTest-full-config.xml |  1 +
 10 files changed, 84 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fbe27682/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 7ace35c..2ff6a0a 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
@@ -261,6 +261,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;
 
@@ -796,6 +799,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/fbe27682/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 c0a278d..488aa1f 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() {
@@ -103,7 +105,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");
       }
@@ -122,6 +125,7 @@ public class JournalFilesRepository {
       this.poolSize = poolSize;
       this.userVersion = userVersion;
       this.journal = journal;
+      this.journalFileOpenTimeout = journalFileOpenTimeout;
    }
 
    // Public --------------------------------------------------------
@@ -421,7 +425,7 @@ public class JournalFilesRepository {
 
          pushOpen();
 
-         nextFile = openedFiles.poll(5, TimeUnit.SECONDS);
+         nextFile = openedFiles.poll(journalFileOpenTimeout, TimeUnit.SECONDS);
       }
 
       if (openedFiles.isEmpty()) {
@@ -431,7 +435,7 @@ public class JournalFilesRepository {
 
       if (nextFile == null) {
 
-         logger.debug("Could not get a file in 5 seconds, it will retry directly, without
an executor");
+         logger.debug("Could not get a file in " + journalFileOpenTimeout + " seconds, it
will retry directly, without an executor");
          try {
             nextFile = takeFile(true, true, true, false);
          } catch (Exception e) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fbe27682/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 7e8320c..513ed03 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/fbe27682/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 9d5d4a8..6997443 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
@@ -646,6 +646,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/fbe27682/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 fb678b6..f0a6067 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
@@ -173,6 +173,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();
@@ -1146,6 +1148,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/fbe27682/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 a3d59f6..e06397d 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
@@ -561,6 +561,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/fbe27682/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 27fdc6f..803c441 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
@@ -120,7 +120,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/fbe27682/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 6af18bd..9021b70 100644
--- a/artemis-server/src/main/resources/schema/artemis-configuration.xsd
+++ b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
@@ -692,6 +692,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>
@@ -764,7 +772,7 @@
                   a list of security settings
                </xsd:documentation>
             </xsd:annotation>
-            
+
             <xsd:complexType>
                <xsd:sequence>
                   <xsd:choice>
@@ -862,7 +870,7 @@
                </xsd:sequence>
             </xsd:complexType>
          </xsd:element>
-         
+
          <xsd:element name="broker-plugins" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>
@@ -886,7 +894,7 @@
                            </xsd:annotation>
                         </xsd:attribute>
                      </xsd:complexType>
-                  </xsd:element>               
+                  </xsd:element>
                </xsd:sequence>
             </xsd:complexType>
          </xsd:element>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/fbe27682/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 28ad83e..1d1f53b 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
@@ -101,6 +101,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/fbe27682/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 ca10eb9..6526454 100644
--- a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
+++ b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
@@ -232,6 +232,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>
       <server-dump-interval>5000</server-dump-interval>
       <memory-warning-threshold>95</memory-warning-threshold>
       <memory-measure-interval>54321</memory-measure-interval>


Mime
View raw message