use of com.hazelcast.internal.yaml.YamlMapping in project hazelcast by hazelcast.
the class YamlDomChecker method check.
/**
* Performs {code @null} checks on the provided YAML node recursively.
*
* @param node The YAML node to check for {@code null}s
*/
public static void check(YamlNode node) {
if (node instanceof YamlMapping) {
for (YamlNameNodePair nodePair : ((YamlMapping) node).childrenPairs()) {
YamlNode child = nodePair.childNode();
if (child == null) {
String path = YamlUtil.constructPath(node, nodePair.nodeName());
reportNullEntryOnConcretePath(path);
}
check(nodePair.childNode());
}
} else if (node instanceof YamlSequence) {
for (YamlNode child : ((YamlSequence) node).children()) {
if (child == null) {
throw new InvalidConfigurationException("There is a null configuration entry under sequence " + node.path() + ". Please check if the provided YAML configuration is well-indented and no blocks started without " + "sub-nodes.");
}
check(child);
}
} else {
if (((YamlScalar) node).nodeValue() == null) {
reportNullEntryOnConcretePath(node.path());
}
}
}
use of com.hazelcast.internal.yaml.YamlMapping in project hazelcast by hazelcast.
the class YamlClientFailoverConfigBuilder method parseAndBuildConfig.
private void parseAndBuildConfig(ClientFailoverConfig config) throws Exception {
YamlMapping yamlRootNode;
try {
yamlRootNode = ((YamlMapping) YamlLoader.load(in));
} catch (Exception ex) {
throw new InvalidConfigurationException("Invalid YAML configuration", ex);
}
String configRoot = getConfigRoot();
YamlNode clientFailoverRoot = yamlRootNode.childAsMapping(configRoot);
if (clientFailoverRoot == null) {
clientFailoverRoot = yamlRootNode;
}
YamlDomChecker.check(clientFailoverRoot);
Node w3cRootNode = asW3cNode(clientFailoverRoot);
replaceVariables(w3cRootNode);
importDocuments(clientFailoverRoot);
if (shouldValidateTheSchema()) {
new YamlConfigSchemaValidator().validate(yamlRootNode);
}
new YamlClientFailoverDomConfigProcessor(true, config).buildConfig(w3cRootNode);
}
use of com.hazelcast.internal.yaml.YamlMapping in project hazelcast by hazelcast.
the class YamlMemberDomConfigProcessorTest method toNode.
private static Node toNode(String yaml) {
YamlMapping yamlRootNode = ((YamlMapping) YamlLoader.load(yaml));
YamlNode imdgRoot = yamlRootNode.childAsMapping(ConfigSections.HAZELCAST.getName());
if (imdgRoot == null) {
imdgRoot = yamlRootNode;
}
return asW3cNode(imdgRoot);
}
use of com.hazelcast.internal.yaml.YamlMapping in project hazelcast by hazelcast.
the class YamlConfigSchemaValidatorTest method validationExceptionIsWrapped.
@Test
public void validationExceptionIsWrapped() {
YamlMapping config = (YamlMapping) YamlDomBuilder.build(new HashMap<>());
YamlConfigSchemaValidator validator = new YamlConfigSchemaValidator();
try {
validator.validate(config);
fail("did not throw exception for invalid config");
} catch (SchemaViolationConfigurationException e) {
assertEquals("#", e.getKeywordLocation());
assertEquals("#", e.getInstanceLocation());
assertEquals("exactly one of [hazelcast], [hazelcast-client] and [hazelcast-client-failover] should be present in the" + " root schema document, 0 are present", e.getMessage());
}
}
Aggregations