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 2018/08/07 16:26:42 UTC
activemq-artemis git commit: ARTEMIS-2014 Treat inability to create
directory for paging as critial
Repository: activemq-artemis
Updated Branches:
refs/heads/2.6.x e55549b94 -> 318fc6f44
ARTEMIS-2014 Treat inability to create directory for paging as critial
(cherry picked from commit 0ae7d32532dce9980bab5031d99314c7f66c56f0)
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/318fc6f4
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/318fc6f4
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/318fc6f4
Branch: refs/heads/2.6.x
Commit: 318fc6f4455bc91031785a1b5652e4a1746c5ac0
Parents: e55549b
Author: Justin Bertram <jb...@apache.org>
Authored: Tue Aug 7 10:51:56 2018 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Aug 7 12:26:36 2018 -0400
----------------------------------------------------------------------
.../core/io/AbstractSequentialFileFactory.java | 6 +-
.../tests/integration/paging/PagingTest.java | 58 ++++++++++++++++++++
2 files changed, 62 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/318fc6f4/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java
----------------------------------------------------------------------
diff --git a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java
index 5f191cf..482aaa2 100644
--- a/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java
+++ b/artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/AbstractSequentialFileFactory.java
@@ -224,8 +224,10 @@ public abstract class AbstractSequentialFileFactory implements SequentialFileFac
@Override
public void createDirs() throws Exception {
boolean ok = journalDir.mkdirs();
- if (!ok) {
- throw new IOException("Failed to create directory " + journalDir);
+ if (!ok && !journalDir.exists()) {
+ IOException e = new IOException("Unable to create directory: " + journalDir);
+ onIOError(e, e.getMessage(), null);
+ throw e;
}
}
http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/318fc6f4/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java
index 1436bea..71be960 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/paging/PagingTest.java
@@ -35,6 +35,7 @@ import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -96,6 +97,7 @@ import org.apache.activemq.artemis.utils.actors.ArtemisExecutor;
import org.jboss.logging.Logger;
import org.junit.After;
import org.junit.Assert;
+import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -1400,6 +1402,62 @@ public class PagingTest extends ActiveMQTestBase {
}
+ @Test
+ public void testInabilityToCreateDirectoryDuringPaging() throws Exception {
+ // this test only applies to file-based stores
+ Assume.assumeTrue(storeType == StoreConfiguration.StoreType.FILE);
+
+ clearDataRecreateServerDirs();
+
+ Configuration config = createDefaultInVMConfig().setJournalSyncNonTransactional(false).setPagingDirectory(UUID.randomUUID().toString());
+
+ server = createServer(true, config, PagingTest.PAGE_SIZE, PagingTest.PAGE_MAX);
+
+ server.start();
+
+ final int numberOfMessages = 100;
+
+ locator = createInVMNonHALocator().setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true);
+
+ sf = createSessionFactory(locator);
+
+ ClientSession session = sf.createSession(false, true, true);
+
+ session.createQueue(PagingTest.ADDRESS, RoutingType.MULTICAST, PagingTest.ADDRESS, null, true);
+
+ ClientProducer producer = session.createProducer(PagingTest.ADDRESS);
+
+ ClientMessage message = null;
+
+ byte[] body = new byte[MESSAGE_SIZE];
+
+ ByteBuffer bb = ByteBuffer.wrap(body);
+
+ for (int j = 1; j <= MESSAGE_SIZE; j++) {
+ bb.put(getSamplebyte(j));
+ }
+
+ for (int i = 0; i < numberOfMessages; i++) {
+ message = session.createMessage(true);
+
+ ActiveMQBuffer bodyLocal = message.getBodyBuffer();
+
+ bodyLocal.writeBytes(body);
+
+ message.putIntProperty(new SimpleString("id"), i);
+
+ try {
+ producer.send(message);
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ assertTrue(Wait.waitFor(() -> server.getState() == ActiveMQServer.SERVER_STATE.STOPPED, 5000, 200));
+ session.close();
+ sf.close();
+ locator.close();
+ }
+
/**
* This test will remove all the page directories during a restart, simulating a crash scenario. The server should still start after this
*/