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());
}
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);
}
}
}
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));
}
}
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));
}
}
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);
}
Aggregations