private void init()

in cassandra/src/main/java/org/apache/ignite/activestore/impl/cassandra/persistence/PublicKeyspacePersistenceSettings.java [328:379]


    private void init(String settings) {
        Document doc;
        try {
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder builder = factory.newDocumentBuilder();
            doc = builder.parse(new InputSource(new StringReader(settings)));
        }
        catch (Throwable e) {
            throw new IllegalArgumentException("Failed to parse general persistence settings:" +
                SystemHelper.LINE_SEPARATOR + settings, e);
        }
        Element root = doc.getDocumentElement();
        if (!PERSISTENCE_NODE.equals(root.getNodeName())) {
            throw new IllegalArgumentException("Incorrect general persistence settings specified. " +
                "Root XML element should be 'persistence'");
        }
        keyspace = root.hasAttribute(KEYSPACE_ATTR) ? root.getAttribute(KEYSPACE_ATTR).trim() : null;
        if (root.hasAttribute(TTL_ATTR)) {
            ttl = extractIntAttribute(root, TTL_ATTR);
        }
        if (!root.hasChildNodes()) {
            throw new IllegalArgumentException("Incorrect Cassandra general persistence settings specification, " +
                "there are no key and value persistence settings specified");
        }
        NodeList children = root.getChildNodes();
        int cnt = children.getLength();
        for (int i = 0; i < cnt; i++) {
            Node node = children.item(i);
            if (node.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            Element el = (Element)node;
            String nodeName = el.getNodeName();
            if (nodeName.equals(TABLE_OPTIONS_NODE)) {
                tblOptions = el.getTextContent();
                tblOptions = tblOptions.replace("\n", " ").replace("\r", "").replace("\t", " ");
            }
            else if (nodeName.equals(KEYSPACE_OPTIONS_NODE)) {
                keyspaceOptions = el.getTextContent();
                keyspaceOptions = keyspaceOptions.replace("\n", " ").replace("\r", "").replace("\t", " ");
            }
            else if (el.hasAttribute(SERIALIZER_ATTR)) {
                Object obj = newObjectInstance(el.getAttribute(SERIALIZER_ATTR).trim());
                if (!(obj instanceof Serializer)) {
                    throw new IllegalArgumentException("Incorrect configuration of Cassandra general persistence " +
                        "settings, serializer class '" + el.getAttribute(SERIALIZER_ATTR) + "' doesn't " +
                        "implement '" + Serializer.class.getName() + "' interface");
                }
                serializer = (Serializer)obj;
            }
        }
    }