You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2023/12/20 03:08:59 UTC

(activemq-artemis) branch main updated: ARTEMIS-4543 Reverting to previous semantic on MappedSequentialFile

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new d8ac2d99e0 ARTEMIS-4543 Reverting to previous semantic on MappedSequentialFile
d8ac2d99e0 is described below

commit d8ac2d99e0db0ea7e1377c478456b1fbae1c5902
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Tue Dec 19 21:48:12 2023 -0500

    ARTEMIS-4543 Reverting to previous semantic on MappedSequentialFile
---
 .../activemq/artemis/core/io/IOCallback.java       | 16 ++++++++-------
 .../core/io/mapped/TimedSequentialFile.java        | 23 ++++++----------------
 .../unit/core/journal/impl/BatchCommitTest.java    |  3 ++-
 3 files changed, 17 insertions(+), 25 deletions(-)

diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/IOCallback.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/IOCallback.java
index fe9a527d7b..8eed9d23a2 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/IOCallback.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/IOCallback.java
@@ -38,13 +38,15 @@ public interface IOCallback {
    void onError(int errorCode, String errorMessage);
 
    static void done(Collection<? extends IOCallback> delegates) {
-      delegates.forEach(callback -> {
-         try {
-            callback.done();
-         } catch (Throwable e) {
-            ActiveMQJournalLogger.LOGGER.errorCompletingCallback(e);
-         }
-      });
+      if (delegates != null) {
+         delegates.forEach(callback -> {
+            try {
+               callback.done();
+            } catch (Throwable e) {
+               ActiveMQJournalLogger.LOGGER.errorCompletingCallback(e);
+            }
+         });
+      }
    }
 
    static void onError(Collection<? extends IOCallback> delegates, int errorCode, final String errorMessage) {
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/TimedSequentialFile.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/TimedSequentialFile.java
index fa93e1c13b..78ce12f40c 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/TimedSequentialFile.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/mapped/TimedSequentialFile.java
@@ -18,7 +18,6 @@ package org.apache.activemq.artemis.core.io.mapped;
 
 import java.io.File;
 import java.io.IOException;
-import java.lang.invoke.MethodHandles;
 import java.nio.ByteBuffer;
 import java.util.List;
 
@@ -35,14 +34,9 @@ import org.apache.activemq.artemis.core.io.buffer.TimedBuffer;
 import org.apache.activemq.artemis.core.io.buffer.TimedBufferObserver;
 import org.apache.activemq.artemis.core.journal.EncodingSupport;
 import org.apache.activemq.artemis.core.journal.impl.SimpleWaitIOCallback;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 final class TimedSequentialFile implements SequentialFile {
 
-   private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
-
    private final SequentialFileFactory factory;
    private final SequentialFile sequentialFile;
    private final LocalBufferObserver observer;
@@ -255,7 +249,7 @@ final class TimedSequentialFile implements SequentialFile {
 
       @Override
       public boolean supportSync() {
-         return true;
+         return false;
       }
 
       @Override
@@ -277,7 +271,8 @@ final class TimedSequentialFile implements SequentialFile {
                buffer.flip();
             }
             try {
-               blockingWriteDirect(buffer, false, releaseBuffer);
+               blockingWriteDirect(buffer, requestedSync, releaseBuffer);
+               IOCallback.done(callbacks);
             } catch (Throwable t) {
                final int code;
                if (t instanceof IOException) {
@@ -288,20 +283,14 @@ final class TimedSequentialFile implements SequentialFile {
                }
                IOCallback.onError(callbacks, code, t.getMessage());
             }
+         } else {
+            IOCallback.done(callbacks);
          }
       }
 
       @Override
       public void checkSync(boolean syncRequested, List<IOCallback> callbacks) {
-         try {
-            sync();
-         } catch (Exception e) {
-            logger.warn(e.getMessage(), e);
-         } finally {
-            if (callbacks != null) {
-               callbacks.forEach(c -> c.done());
-            }
-         }
+         throw new UnsupportedOperationException("This method is not supported on mapped");
       }
 
       @Override
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/BatchCommitTest.java b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/BatchCommitTest.java
index 621d235da3..2e7786e7af 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/BatchCommitTest.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/core/journal/impl/BatchCommitTest.java
@@ -46,6 +46,7 @@ import org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory;
 import org.apache.activemq.artemis.utils.collections.ConcurrentHashSet;
 import org.junit.Assert;
 import org.junit.Assume;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -172,7 +173,7 @@ public class BatchCommitTest extends ActiveMQTestBase {
       internalTest(JournalType.NIO, "testRunNIO", false);
    }
 
-   @Test
+   @Ignore // TODO: We should fix Mapped eventually for this case
    public void testMapped() throws Exception {
       internalTest(JournalType.MAPPED, "testRunMapped", true);
    }