use of com.hazelcast.memory.MemoryUnit 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.MemoryUnit 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