Search in sources :

Example 1 with PersistentMemoryConfig

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);
        }
    }
}
Also used : PersistentMemoryConfig(com.hazelcast.config.PersistentMemoryConfig) Node(org.w3c.dom.Node) PersistentMemoryDirectoryConfig(com.hazelcast.config.PersistentMemoryDirectoryConfig)

Example 2 with PersistentMemoryConfig

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());
}
Also used : PersistentMemoryConfig(com.hazelcast.config.PersistentMemoryConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) YamlConfigBuilderTest(com.hazelcast.config.YamlConfigBuilderTest) Test(org.junit.Test)

Example 3 with PersistentMemoryConfig

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());
}
Also used : PersistentMemoryConfig(com.hazelcast.config.PersistentMemoryConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) XMLConfigBuilderTest(com.hazelcast.config.XMLConfigBuilderTest) Test(org.junit.Test)

Example 4 with PersistentMemoryConfig

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());
}
Also used : PersistentMemoryConfig(com.hazelcast.config.PersistentMemoryConfig) PersistentMemoryDirectoryConfig(com.hazelcast.config.PersistentMemoryDirectoryConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) XMLConfigBuilderTest(com.hazelcast.config.XMLConfigBuilderTest) Test(org.junit.Test)

Example 5 with PersistentMemoryConfig

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());
}
Also used : PersistentMemoryConfig(com.hazelcast.config.PersistentMemoryConfig) PersistentMemoryDirectoryConfig(com.hazelcast.config.PersistentMemoryDirectoryConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) YamlConfigBuilderTest(com.hazelcast.config.YamlConfigBuilderTest) Test(org.junit.Test)

Aggregations

PersistentMemoryConfig (com.hazelcast.config.PersistentMemoryConfig)10 QuickTest (com.hazelcast.test.annotation.QuickTest)8 Test (org.junit.Test)8 PersistentMemoryDirectoryConfig (com.hazelcast.config.PersistentMemoryDirectoryConfig)7 XMLConfigBuilderTest (com.hazelcast.config.XMLConfigBuilderTest)3 YamlConfigBuilderTest (com.hazelcast.config.YamlConfigBuilderTest)3 NativeMemoryConfig (com.hazelcast.config.NativeMemoryConfig)2 Node (org.w3c.dom.Node)1