Search in sources :

Example 1 with YamlClientConfigBuilder

use of com.hazelcast.client.config.YamlClientConfigBuilder in project hazelcast by hazelcast.

the class HazelcastCommandLine method getClientConfig.

@SuppressFBWarnings(value = "DLS_DEAD_LOCAL_STORE", justification = "Generates false positive")
private ClientConfig getClientConfig(boolean retryClusterConnectForever) throws IOException {
    ClientConfig config;
    if (isYaml()) {
        config = new YamlClientConfigBuilder(this.config).build();
    } else if (isConfigFileNotNull()) {
        config = new XmlClientConfigBuilder(this.config).build();
    } else {
        config = ClientConfig.load();
    }
    if (targetsMixin.getTargets() != null) {
        config.getNetworkConfig().setAddresses(targetsMixin.getAddresses());
        config.setClusterName(targetsMixin.getClusterName());
    }
    if (retryClusterConnectForever) {
        final double expBackoffMultiplier = 1.25;
        final long clusterConnectTimeoutMillis = Long.MAX_VALUE;
        final int maxBackOffMillis = (int) SECONDS.toMillis(15);
        config.getConnectionStrategyConfig().getConnectionRetryConfig().setClusterConnectTimeoutMillis(clusterConnectTimeoutMillis).setMultiplier(expBackoffMultiplier).setMaxBackoffMillis(maxBackOffMillis);
    }
    return config;
}
Also used : YamlClientConfigBuilder(com.hazelcast.client.config.YamlClientConfigBuilder) XmlClientConfigBuilder(com.hazelcast.client.config.XmlClientConfigBuilder) ClientConfig(com.hazelcast.client.config.ClientConfig) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 2 with YamlClientConfigBuilder

use of com.hazelcast.client.config.YamlClientConfigBuilder in project hazelcast by hazelcast.

the class YamlClientFailoverDomConfigProcessor method handleClients.

@Override
protected void handleClients(Node node) {
    boolean clientConfigDefined = false;
    for (Node child : childElements(node)) {
        String clientPath = getTextContent(child);
        try {
            ClientConfig config = new YamlClientConfigBuilder(clientPath).build();
            clientFailoverConfig.addClientConfig(config);
            clientConfigDefined = true;
        } catch (IOException e) {
            throw new InvalidConfigurationException("Could not create the config from given path : " + clientPath, e);
        }
    }
    if (!clientConfigDefined) {
        String path = ((YamlElementAdapter) node).getYamlNode().path();
        throw new InvalidConfigurationException(String.format("At least one client configuration must be defined " + "under '%s'", path));
    }
}
Also used : YamlClientConfigBuilder(com.hazelcast.client.config.YamlClientConfigBuilder) Node(org.w3c.dom.Node) IOException(java.io.IOException) ClientConfig(com.hazelcast.client.config.ClientConfig) InvalidConfigurationException(com.hazelcast.config.InvalidConfigurationException)

Aggregations

ClientConfig (com.hazelcast.client.config.ClientConfig)2 YamlClientConfigBuilder (com.hazelcast.client.config.YamlClientConfigBuilder)2 XmlClientConfigBuilder (com.hazelcast.client.config.XmlClientConfigBuilder)1 InvalidConfigurationException (com.hazelcast.config.InvalidConfigurationException)1 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 IOException (java.io.IOException)1 Node (org.w3c.dom.Node)1