ARTEMIS-2435 Configuration on device-block-size through CLI / broker.xml

This commit is contained in:
Clebert Suconic 2019-07-30 13:30:20 -04:00
parent 32a15284ca
commit 80190860cc
11 changed files with 57 additions and 1 deletions

View File

@ -266,10 +266,12 @@ public class Create extends InputAbstract {
@Option(name = "--no-fsync", description = "Disable usage of fdatasync (channel.force(false) from java nio) on the journal")
private boolean noJournalSync;
@Option(name = "--device-block-size", description = "The block size by the device, default at 4096.")
private int journalDeviceBlockSize = 4096;
@Option(name = "--global-max-size", description = "Maximum amount of memory which message data may consume (Default: Undefined, half of the system's memory)")
private String globalMaxSize;
@Option(name = "--jdbc", description = "It will activate jdbc")
boolean jdbc;
@ -548,6 +550,14 @@ public class Create extends InputAbstract {
HashMap<String, String> filters = new LinkedHashMap<>();
if (journalDeviceBlockSize % 512 != 0) {
// This will generate a CLI error
// no need to a logger here as this would be just a regular UI output
throw new IllegalArgumentException("You must pass a device-block-size multiple of 512");
}
filters.put("${device-block-size}", Integer.toString(journalDeviceBlockSize));
filters.put("${master-slave}", isSlave() ? "slave" : "master");
filters.put("${failover-on-shutdown}", isFailoverOnShutodwn() ? "true" : "false");

View File

@ -52,6 +52,8 @@ ${jdbc}
<journal-pool-files>10</journal-pool-files>
<journal-device-block-size>${device-block-size}</journal-device-block-size>
<journal-file-size>10M</journal-file-size>
${journal-buffer.settings}${ping-config.settings}${connector-config.settings}

View File

@ -735,6 +735,17 @@ public interface Configuration {
*/
Configuration setJournalBufferTimeout_AIO(int journalBufferTimeout);
/** This is the device block size used on writing.
* This is usually translated as st_blksize from fstat.
* returning null mans the system should instead make a call on fstat and use st_blksize.
* The intention of this setting was to bypass the value in certain devices that will return a huge number as their block size (e.g. CephFS) */
Integer getJournalDeviceBlockSize();
/**
* @see #getJournalDeviceBlockSize()
*/
Configuration setJournalDeviceBlockSize(Integer deviceBlockSize);
/**
* Returns the buffer size (in bytes) for AIO.
* <br>

View File

@ -212,6 +212,8 @@ public class ConfigurationImpl implements Configuration, Serializable {
protected int journalBufferTimeout_AIO = ActiveMQDefaultConfiguration.getDefaultJournalBufferTimeoutAio();
protected Integer deviceBlockSize = null;
protected int journalBufferSize_AIO = ActiveMQDefaultConfiguration.getDefaultJournalBufferSizeAio();
protected int journalMaxIO_NIO = ActiveMQDefaultConfiguration.getDefaultJournalMaxIoNio();
@ -1288,6 +1290,17 @@ public class ConfigurationImpl implements Configuration, Serializable {
return journalBufferTimeout_AIO;
}
@Override
public Integer getJournalDeviceBlockSize() {
return deviceBlockSize;
}
@Override
public ConfigurationImpl setJournalDeviceBlockSize(Integer deviceBlockSize) {
this.deviceBlockSize = deviceBlockSize;
return this;
}
@Override
public ConfigurationImpl setJournalBufferTimeout_AIO(final int journalBufferTimeout) {
journalBufferTimeout_AIO = journalBufferTimeout;

View File

@ -605,6 +605,8 @@ public final class FileConfigurationParser extends XMLConfigurationUtil {
int journalMaxIO = getInteger(e, "journal-max-io", config.getJournalType() == JournalType.ASYNCIO ? ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio() : ActiveMQDefaultConfiguration.getDefaultJournalMaxIoNio(), Validators.GT_ZERO);
config.setJournalDeviceBlockSize(getInteger(e, "journal-device-block-size", null, Validators.MINUS_ONE_OR_GE_ZERO));
if (config.getJournalType() == JournalType.ASYNCIO) {
config.setJournalBufferTimeout_AIO(journalBufferTimeout);
config.setJournalBufferSize_AIO(journalBufferSize);

View File

@ -148,6 +148,10 @@ public class JournalStorageManager extends AbstractJournalStorageManager {
ActiveMQServerLogger.LOGGER.journalUseAIO();
}
journalFF = new AIOSequentialFileFactory(config.getJournalLocation(), config.getJournalBufferSize_AIO(), config.getJournalBufferTimeout_AIO(), config.getJournalMaxIO_AIO(), config.isLogJournalWriteRate(), criticalErrorListener, getCriticalAnalyzer());
if (config.getJournalDeviceBlockSize() != null) {
journalFF.setAlignment(config.getJournalDeviceBlockSize());
}
break;
case MAPPED:
if (criticalErrorListener != null) {

View File

@ -673,6 +673,16 @@
</xsd:annotation>
</xsd:element>
<xsd:element name="journal-device-block-size" type="xsd:long" maxOccurs="1" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
The size in bytes used by the device. This is usually translated as fstat/st_blksize
And this is a way to bypass the value returned as st_blksize.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="journal-buffer-size" type="xsd:string" default="501760" maxOccurs="1" minOccurs="0">
<xsd:annotation>
<xsd:documentation>

View File

@ -87,6 +87,7 @@ public class ConfigurationImplTest extends ActiveMQTestBase {
Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultMemoryWarningThreshold(), conf.getMemoryWarningThreshold());
Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultMemoryMeasureInterval(), conf.getMemoryMeasureInterval());
Assert.assertEquals(conf.getJournalLocation(), conf.getNodeManagerLockLocation());
Assert.assertNull(conf.getJournalDeviceBlockSize());
}
@Test

View File

@ -117,6 +117,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
Assert.assertEquals(25000, conf.getAddressQueueScanPeriod());
Assert.assertEquals(127, conf.getIDCacheSize());
Assert.assertEquals(true, conf.isPersistIDCache());
Assert.assertEquals(Integer.valueOf(777), conf.getJournalDeviceBlockSize());
Assert.assertEquals(true, conf.isPersistDeliveryCountBeforeDelivery());
Assert.assertEquals("pagingdir", conf.getPagingDirectory());
Assert.assertEquals("somedir", conf.getBindingsDirectory());

View File

@ -356,6 +356,7 @@
<journal-compact-min-files>123</journal-compact-min-files>
<journal-max-io>56546</journal-max-io>
<journal-file-open-timeout>9876</journal-file-open-timeout>
<journal-device-block-size>777</journal-device-block-size>
<server-dump-interval>5000</server-dump-interval>
<memory-warning-threshold>95</memory-warning-threshold>
<memory-measure-interval>54321</memory-measure-interval>

View File

@ -270,6 +270,7 @@
<journal-compact-min-files>123</journal-compact-min-files>
<journal-max-io>56546</journal-max-io>
<journal-file-open-timeout>9876</journal-file-open-timeout>
<journal-device-block-size>777</journal-device-block-size>
<server-dump-interval>5000</server-dump-interval>
<memory-warning-threshold>95</memory-warning-threshold>
<memory-measure-interval>54321</memory-measure-interval>