osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GitHub] activemq-artemis pull request #2474: [ARTEMIS-1536]: Incorrect Journal files...


Github user franz1981 commented on a diff in the pull request:

    https://github.com/apache/activemq-artemis/pull/2474#discussion_r243190151
  
    --- Diff: artemis-server/src/main/java/org/apache/activemq/artemis/core/persistence/impl/journal/JournalStorageManager.java ---
    @@ -163,13 +163,17 @@ protected void init(Configuration config, IOCriticalErrorListener criticalErrorL
     
           int fileSize = config.getJournalFileSize();
           // we need to correct the file size if its not a multiple of the alignement
    -      int modulus = fileSize % journalFF.getAlignment();
    -      if (modulus != 0) {
    -         int difference = modulus;
    -         int low = config.getJournalFileSize() - difference;
    -         int high = low + journalFF.getAlignment();
    -         fileSize = difference < journalFF.getAlignment() / 2 ? low : high;
    -         ActiveMQServerLogger.LOGGER.invalidJournalFileSize(config.getJournalFileSize(), fileSize, journalFF.getAlignment());
    +      if (fileSize <= journalFF.getAlignment()) {
    --- End diff --
    
    If `alignment` is a power of 2 (and it should be right?) you can use:
    ```
       public static long align(final long value, final long alignment) {
          return (value + (alignment - 1)) & ~(alignment - 1);
       }
    ```
    That is into `BytesUtils::align`


---