use of org.infinispan.client.hotrod.impl.HotRodURI in project infinispan by infinispan.
the class ConfigurationBuilder method withProperties.
@Override
public ConfigurationBuilder withProperties(Properties properties) {
TypedProperties typed = TypedProperties.toTypedProperties(properties);
if (typed.containsKey(ConfigurationProperties.URI)) {
HotRodURI uri = HotRodURI.create(typed.getProperty(ConfigurationProperties.URI));
this.read(uri.toConfigurationBuilder().build());
}
if (typed.containsKey(ConfigurationProperties.ASYNC_EXECUTOR_FACTORY)) {
this.asyncExecutorFactory().factoryClass(typed.getProperty(ConfigurationProperties.ASYNC_EXECUTOR_FACTORY, null, true));
}
this.asyncExecutorFactory().withExecutorProperties(typed);
String balancingStrategyClass = typed.getProperty(ConfigurationProperties.REQUEST_BALANCING_STRATEGY, null, true);
if (balancingStrategyClass != null) {
this.balancingStrategy(balancingStrategyClass);
}
if (typed.containsKey(ConfigurationProperties.CLIENT_INTELLIGENCE)) {
this.clientIntelligence(typed.getEnumProperty(ConfigurationProperties.CLIENT_INTELLIGENCE, ClientIntelligence.class, ClientIntelligence.getDefault(), true));
}
this.connectionPool.withPoolProperties(typed);
if (typed.containsKey(ConfigurationProperties.CONNECT_TIMEOUT)) {
this.connectionTimeout(typed.getIntProperty(ConfigurationProperties.CONNECT_TIMEOUT, connectionTimeout, true));
}
if (typed.containsKey(ConfigurationProperties.HASH_FUNCTION_PREFIX + ".1")) {
log.warn("Hash function version 1 is no longer supported");
}
for (int i = 0; i < consistentHashImpl.length; i++) {
if (consistentHashImpl[i] != null) {
int version = i + 1;
String hashClassName = typed.getProperty(ConfigurationProperties.HASH_FUNCTION_PREFIX + "." + version, null, true);
if (hashClassName != null) {
this.consistentHashImpl(version, hashClassName);
}
}
}
if (typed.containsKey(ConfigurationProperties.FORCE_RETURN_VALUES)) {
this.forceReturnValues(typed.getBooleanProperty(ConfigurationProperties.FORCE_RETURN_VALUES, forceReturnValues, true));
}
if (typed.containsKey(ConfigurationProperties.KEY_SIZE_ESTIMATE)) {
this.keySizeEstimate(typed.getIntProperty(ConfigurationProperties.KEY_SIZE_ESTIMATE, keySizeEstimate, true));
}
if (typed.containsKey(ConfigurationProperties.MARSHALLER)) {
this.marshaller(typed.getProperty(ConfigurationProperties.MARSHALLER, null, true));
}
if (typed.containsKey(ConfigurationProperties.CONTEXT_INITIALIZERS)) {
String initializers = typed.getProperty(ConfigurationProperties.CONTEXT_INITIALIZERS);
for (String sci : initializers.split(",")) this.addContextInitializer(sci);
}
if (typed.containsKey(ConfigurationProperties.PROTOCOL_VERSION)) {
this.version(ProtocolVersion.parseVersion(typed.getProperty(ConfigurationProperties.PROTOCOL_VERSION, protocolVersion.toString(), true)));
}
String serverList = typed.getProperty(ConfigurationProperties.SERVER_LIST, null, true);
if (serverList != null) {
this.servers.clear();
this.addServers(serverList);
}
if (typed.containsKey(ConfigurationProperties.SO_TIMEOUT)) {
this.socketTimeout(typed.getIntProperty(ConfigurationProperties.SO_TIMEOUT, socketTimeout, true));
}
if (typed.containsKey(ConfigurationProperties.TCP_NO_DELAY)) {
this.tcpNoDelay(typed.getBooleanProperty(ConfigurationProperties.TCP_NO_DELAY, tcpNoDelay, true));
}
if (typed.containsKey(ConfigurationProperties.TCP_KEEP_ALIVE)) {
this.tcpKeepAlive(typed.getBooleanProperty(ConfigurationProperties.TCP_KEEP_ALIVE, tcpKeepAlive, true));
}
if (typed.containsKey(ConfigurationProperties.VALUE_SIZE_ESTIMATE)) {
this.valueSizeEstimate(typed.getIntProperty(ConfigurationProperties.VALUE_SIZE_ESTIMATE, valueSizeEstimate, true));
}
if (typed.containsKey(ConfigurationProperties.MAX_RETRIES)) {
this.maxRetries(typed.getIntProperty(ConfigurationProperties.MAX_RETRIES, maxRetries, true));
}
this.security.ssl().withProperties(properties);
this.security.authentication().withProperties(properties);
String serialAllowList = typed.getProperty(ConfigurationProperties.JAVA_SERIAL_WHITELIST);
if (serialAllowList != null && !serialAllowList.isEmpty()) {
org.infinispan.commons.logging.Log.CONFIG.deprecatedProperty(ConfigurationProperties.JAVA_SERIAL_WHITELIST, ConfigurationProperties.JAVA_SERIAL_ALLOWLIST);
String[] classes = serialAllowList.split(",");
Collections.addAll(this.allowListRegExs, classes);
}
serialAllowList = typed.getProperty(ConfigurationProperties.JAVA_SERIAL_ALLOWLIST);
if (serialAllowList != null && !serialAllowList.isEmpty()) {
String[] classes = serialAllowList.split(",");
Collections.addAll(this.allowListRegExs, classes);
}
if (typed.containsKey(ConfigurationProperties.BATCH_SIZE)) {
this.batchSize(typed.getIntProperty(ConfigurationProperties.BATCH_SIZE, batchSize, true));
}
// TODO read TRANSACTION_TIMEOUT property after TransactionConfigurationBuilder is removed.
transaction.withTransactionProperties(typed);
nearCache.withProperties(properties);
Map<String, String> xsiteProperties = typed.entrySet().stream().filter(e -> ((String) e.getKey()).startsWith(ConfigurationProperties.CLUSTER_PROPERTIES_PREFIX)).collect(Collectors.toMap(e -> ConfigurationProperties.CLUSTER_PROPERTIES_PREFIX_REGEX.matcher((String) e.getKey()).replaceFirst(""), e -> StringPropertyReplacer.replaceProperties((String) e.getValue())));
xsiteProperties.forEach((key, value) -> {
ClusterConfigurationBuilder cluster = this.addCluster(key);
parseServers(value, cluster::addClusterNode);
});
Set<String> cachesNames = typed.keySet().stream().map(k -> (String) k).filter(k -> k.startsWith(ConfigurationProperties.CACHE_PREFIX)).map(k -> k.charAt(CACHE_PREFIX_LENGTH) == '[' ? k.substring(CACHE_PREFIX_LENGTH + 1, k.indexOf(']', CACHE_PREFIX_LENGTH)) : k.substring(CACHE_PREFIX_LENGTH, k.indexOf('.', CACHE_PREFIX_LENGTH + 1))).collect(Collectors.toSet());
for (String cacheName : cachesNames) {
this.remoteCache(cacheName).withProperties(typed);
}
statistics.withProperties(properties);
if (typed.containsKey(ConfigurationProperties.TRANSPORT_FACTORY)) {
this.transportFactory = Util.getInstance(typed.getProperty(ConfigurationProperties.TRANSPORT_FACTORY), classLoader.get());
}
return this;
}
Aggregations