mirror of
https://github.com/apache/activemq-artemis.git
synced 2025-02-21 01:15:50 +00:00
ARTEMIS-2258 The FileLockNodeManager directory should be configurable
This commit is contained in:
parent
ed05bbf348
commit
39fd58f719
@ -596,6 +596,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.
|
||||
*/
|
||||
|
@ -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;
|
||||
@ -818,6 +820,21 @@ public class ConfigurationImpl implements Configuration, Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
@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;
|
||||
|
@ -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));
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
@ -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");
|
||||
|
@ -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>
|
||||
|
@ -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
|
||||
|
@ -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`
|
||||
|
||||
|
@ -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) {
|
||||
@ -88,6 +95,15 @@ public class NettyFailoverTest extends FailoverTest {
|
||||
return super.createReplicatedBackupNodeManager(backupConfig);
|
||||
}
|
||||
|
||||
@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 {
|
||||
|
||||
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user