Search in sources :

Example 1 with YamlClientDomConfigProcessor

use of com.hazelcast.client.config.impl.YamlClientDomConfigProcessor in project hazelcast by hazelcast.

the class YamlClientConfigBuilder method parseAndBuildConfig.

private void parseAndBuildConfig(ClientConfig config) throws Exception {
    YamlMapping yamlRootNode;
    try {
        yamlRootNode = ((YamlMapping) YamlLoader.load(in));
    } catch (Exception ex) {
        throw new InvalidConfigurationException("Invalid YAML configuration", ex);
    }
    YamlNode clientRoot = yamlRootNode.childAsMapping(ClientConfigSections.HAZELCAST_CLIENT.getName());
    if (clientRoot == null) {
        clientRoot = yamlRootNode;
    }
    YamlDomChecker.check(clientRoot);
    Node w3cRootNode = asW3cNode(clientRoot);
    replaceVariables(w3cRootNode);
    importDocuments(clientRoot);
    if (shouldValidateTheSchema()) {
        new YamlConfigSchemaValidator().validate((YamlMapping) clientRoot.parent());
    }
    new YamlClientDomConfigProcessor(true, config).buildConfig(w3cRootNode);
}
Also used : YamlConfigSchemaValidator(com.hazelcast.internal.config.YamlConfigSchemaValidator) YamlNode(com.hazelcast.internal.yaml.YamlNode) W3cDomUtil.asW3cNode(com.hazelcast.internal.config.yaml.W3cDomUtil.asW3cNode) Node(org.w3c.dom.Node) YamlNode(com.hazelcast.internal.yaml.YamlNode) YamlMapping(com.hazelcast.internal.yaml.YamlMapping) YamlClientDomConfigProcessor(com.hazelcast.client.config.impl.YamlClientDomConfigProcessor) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException) IOException(java.io.IOException) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Example 2 with YamlClientDomConfigProcessor

use of com.hazelcast.client.config.impl.YamlClientDomConfigProcessor in project hazelcast by hazelcast.

the class ConfigNodeStateTrackerTest method shouldDetectUnappliedClientConfigEntries.

@Test
public void shouldDetectUnappliedClientConfigEntries() {
    Map<String, String> entries = new HashMap<>();
    entries.put("HZCLIENT_FOO", "foo");
    entries.put("HZCLIENT_NETWORK_SOCKETINTERCEPTOR_ENABLE", "true");
    entries.put("HZCLIENT_NETWORK_SMARTROUTING", "true");
    ConfigNode configNode = PropertiesToNodeConverter.propsToNode(EnvVariablesConfigParser.client().parse(entries));
    new YamlClientDomConfigProcessor(true, new ClientConfig(), false).buildConfig(new ConfigOverrideElementAdapter(configNode));
    Map<String, String> unprocessed = new ConfigNodeStateTracker().unprocessedNodes(configNode);
    assertTrue(unprocessed.containsKey("hazelcast-client.foo"));
    assertTrue(unprocessed.containsKey("hazelcast-client.network.socketinterceptor.enable"));
    assertFalse(unprocessed.containsKey("hazelcast-client.network.smartrouting"));
}
Also used : HashMap(java.util.HashMap) YamlClientDomConfigProcessor(com.hazelcast.client.config.impl.YamlClientDomConfigProcessor) ClientConfig(com.hazelcast.client.config.ClientConfig) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

YamlClientDomConfigProcessor (com.hazelcast.client.config.impl.YamlClientDomConfigProcessor)2 ClientConfig (com.hazelcast.client.config.ClientConfig)1 InvalidConfigurationException (com.hazelcast.config.InvalidConfigurationException)1 YamlConfigSchemaValidator (com.hazelcast.internal.config.YamlConfigSchemaValidator)1 W3cDomUtil.asW3cNode (com.hazelcast.internal.config.yaml.W3cDomUtil.asW3cNode)1 YamlMapping (com.hazelcast.internal.yaml.YamlMapping)1 YamlNode (com.hazelcast.internal.yaml.YamlNode)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 Node (org.w3c.dom.Node)1