/** * Creates a new {@link ClientConfiguration} instance from the given {@link ServiceConfiguration}, filling in * empty/absent configuration with the defaults specified as constants in this class. */ public static ClientConfiguration of(ServiceConfiguration config) { return ClientConfiguration.builder() .sslSocketFactory(SslSocketFactories.createSslSocketFactory(config.security())) .trustManager(SslSocketFactories.createX509TrustManager(config.security())) .uris(config.uris()) .connectTimeout(config.connectTimeout().orElse(DEFAULT_CONNECT_TIMEOUT)) .readTimeout(config.readTimeout().orElse(DEFAULT_READ_TIMEOUT)) .writeTimeout(config.writeTimeout().orElse(DEFAULT_WRITE_TIMEOUT)) .enableGcmCipherSuites(config.enableGcmCipherSuites().orElse(DEFAULT_ENABLE_GCM_CIPHERS)) .proxy(config.proxy().map(ClientConfigurations::createProxySelector).orElse(ProxySelector.getDefault())) .proxyCredentials(config.proxy().flatMap(ProxyConfiguration::credentials)) .meshProxy(meshProxy(config.proxy())) .maxNumRetries(config.maxNumRetries().orElse(DEFAULT_MAX_NUM_RETRIES)) .nodeSelectionStrategy(DEFAULT_NODE_SELECTION_STRATEGY) .failedUrlCooldown(DEFAULT_FAILED_URL_COOLDOWN) .backoffSlotSize(config.backoffSlotSize().orElse(DEFAULT_BACKOFF_SLOT_SIZE)) .build(); }
/** * Creates a new {@link ClientConfiguration} instance from the given SSL configuration and URIs, filling in all * other configuration with the defaults specified as constants in this class. */ public static ClientConfiguration of( List<String> uris, SSLSocketFactory sslSocketFactory, X509TrustManager trustManager) { return ClientConfiguration.builder() .sslSocketFactory(sslSocketFactory) .trustManager(trustManager) .uris(uris) .connectTimeout(DEFAULT_CONNECT_TIMEOUT) .readTimeout(DEFAULT_READ_TIMEOUT) .writeTimeout(DEFAULT_WRITE_TIMEOUT) .enableGcmCipherSuites(DEFAULT_ENABLE_GCM_CIPHERS) .proxy(ProxySelector.getDefault()) .proxyCredentials(Optional.empty()) .maxNumRetries(DEFAULT_MAX_NUM_RETRIES) .backoffSlotSize(DEFAULT_BACKOFF_SLOT_SIZE) .nodeSelectionStrategy(DEFAULT_NODE_SELECTION_STRATEGY) .failedUrlCooldown(DEFAULT_FAILED_URL_COOLDOWN) .build(); }