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

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


The following commit(s) were added to refs/heads/master by this push:
     new 39fd58f  ARTEMIS-2258 The FileLockNodeManager directory should be 
configurable
     new 2a3ce34  This closes #2559
39fd58f is described below

commit 39fd58f71969678a0a9429aedad64d331be0ca3c
Author: Francesco Nigro <nigro....@gmail.com>
AuthorDate: Thu Feb 21 15:22:01 2019 +0100

    ARTEMIS-2258 The FileLockNodeManager directory should be configurable
---
 .../artemis/core/config/Configuration.java         | 10 +++++++
 .../core/config/impl/ConfigurationImpl.java        | 17 +++++++++++
 .../deployers/impl/FileConfigurationParser.java    |  2 ++
 .../core/server/impl/ActiveMQServerImpl.java       | 11 ++++++--
 .../resources/schema/artemis-configuration.xsd     |  8 ++++++
 .../core/config/impl/ConfigurationImplTest.java    | 22 +++++++++++++++
 .../src/test/resources/artemis-configuration.xsd   |  8 ++++++
 docs/user-manual/en/configuration-index.md         |  1 +
 docs/user-manual/en/persistence.md                 |  8 ++++++
 .../cluster/failover/NettyFailoverTest.java        | 33 ++++++++++++++++++----
 10 files changed, 113 insertions(+), 7 deletions(-)

diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
index 49c90fd..783adca 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/Configuration.java
@@ -597,6 +597,16 @@ public interface Configuration {
    File getJournalLocation();
 
    /**
+    * The location of the node manager lock file related to artemis.instance.
+    */
+   File getNodeManagerLockLocation();
+
+   /**
+    * Sets the file system directory used to store the node manager lock file.
+    */
+   Configuration setNodeManagerLockDirectory(String dir);
+
+   /**
     * Sets the file system directory used to store journal log.
     */
    Configuration setJournalDirectory(String dir);
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
index fa6ea63..7df8fb1 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImpl.java
@@ -183,6 +183,8 @@ public class ConfigurationImpl implements Configuration, 
Serializable {
 
    protected String journalDirectory = 
ActiveMQDefaultConfiguration.getDefaultJournalDir();
 
+   protected String nodeManagerLockDirectory = null;
+
    protected boolean createJournalDir = 
ActiveMQDefaultConfiguration.isDefaultCreateJournalDir();
 
    public JournalType journalType = ConfigurationImpl.DEFAULT_JOURNAL_TYPE;
@@ -819,6 +821,21 @@ public class ConfigurationImpl implements Configuration, 
Serializable {
    }
 
    @Override
+   public File getNodeManagerLockLocation() {
+      if (nodeManagerLockDirectory == null) {
+         return getJournalLocation();
+      } else {
+         return subFolder(nodeManagerLockDirectory);
+      }
+   }
+
+   @Override
+   public Configuration setNodeManagerLockDirectory(String dir) {
+      nodeManagerLockDirectory = dir;
+      return this;
+   }
+
+   @Override
    public JournalType getJournalType() {
       return journalType;
    }
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
index 1b6e3b8..0a838cb 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java
@@ -564,6 +564,8 @@ public final class FileConfigurationParser extends 
XMLConfigurationUtil {
 
       config.setJournalDirectory(getString(e, "journal-directory", 
config.getJournalDirectory(), Validators.NOT_NULL_OR_EMPTY));
 
+      config.setNodeManagerLockDirectory(getString(e, 
"node-manager-lock-directory", null, Validators.NO_CHECK));
+
       config.setPageMaxConcurrentIO(getInteger(e, "page-max-concurrent-io", 
config.getPageMaxConcurrentIO(), Validators.MINUS_ONE_OR_GT_ZERO));
 
       config.setPagingDirectory(getString(e, "paging-directory", 
config.getPagingDirectory(), Validators.NOT_NULL_OR_EMPTY));
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 6cf63ad..9480f58 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -549,7 +549,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
       try {
          checkJournalDirectory();
 
-         nodeManager = createNodeManager(configuration.getJournalLocation(), 
false);
+         nodeManager = 
createNodeManager(configuration.getNodeManagerLockLocation(), false);
 
          nodeManager.start();
 
@@ -758,7 +758,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
       if (nodeManager != null) {
          nodeManager.stop();
       }
-      nodeManager = createNodeManager(configuration.getJournalLocation(), 
true);
+      nodeManager = 
createNodeManager(configuration.getNodeManagerLockLocation(), true);
    }
 
    @Override
@@ -3362,6 +3362,13 @@ public class ActiveMQServerImpl implements 
ActiveMQServer {
             throw 
ActiveMQMessageBundle.BUNDLE.cannotCreateDir(journalDir.getAbsolutePath());
          }
       }
+
+      File nodeManagerLockDir = configuration.getNodeManagerLockLocation();
+      if (!journalDir.equals(nodeManagerLockDir)) {
+         if (configuration.isPersistenceEnabled() && 
!nodeManagerLockDir.exists()) {
+            nodeManagerLockDir.mkdirs();
+         }
+      }
    }
 
    // Inner classes
diff --git a/artemis-server/src/main/resources/schema/artemis-configuration.xsd 
b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
index 5a43596..89cdcc8 100644
--- a/artemis-server/src/main/resources/schema/artemis-configuration.xsd
+++ b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
@@ -624,6 +624,14 @@
             </xsd:annotation>
          </xsd:element>
 
+         <xsd:element name="node-manager-lock-directory" type="xsd:string" 
maxOccurs="1" minOccurs="0">
+            <xsd:annotation>
+               <xsd:documentation>
+                  the directory to store the node manager lock file
+               </xsd:documentation>
+            </xsd:annotation>
+         </xsd:element>
+
          <xsd:element name="create-journal-dir" type="xsd:boolean" 
default="true" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>
diff --git 
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
 
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
index ca28e35..8509450 100644
--- 
a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
+++ 
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/ConfigurationImplTest.java
@@ -86,6 +86,7 @@ public class ConfigurationImplTest extends ActiveMQTestBase {
       
Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultServerDumpInterval(),
 conf.getServerDumpInterval());
       
Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultMemoryWarningThreshold(),
 conf.getMemoryWarningThreshold());
       
Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultMemoryMeasureInterval(),
 conf.getMemoryMeasureInterval());
+      Assert.assertEquals(conf.getJournalLocation(), 
conf.getNodeManagerLockLocation());
    }
 
    @Test
@@ -498,6 +499,11 @@ public class ConfigurationImplTest extends 
ActiveMQTestBase {
          configuration.setJournalDirectory("./data-journal");
          File journalLocation = configuration.getJournalLocation();
          Assert.assertFalse("This path shouldn't resolve to a real folder", 
journalLocation.exists());
+         Assert.assertEquals(configuration.getJournalLocation(), 
configuration.getNodeManagerLockLocation());
+         
Assert.assertFalse(configuration.getNodeManagerLockLocation().exists());
+         configuration.setNodeManagerLockDirectory("./lock-folder");
+         Assert.assertNotEquals(configuration.getJournalLocation(), 
configuration.getNodeManagerLockLocation());
+         Assert.assertFalse("This path shouldn't resolve to a real folder", 
configuration.getNodeManagerLockLocation().exists());
       } finally {
          if (oldProperty == null) {
             System.clearProperty("artemis.instance");
@@ -531,6 +537,22 @@ public class ConfigurationImplTest extends 
ActiveMQTestBase {
          File journalLocation = configuration.getJournalLocation();
 
          Assert.assertTrue(journalLocation.exists());
+         Assert.assertEquals(configuration.getJournalLocation(), 
configuration.getNodeManagerLockLocation());
+         
Assert.assertTrue(configuration.getNodeManagerLockLocation().exists());
+
+         tempFolder = File.createTempFile("lock-folder", "");
+         tempFolder.delete();
+
+         tempFolder.getAbsolutePath();
+
+         tempFolder = new File(tempFolder.getAbsolutePath());
+         tempFolder.mkdirs();
+
+         System.out.println("TempFolder = " + tempFolder.getAbsolutePath());
+         
configuration.setNodeManagerLockDirectory(tempFolder.getAbsolutePath());
+         File lockLocation = configuration.getNodeManagerLockLocation();
+         Assert.assertTrue(lockLocation.exists());
+
       } finally {
          if (oldProperty == null) {
             System.clearProperty("artemis.instance");
diff --git a/artemis-tools/src/test/resources/artemis-configuration.xsd 
b/artemis-tools/src/test/resources/artemis-configuration.xsd
index 61bdd8b..5a5d4f3 100644
--- a/artemis-tools/src/test/resources/artemis-configuration.xsd
+++ b/artemis-tools/src/test/resources/artemis-configuration.xsd
@@ -597,6 +597,14 @@
             </xsd:annotation>
          </xsd:element>
 
+         <xsd:element name="node-manager-lock-directory" type="xsd:string" 
maxOccurs="1" minOccurs="0">
+            <xsd:annotation>
+               <xsd:documentation>
+                  the directory to store the node manager lock file
+               </xsd:documentation>
+            </xsd:annotation>
+         </xsd:element>
+
          <xsd:element name="create-journal-dir" type="xsd:boolean" 
default="true" maxOccurs="1" minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>
diff --git a/docs/user-manual/en/configuration-index.md 
b/docs/user-manual/en/configuration-index.md
index 6311f94..692b660 100644
--- a/docs/user-manual/en/configuration-index.md
+++ b/docs/user-manual/en/configuration-index.md
@@ -129,6 +129,7 @@ Name | Description | Default
 [journal-compact-min-files](persistence.md#configuring-the-message-journal) | 
The minimal number of data files before we can start compacting. Setting this 
to 0 means compacting is disabled. | 10
 [journal-compact-percentage](persistence.md#configuring-the-message-journal) | 
The percentage of live data on which we consider compacting the journal. | 30
 [journal-directory](persistence.md#configuring-the-message-journal) | the 
directory to store the journal files in. | `data/journal`
+[node-manager-lock-directory](persistence.md#configuring-the-message-journal) 
| the directory to store the node manager lock file. | same of 
`journal-directory`
 [journal-file-size](persistence.md#configuring-the-message-journal) | the size 
(in bytes) of each journal file. | 10MB
 
[journal-lock-acquisition-timeout](persistence.md#configuring-the-message-journal)
 | how long (in ms) to wait to acquire a file lock on the journal. | -1
 [journal-max-io](persistence.md#configuring-the-message-journal) | the maximum 
number of write requests that can be in the ASYNCIO queue at any one time. | 
4096 for ASYNCIO; 1 for NIO; ignored for MAPPED
diff --git a/docs/user-manual/en/persistence.md 
b/docs/user-manual/en/persistence.md
index 5b34898..c8994da 100644
--- a/docs/user-manual/en/persistence.md
+++ b/docs/user-manual/en/persistence.md
@@ -169,6 +169,14 @@ The message journal is configured using the following 
attributes in
   When the message journal is stored on a SAN we recommend each
   journal instance that is stored on the SAN is given its own LUN
   (logical unit).
+  
+- `node-manager-lock-directory`
+  
+   This is the directory in which the node manager file lock lives. By default
+   has the same value of `journal-directory`.
+   
+   This is useful when the message journal is on a SAN and is being used a 
[Shared Store HA](ha.md#shared-store)
+   policy with the broker instances on the same physical machine.
 
 - `create-journal-dir`
 
diff --git 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyFailoverTest.java
 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyFailoverTest.java
index b986e4e..88549db 100644
--- 
a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyFailoverTest.java
+++ 
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/failover/NettyFailoverTest.java
@@ -39,6 +39,7 @@ import 
org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfigur
 import 
org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
 import org.apache.activemq.artemis.core.server.NodeManager;
+import org.apache.activemq.artemis.core.server.impl.FileLockNodeManager;
 import org.apache.activemq.artemis.core.server.impl.InVMNodeManager;
 import org.apache.activemq.artemis.core.server.impl.jdbc.JdbcNodeManager;
 import 
org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer;
@@ -58,16 +59,22 @@ import org.junit.runners.Parameterized;
 public class NettyFailoverTest extends FailoverTest {
 
    public enum NodeManagerType {
-      InVM, Jdbc
+      InVM, Jdbc, File
    }
 
-   @Parameterized.Parameters(name = "{0} Node Manager")
+   @Parameterized.Parameters(name = "{0} Node Manager, Use Separate Lock 
Folder = {1}")
    public static Iterable<? extends Object> nodeManagerTypes() {
-      return Arrays.asList(new Object[][]{{NodeManagerType.Jdbc}, 
{NodeManagerType.InVM}});
+      return Arrays.asList(new Object[][]{
+         {NodeManagerType.Jdbc, false},
+         {NodeManagerType.InVM, false},
+         {NodeManagerType.File, false},
+         {NodeManagerType.File, true}});
    }
 
-   @Parameterized.Parameter
+   @Parameterized.Parameter(0)
    public NodeManagerType nodeManagerType;
+   @Parameterized.Parameter(1)
+   public boolean useSeparateLockFolder;
 
    @Override
    protected TransportConfiguration getAcceptorTransportConfiguration(final 
boolean live) {
@@ -89,6 +96,15 @@ public class NettyFailoverTest extends FailoverTest {
    }
 
    @Override
+   protected Configuration createDefaultInVMConfig() throws Exception {
+      final Configuration config = super.createDefaultInVMConfig();
+      if (useSeparateLockFolder) {
+         config.setNodeManagerLockDirectory(getTestDir() + "/nm_lock");
+      }
+      return config;
+   }
+
+   @Override
    protected NodeManager createNodeManager() throws Exception {
 
       switch (nodeManagerType) {
@@ -111,6 +127,13 @@ public class NettyFailoverTest extends FailoverTest {
                code.printStackTrace();
                Assert.fail(message);
             });
+         case File:
+            final Configuration config = createDefaultInVMConfig();
+            if (useSeparateLockFolder) {
+               config.getNodeManagerLockLocation().mkdirs();
+            }
+            return new 
FileLockNodeManager(config.getNodeManagerLockLocation(), false);
+
          default:
             throw new AssertionError("enum type not supported!");
       }
@@ -122,7 +145,7 @@ public class NettyFailoverTest extends FailoverTest {
       final boolean isBackup = config.getHAPolicyConfiguration() instanceof 
ReplicaPolicyConfiguration || config.getHAPolicyConfiguration() instanceof 
SharedStoreSlavePolicyConfiguration;
       NodeManager nodeManager = this.nodeManager;
       //create a separate NodeManager for the backup
-      if (isBackup && nodeManagerType == NodeManagerType.Jdbc) {
+      if (isBackup && (nodeManagerType == NodeManagerType.Jdbc || 
nodeManagerType == NodeManagerType.File)) {
          nodeManager = createNodeManager();
       }
       return new SameProcessActiveMQServer(createInVMFailoverServer(true, 
config, nodeManager, isBackup ? 2 : 1));

Reply via email to