Search in sources :

Example 1 with PersistentMemoryMode

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

the class AbstractDomConfigProcessor method handlePersistentMemoryConfig.

private void handlePersistentMemoryConfig(PersistentMemoryConfig persistentMemoryConfig, Node node) {
    Node enabledNode = getNamedItemNode(node, "enabled");
    if (enabledNode != null) {
        boolean enabled = getBooleanValue(getTextContent(enabledNode));
        persistentMemoryConfig.setEnabled(enabled);
    }
    final Node modeNode = getNamedItemNode(node, "mode");
    final String modeStr = getTextContent(modeNode);
    PersistentMemoryMode mode = PersistentMemoryMode.MOUNTED;
    if (!StringUtil.isNullOrEmptyAfterTrim(modeStr)) {
        try {
            mode = PersistentMemoryMode.valueOf(modeStr);
            persistentMemoryConfig.setMode(mode);
        } catch (Exception ex) {
            throw new InvalidConfigurationException("Invalid 'mode' for 'persistent-memory': " + modeStr);
        }
    }
    for (Node parent : childElements(node)) {
        final String nodeName = cleanNodeName(parent);
        if (matches("directories", nodeName)) {
            if (PersistentMemoryMode.SYSTEM_MEMORY == mode) {
                throw new InvalidConfigurationException("Directories for 'persistent-memory' should only be" + " defined if the 'mode' is set to '" + PersistentMemoryMode.MOUNTED.name() + "'");
            }
            for (Node dirNode : childElements(parent)) {
                handlePersistentMemoryDirectory(persistentMemoryConfig, dirNode);
            }
        }
    }
}
Also used : PersistentMemoryMode(com.hazelcast.config.PersistentMemoryMode) Node(org.w3c.dom.Node) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Aggregations

InvalidConfigurationException (com.hazelcast.config.InvalidConfigurationException)1 PersistentMemoryMode (com.hazelcast.config.PersistentMemoryMode)1 Node (org.w3c.dom.Node)1