Search in sources :

Example 1 with PersistentMemoryDirectoryConfig

use of com.hazelcast.config.PersistentMemoryDirectoryConfig in project hazelcast by hazelcast.

the class TestFullApplicationContext method testNativeMemoryConfig.

@Test
public void testNativeMemoryConfig() {
    NativeMemoryConfig nativeMemoryConfig = config.getNativeMemoryConfig();
    assertFalse(nativeMemoryConfig.isEnabled());
    assertEquals(MemoryUnit.GIGABYTES, nativeMemoryConfig.getSize().getUnit());
    assertEquals(256, nativeMemoryConfig.getSize().getValue());
    assertEquals(20, nativeMemoryConfig.getPageSize());
    assertEquals(NativeMemoryConfig.MemoryAllocatorType.STANDARD, nativeMemoryConfig.getAllocatorType());
    assertEquals(10.2, nativeMemoryConfig.getMetadataSpacePercentage(), 0.1);
    assertEquals(10, nativeMemoryConfig.getMinBlockSize());
    List<PersistentMemoryDirectoryConfig> directoryConfigs = nativeMemoryConfig.getPersistentMemoryConfig().getDirectoryConfigs();
    assertEquals(2, directoryConfigs.size());
    assertEquals("/mnt/pmem0", directoryConfigs.get(0).getDirectory());
    assertEquals(0, directoryConfigs.get(0).getNumaNode());
    assertEquals("/mnt/pmem1", directoryConfigs.get(1).getDirectory());
    assertEquals(1, directoryConfigs.get(1).getNumaNode());
}
Also used : NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) PersistentMemoryDirectoryConfig(com.hazelcast.config.PersistentMemoryDirectoryConfig) Test(org.junit.Test) QuickTest(com.hazelcast.test.annotation.QuickTest)

Example 2 with PersistentMemoryDirectoryConfig

use of com.hazelcast.config.PersistentMemoryDirectoryConfig 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 3 with PersistentMemoryDirectoryConfig

use of com.hazelcast.config.PersistentMemoryDirectoryConfig in project hazelcast by hazelcast.

the class AbstractDomConfigProcessor method handlePersistentMemoryDirectory.

protected void handlePersistentMemoryDirectory(PersistentMemoryConfig persistentMemoryConfig, Node dirNode) {
    final String childNodeName = cleanNodeName(dirNode);
    if (matches("directory", childNodeName)) {
        Node numaNodeIdNode = getNamedItemNode(dirNode, "numa-node");
        int numaNodeId = numaNodeIdNode != null ? getIntegerValue("numa-node", getTextContent(numaNodeIdNode)) : -1;
        String directory = getTextContent(dirNode).trim();
        persistentMemoryConfig.addDirectoryConfig(new PersistentMemoryDirectoryConfig(directory, numaNodeId));
    }
}
Also used : Node(org.w3c.dom.Node) PersistentMemoryDirectoryConfig(com.hazelcast.config.PersistentMemoryDirectoryConfig)

Example 4 with PersistentMemoryDirectoryConfig

use of com.hazelcast.config.PersistentMemoryDirectoryConfig in project hazelcast by hazelcast.

the class YamlClientDomConfigProcessor method handlePersistentMemoryDirectory.

@Override
protected void handlePersistentMemoryDirectory(PersistentMemoryConfig persistentMemoryConfig, Node dirNode) {
    String directory = getTextContent(getNamedItemNode(dirNode, "directory"));
    String numaNodeIdStr = getTextContent(getNamedItemNode(dirNode, "numa-node"));
    if (!StringUtil.isNullOrEmptyAfterTrim(numaNodeIdStr)) {
        int numaNodeId = getIntegerValue("numa-node", numaNodeIdStr);
        persistentMemoryConfig.addDirectoryConfig(new PersistentMemoryDirectoryConfig(directory, numaNodeId));
    } else {
        persistentMemoryConfig.addDirectoryConfig(new PersistentMemoryDirectoryConfig(directory));
    }
}
Also used : PersistentMemoryDirectoryConfig(com.hazelcast.config.PersistentMemoryDirectoryConfig)

Example 5 with PersistentMemoryDirectoryConfig

use of com.hazelcast.config.PersistentMemoryDirectoryConfig in project hazelcast by hazelcast.

the class ClientConfigXmlGeneratorTest method nativeMemoryWithPersistentMemory.

@Test
public void nativeMemoryWithPersistentMemory() {
    NativeMemoryConfig expected = new NativeMemoryConfig();
    expected.setEnabled(true).setAllocatorType(MemoryAllocatorType.STANDARD).setMetadataSpacePercentage(70).setMinBlockSize(randomInt()).setPageSize(randomInt()).setSize(new MemorySize(randomInt(), MemoryUnit.BYTES)).getPersistentMemoryConfig().setEnabled(true).addDirectoryConfig(new PersistentMemoryDirectoryConfig("/mnt/pmem0", 0)).addDirectoryConfig(new PersistentMemoryDirectoryConfig("/mnt/pmem1", 1));
    clientConfig.setNativeMemoryConfig(expected);
    NativeMemoryConfig actual = newConfigViaGenerator().getNativeMemoryConfig();
    assertEquals(clientConfig.getNativeMemoryConfig(), actual);
}
Also used : NativeMemoryConfig(com.hazelcast.config.NativeMemoryConfig) MemorySize(com.hazelcast.memory.MemorySize) PersistentMemoryDirectoryConfig(com.hazelcast.config.PersistentMemoryDirectoryConfig) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

PersistentMemoryDirectoryConfig (com.hazelcast.config.PersistentMemoryDirectoryConfig)14 QuickTest (com.hazelcast.test.annotation.QuickTest)9 Test (org.junit.Test)9 PersistentMemoryConfig (com.hazelcast.config.PersistentMemoryConfig)7 NativeMemoryConfig (com.hazelcast.config.NativeMemoryConfig)3 XMLConfigBuilderTest (com.hazelcast.config.XMLConfigBuilderTest)3 YamlConfigBuilderTest (com.hazelcast.config.YamlConfigBuilderTest)3 Node (org.w3c.dom.Node)2 MemorySize (com.hazelcast.memory.MemorySize)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1