use of com.hazelcast.config.PersistentMemoryConfig in project hazelcast by hazelcast.
the class AbstractDomConfigProcessor method fillNativeMemoryConfig.
protected void fillNativeMemoryConfig(Node node, NativeMemoryConfig nativeMemoryConfig) {
final Node enabledNode = getNamedItemNode(node, "enabled");
final boolean enabled = enabledNode != null && getBooleanValue(getTextContent(enabledNode).trim());
nativeMemoryConfig.setEnabled(enabled);
final Node allocTypeNode = getNamedItemNode(node, "allocator-type");
final String allocType = getTextContent(allocTypeNode);
if (allocType != null && !"".equals(allocType)) {
nativeMemoryConfig.setAllocatorType(NativeMemoryConfig.MemoryAllocatorType.valueOf(upperCaseInternal(allocType)));
}
for (Node n : childElements(node)) {
final String nodeName = cleanNodeName(n);
if (matches("size", nodeName)) {
nativeMemoryConfig.setSize(createMemorySize(n));
} else if (matches("min-block-size", nodeName)) {
String value = getTextContent(n);
nativeMemoryConfig.setMinBlockSize(Integer.parseInt(value));
} else if (matches("page-size", nodeName)) {
String value = getTextContent(n);
nativeMemoryConfig.setPageSize(Integer.parseInt(value));
} else if (matches("metadata-space-percentage", nodeName)) {
String value = getTextContent(n);
nativeMemoryConfig.setMetadataSpacePercentage(Float.parseFloat(value));
} else if (matches("persistent-memory-directory", nodeName)) {
PersistentMemoryConfig pmemConfig = nativeMemoryConfig.getPersistentMemoryConfig();
pmemConfig.addDirectoryConfig(new PersistentMemoryDirectoryConfig(getTextContent(n).trim()));
// we enable the persistent memory configuration for legacy reasons
pmemConfig.setEnabled(true);
} else if (matches("persistent-memory", nodeName)) {
handlePersistentMemoryConfig(nativeMemoryConfig.getPersistentMemoryConfig(), n);
}
}
}
use of com.hazelcast.config.PersistentMemoryConfig in project hazelcast by hazelcast.
the class YamlClientConfigBuilderTest method testPersistentMemoryConfiguration_SystemMemoryMode.
@Override
@Test
public void testPersistentMemoryConfiguration_SystemMemoryMode() {
String yaml = "" + "hazelcast-client:\n" + " native-memory:\n" + " persistent-memory:\n" + " mode: SYSTEM_MEMORY\n";
ClientConfig config = buildConfig(yaml);
PersistentMemoryConfig pmemConfig = config.getNativeMemoryConfig().getPersistentMemoryConfig();
assertEquals(SYSTEM_MEMORY, pmemConfig.getMode());
}
use of com.hazelcast.config.PersistentMemoryConfig in project hazelcast by hazelcast.
the class XmlClientConfigBuilderTest method testPersistentMemoryConfiguration_SystemMemoryMode.
@Override
@Test
public void testPersistentMemoryConfiguration_SystemMemoryMode() {
String xml = HAZELCAST_CLIENT_START_TAG + "<native-memory>\n" + " <persistent-memory enabled=\"true\" mode=\"SYSTEM_MEMORY\" />\n" + "</native-memory>\n" + HAZELCAST_CLIENT_END_TAG;
ClientConfig config = buildConfig(xml);
PersistentMemoryConfig pmemConfig = config.getNativeMemoryConfig().getPersistentMemoryConfig();
assertTrue(pmemConfig.isEnabled());
assertEquals(SYSTEM_MEMORY, pmemConfig.getMode());
}
use of com.hazelcast.config.PersistentMemoryConfig in project hazelcast by hazelcast.
the class XmlClientConfigBuilderTest method testPersistentMemoryDirectoryConfiguration_simpleAndAdvancedPasses.
@Override
@Test
public void testPersistentMemoryDirectoryConfiguration_simpleAndAdvancedPasses() {
String xml = HAZELCAST_CLIENT_START_TAG + "<native-memory>\n" + " <persistent-memory-directory>/mnt/optane</persistent-memory-directory>\n" + " <persistent-memory enabled=\"false\">\n" + " <directories>\n" + " <directory>/mnt/pmem0</directory>\n" + " <directory>/mnt/pmem1</directory>\n" + " </directories>\n" + " </persistent-memory>\n" + "</native-memory>\n" + HAZELCAST_CLIENT_END_TAG;
ClientConfig config = buildConfig(xml);
PersistentMemoryConfig pmemConfig = config.getNativeMemoryConfig().getPersistentMemoryConfig();
assertFalse(pmemConfig.isEnabled());
assertEquals(MOUNTED, pmemConfig.getMode());
List<PersistentMemoryDirectoryConfig> directoryConfigs = pmemConfig.getDirectoryConfigs();
assertEquals(3, directoryConfigs.size());
PersistentMemoryDirectoryConfig dir0Config = directoryConfigs.get(0);
PersistentMemoryDirectoryConfig dir1Config = directoryConfigs.get(1);
PersistentMemoryDirectoryConfig dir2Config = directoryConfigs.get(2);
assertEquals("/mnt/optane", dir0Config.getDirectory());
assertFalse(dir0Config.isNumaNodeSet());
assertEquals("/mnt/pmem0", dir1Config.getDirectory());
assertFalse(dir1Config.isNumaNodeSet());
assertEquals("/mnt/pmem1", dir2Config.getDirectory());
assertFalse(dir2Config.isNumaNodeSet());
}
use of com.hazelcast.config.PersistentMemoryConfig in project hazelcast by hazelcast.
the class YamlClientConfigBuilderTest method testPersistentMemoryDirectoryConfiguration_simpleAndAdvancedPasses.
@Override
@Test
public void testPersistentMemoryDirectoryConfiguration_simpleAndAdvancedPasses() {
String yaml = "" + "hazelcast-client:\n" + " native-memory:\n" + " persistent-memory-directory: /mnt/optane\n" + " persistent-memory:\n" + " enabled: false\n" + " directories:\n" + " - directory: /mnt/pmem0\n" + " - directory: /mnt/pmem1\n";
ClientConfig config = buildConfig(yaml);
PersistentMemoryConfig pmemConfig = config.getNativeMemoryConfig().getPersistentMemoryConfig();
assertFalse(pmemConfig.isEnabled());
assertEquals(MOUNTED, pmemConfig.getMode());
List<PersistentMemoryDirectoryConfig> directoryConfigs = pmemConfig.getDirectoryConfigs();
assertEquals(3, directoryConfigs.size());
PersistentMemoryDirectoryConfig dir0Config = directoryConfigs.get(0);
PersistentMemoryDirectoryConfig dir1Config = directoryConfigs.get(1);
PersistentMemoryDirectoryConfig dir2Config = directoryConfigs.get(2);
assertEquals("/mnt/optane", dir0Config.getDirectory());
assertFalse(dir0Config.isNumaNodeSet());
assertEquals("/mnt/pmem0", dir1Config.getDirectory());
assertFalse(dir1Config.isNumaNodeSet());
assertEquals("/mnt/pmem1", dir2Config.getDirectory());
assertFalse(dir2Config.isNumaNodeSet());
}
Aggregations