use of com.hazelcast.memory.MemorySize in project hazelcast by hazelcast.
the class AbstractDomConfigProcessor method createMemorySize.
protected MemorySize createMemorySize(Node node) {
final String value = getTextContent(getNamedItemNode(node, "value"));
final MemoryUnit unit = MemoryUnit.valueOf(getTextContent(getNamedItemNode(node, "unit")));
return new MemorySize(Long.parseLong(value), unit);
}
use of com.hazelcast.memory.MemorySize 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);
}
use of com.hazelcast.memory.MemorySize in project hazelcast by hazelcast.
the class ClientConfigXmlGeneratorTest method nativeMemory.
@Test
public void nativeMemory() {
NativeMemoryConfig expected = new NativeMemoryConfig();
expected.setEnabled(true).setAllocatorType(MemoryAllocatorType.STANDARD).setMetadataSpacePercentage(70).setMinBlockSize(randomInt()).setPageSize(randomInt()).setSize(new MemorySize(randomInt(), MemoryUnit.BYTES));
clientConfig.setNativeMemoryConfig(expected);
NativeMemoryConfig actual = newConfigViaGenerator().getNativeMemoryConfig();
assertEquals(clientConfig.getNativeMemoryConfig(), actual);
}
use of com.hazelcast.memory.MemorySize in project hazelcast by hazelcast.
the class ClientConfigXmlGeneratorTest method nativeMemoryWithPersistentMemory_SystemMemoryMode.
@Test
public void nativeMemoryWithPersistentMemory_SystemMemoryMode() {
NativeMemoryConfig expected = new NativeMemoryConfig();
expected.setEnabled(true).setAllocatorType(MemoryAllocatorType.STANDARD).setMetadataSpacePercentage(70).setMinBlockSize(randomInt()).setPageSize(randomInt()).setSize(new MemorySize(randomInt(), MemoryUnit.BYTES)).getPersistentMemoryConfig().setMode(PersistentMemoryMode.SYSTEM_MEMORY);
clientConfig.setNativeMemoryConfig(expected);
NativeMemoryConfig actual = newConfigViaGenerator().getNativeMemoryConfig();
assertEquals(clientConfig.getNativeMemoryConfig(), actual);
}
use of com.hazelcast.memory.MemorySize in project hazelcast by hazelcast.
the class AbstractXmlConfigHelper method fillNativeMemoryConfig.
@SuppressFBWarnings("DM_BOXED_PRIMITIVE_FOR_PARSING")
protected void fillNativeMemoryConfig(Node node, NativeMemoryConfig nativeMemoryConfig) {
final NamedNodeMap atts = node.getAttributes();
final Node enabledNode = atts.getNamedItem("enabled");
final boolean enabled = enabledNode != null && getBooleanValue(getTextContent(enabledNode).trim());
nativeMemoryConfig.setEnabled(enabled);
final Node allocTypeNode = atts.getNamedItem("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 ("size".equals(nodeName)) {
final NamedNodeMap attrs = n.getAttributes();
final String value = getTextContent(attrs.getNamedItem("value"));
final MemoryUnit unit = MemoryUnit.valueOf(getTextContent(attrs.getNamedItem("unit")));
MemorySize memorySize = new MemorySize(Long.valueOf(value), unit);
nativeMemoryConfig.setSize(memorySize);
} else if ("min-block-size".equals(nodeName)) {
String value = getTextContent(n);
nativeMemoryConfig.setMinBlockSize(Integer.parseInt(value));
} else if ("page-size".equals(nodeName)) {
String value = getTextContent(n);
nativeMemoryConfig.setPageSize(Integer.parseInt(value));
} else if ("metadata-space-percentage".equals(nodeName)) {
String value = getTextContent(n);
try {
Number percentage = new DecimalFormat("##.#").parse(value);
nativeMemoryConfig.setMetadataSpacePercentage(percentage.floatValue());
} catch (ParseException e) {
LOGGER.info("Metadata space percentage, [" + value + "], is not a proper value. Default value will be used!");
}
}
}
}
Aggregations