Skip to content

Commit

Permalink
ARTEMIS-4543 Reverting to previous semantic on MappedSequentialFile
Browse files Browse the repository at this point in the history
  • Loading branch information
clebertsuconic committed Dec 20, 2023
1 parent a1add09 commit d8ac2d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.io.File;
import java.io.IOException;
import java.lang.invoke.MethodHandles;
import java.nio.ByteBuffer;
import java.util.List;

Expand All @@ -35,14 +34,9 @@
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;
Expand Down Expand Up @@ -255,7 +249,7 @@ private final class LocalBufferObserver implements TimedBufferObserver {

@Override
public boolean supportSync() {
return true;
return false;
}

@Override
Expand All @@ -277,7 +271,8 @@ public void flushBuffer(final ByteBuf byteBuf, final boolean requestedSync, fina
buffer.flip();
}
try {
blockingWriteDirect(buffer, false, releaseBuffer);
blockingWriteDirect(buffer, requestedSync, releaseBuffer);
IOCallback.done(callbacks);
} catch (Throwable t) {
final int code;
if (t instanceof IOException) {
Expand All @@ -288,20 +283,14 @@ public void flushBuffer(final ByteBuf byteBuf, final boolean requestedSync, fina
}
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
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;
Expand Down Expand Up @@ -172,7 +173,7 @@ public void testNIONoSync() throws Exception {
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);
}
Expand Down

0 comments on commit d8ac2d9

Please sign in to comment.