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:21 UTC

[1/2] activemq-artemis git commit: ARTEMIS-2014 Treat inability to create directory for paging as critial

Repository: activemq-artemis
Updated Branches:
  refs/heads/master 2eb1a526f -> 44d4fea65


ARTEMIS-2014 Treat inability to create directory for paging as critial


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/0ae7d325
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/0ae7d325
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/0ae7d325

Branch: refs/heads/master
Commit: 0ae7d32532dce9980bab5031d99314c7f66c56f0
Parents: 2eb1a52
Author: Justin Bertram <jb...@apache.org>
Authored: Tue Aug 7 10:51:56 2018 -0500
Committer: Justin Bertram <jb...@apache.org>
Committed: Tue Aug 7 11:09:46 2018 -0500

----------------------------------------------------------------------
 .../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/0ae7d325/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/0ae7d325/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
     */


[2/2] activemq-artemis git commit: This closes #2222

Posted by cl...@apache.org.
This closes #2222


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/44d4fea6
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/44d4fea6
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/44d4fea6

Branch: refs/heads/master
Commit: 44d4fea65cd39abce65052bd625fad3b3b5dcf05
Parents: 2eb1a52 0ae7d32
Author: Clebert Suconic <cl...@apache.org>
Authored: Tue Aug 7 12:26:13 2018 -0400
Committer: Clebert Suconic <cl...@apache.org>
Committed: Tue Aug 7 12:26:13 2018 -0400

----------------------------------------------------------------------
 .../core/io/AbstractSequentialFileFactory.java  |  6 +-
 .../tests/integration/paging/PagingTest.java    | 58 ++++++++++++++++++++
 2 files changed, 62 insertions(+), 2 deletions(-)
----------------------------------------------------------------------