activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From martyntay...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-716 max replication = 0 should mean do not make copies at all
Date Thu, 08 Sep 2016 16:17:26 GMT
ARTEMIS-716 max replication = 0 should mean do not make copies at all


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

Branch: refs/heads/master
Commit: 87d3c1c9bda5853093131b9c81e408a1dda3e543
Parents: bbb9620
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Wed Sep 7 11:12:20 2016 -0400
Committer: Martyn Taylor <mtaylor@redhat.com>
Committed: Thu Sep 8 17:17:04 2016 +0100

----------------------------------------------------------------------
 .../core/server/ActiveMQServerLogger.java       |  5 +++
 .../core/server/files/FileMoveManager.java      | 33 ++++++++++++++------
 .../core/server/files/FileMoveManagerTest.java  | 32 +++++++++++++++++--
 docs/user-manual/en/configuration-index.md      |  2 +-
 .../cluster/failover/FailoverTestBase.java      |  2 +-
 5 files changed, 61 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/87d3c1c9/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
index 7696c01..4ae5442 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
@@ -1136,6 +1136,11 @@ public interface ActiveMQServerLogger extends BasicLogger {
       format = Message.Format.MESSAGE_FORMAT)
    void activateSharedStoreSlaveFailed(@Cause Throwable e);
 
+   @LogMessage(level = Logger.Level.INFO)
+   @Message(id = 222190, value = "Deleting old data directory {0} as the max folders is set
to 0", format = Message.Format.MESSAGE_FORMAT)
+   void backupDeletingData(String oldPath);
+
+
    @LogMessage(level = Logger.Level.WARN)
    @Message(id = 222191,
       value = "Could not find any configured role for user {0}.",

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/87d3c1c9/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java
index 3e250f6..2cd5632 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/files/FileMoveManager.java
@@ -98,16 +98,26 @@ public class FileMoveManager {
 
       int whereToMove = getMaxID() + 1;
 
-      File folderTo = getFolder(whereToMove);
-      folderTo.mkdirs();
+      if (maxFolders == 0) {
+         ActiveMQServerLogger.LOGGER.backupDeletingData(folder.getPath());
+         for (String fileMove : files) {
+            File fileFrom = new File(folder, fileMove);
+            logger.tracef("deleting %s", fileFrom);
+            deleteTree(fileFrom);
+         }
+      }
+      else {
+         File folderTo = getFolder(whereToMove);
+         folderTo.mkdirs();
 
-      ActiveMQServerLogger.LOGGER.backupMovingDataAway(folder.getPath(), folderTo.getPath());
+         ActiveMQServerLogger.LOGGER.backupMovingDataAway(folder.getPath(), folderTo.getPath());
 
-      for (String fileMove : files) {
-         File fileFrom = new File(folder, fileMove);
-         File fileTo = new File(folderTo, fileMove);
-         logger.tracef("doMove:: moving %s as %s", fileFrom, fileTo);
-         Files.move(fileFrom.toPath(), fileTo.toPath());
+         for (String fileMove : files) {
+            File fileFrom = new File(folder, fileMove);
+            File fileTo = new File(folderTo, fileMove);
+            logger.tracef("doMove:: moving %s as %s", fileFrom, fileTo);
+            Files.move(fileFrom.toPath(), fileTo.toPath());
+         }
       }
 
    }
@@ -117,9 +127,14 @@ public class FileMoveManager {
    }
 
    private void internalCheckOldFolders(int creating) {
-      if (maxFolders > 0) {
+      if (maxFolders >= 0) {
          int folders = getNumberOfFolders();
 
+         if (folders == 0) {
+            // no folders.. nothing to be done
+            return;
+         }
+
          // We are counting the next one to be created
          int foldersToDelete = folders + creating - maxFolders;
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/87d3c1c9/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java
index 7353b47..299f0bc 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/server/files/FileMoveManagerTest.java
@@ -200,7 +200,7 @@ public class FileMoveManagerTest {
 
       Assert.assertEquals(manager.getMaxFolders(), manager.getNumberOfFolders());
 
-      manager.setMaxFolders(0).checkOldFolders();
+      manager.setMaxFolders(-1).checkOldFolders();
 
       Assert.assertEquals(3, manager.getNumberOfFolders());
 
@@ -255,7 +255,7 @@ public class FileMoveManagerTest {
 
       Assert.assertEquals(manager.getMaxFolders(), manager.getNumberOfFolders());
 
-      manager.setMaxFolders(0).checkOldFolders();
+      manager.setMaxFolders(-1).checkOldFolders();
 
       Assert.assertEquals(3, manager.getNumberOfFolders());
 
@@ -268,6 +268,34 @@ public class FileMoveManagerTest {
    }
 
    @Test
+   public void testMaxZero() throws Exception {
+      manager.setMaxFolders(0);
+
+      int NUMBER_OF_FOLDERS = 10;
+      int FILES_PER_FOLDER = 10;
+
+      for (int bkp = 1; bkp <= 10; bkp++) {
+         for (int f = 0; f < NUMBER_OF_FOLDERS; f++) {
+            File folderF = new File(dataLocation, "folder" + f);
+            folderF.mkdirs();
+
+            // FILES_PER_FOLDER + f, I'm just creating more files as f grows.
+            // this is just to make each folder unique somehow
+            for (int i = 0; i < FILES_PER_FOLDER + f; i++) {
+               createFile(folderF, i);
+            }
+         }
+
+         manager.doMove();
+
+         // We will always have maximum of 3 folders
+         Assert.assertEquals(0, manager.getNumberOfFolders());
+      }
+
+      Assert.assertEquals(0, manager.getMaxID());
+   }
+
+   @Test
    public void testMoveOverPaging() throws Exception {
       AssertionLoggerHandler.startCapture();
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/87d3c1c9/docs/user-manual/en/configuration-index.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/configuration-index.md b/docs/user-manual/en/configuration-index.md
index b9a49fb..c47861b 100644
--- a/docs/user-manual/en/configuration-index.md
+++ b/docs/user-manual/en/configuration-index.md
@@ -66,7 +66,7 @@ Name | Description
 [management-address](management.md "Configuring Core Management")   |  the name of the management
address to send management messages to. It is prefixed with "jms.queue" so that JMS clients
can send messages to it. Default=jms.queue.activemq.management
 [management-notification-address](management.md "Configuring The Core Management Notification
Address") |  the name of the address that consumers bind to receive management notifications.
Default=activemq.notifications
 [mask-password](configuration-index.md "Using Masked Passwords in Configuration Files") 
|  This option controls whether passwords in server configuration need be masked. If set to
"true" the passwords are masked. Default=false
-[max-saved-replicated-journals-size]()                                                  
             |    This specifies how many times a replicated backup server can restart after
moving its files on start. Once there are this number of backup journal files the server will
stop permanently after if fails back. Default=2
+[max-saved-replicated-journals-size](ha.md#data-replication)                            
                                   |    This specifies how many times a replicated backup
server can restart after moving its files on start. Once there are this number of backup journal
files the server will stop permanently after if fails back. -1 Means no Limit, 0 don't keep
a copy at all, Default=2
 [max-disk-usage](paging.md#max-disk-usage) | The max percentage of data we should use from
disks. The System will block while the disk is full. Default=100
 [memory-measure-interval](perf-tuning.md)                                               
             |  frequency to sample JVM memory in ms (or -1 to disable memory sampling). Default=-1
 [memory-warning-threshold](perf-tuning.md)                                              
             |  Percentage of available memory which will trigger a warning log. Default=25

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/87d3c1c9/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java
index 67123df..aa87b28 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/FailoverTestBase.java
@@ -191,7 +191,7 @@ public abstract class FailoverTestBase extends ActiveMQTestBase {
    }
 
    protected void setupHAPolicyConfiguration() {
-      ((ReplicaPolicyConfiguration) backupConfig.getHAPolicyConfiguration()).setMaxSavedReplicatedJournalsSize(0).setAllowFailBack(true);
+      ((ReplicaPolicyConfiguration) backupConfig.getHAPolicyConfiguration()).setMaxSavedReplicatedJournalsSize(-1).setAllowFailBack(true);
       ((ReplicaPolicyConfiguration) backupConfig.getHAPolicyConfiguration()).setRestartBackup(false);
    }
 


Mime
View raw message