use of org.infinispan.persistence.remote.configuration.RemoteServerConfiguration in project infinispan by infinispan.
the class RemoteStore method buildRemoteConfiguration.
private ConfigurationBuilder buildRemoteConfiguration(RemoteStoreConfiguration configuration, Marshaller marshaller) {
ConfigurationBuilder builder = (configuration.uri() != null && !configuration.uri().isEmpty()) ? HotRodURI.create(configuration.uri()).toConfigurationBuilder() : new ConfigurationBuilder();
List<RemoteServerConfiguration> servers = configuration.servers();
for (RemoteServerConfiguration s : servers) {
builder.addServer().host(s.host()).port(s.port());
}
ConnectionPoolConfiguration poolConfiguration = configuration.connectionPool();
Long connectionTimeout = configuration.connectionTimeout();
Long socketTimeout = configuration.socketTimeout();
builder.classLoader(configuration.getClass().getClassLoader()).balancingStrategy(configuration.balancingStrategy()).connectionPool().exhaustedAction(ExhaustedAction.valueOf(poolConfiguration.exhaustedAction().toString())).maxActive(poolConfiguration.maxActive()).minIdle(poolConfiguration.minIdle()).minEvictableIdleTime(poolConfiguration.minEvictableIdleTime()).connectionTimeout(connectionTimeout.intValue()).forceReturnValues(configuration.forceReturnValues()).keySizeEstimate(configuration.keySizeEstimate()).marshaller(marshaller).asyncExecutorFactory().factoryClass(configuration.asyncExecutorFactory().factory().getClass()).asyncExecutorFactory().withExecutorProperties(configuration.asyncExecutorFactory().properties()).socketTimeout(socketTimeout.intValue()).tcpNoDelay(configuration.tcpNoDelay()).valueSizeEstimate(configuration.valueSizeEstimate()).version(configuration.protocol() == null ? ProtocolVersion.DEFAULT_PROTOCOL_VERSION : configuration.protocol());
SslConfiguration ssl = configuration.security().ssl();
if (ssl.enabled()) {
builder.security().ssl().enable().keyStoreType(ssl.keyStoreType()).keyAlias(ssl.keyAlias()).keyStoreFileName(ssl.keyStoreFileName()).keyStorePassword(ssl.keyStorePassword()).keyStoreCertificatePassword(ssl.keyStoreCertificatePassword()).trustStoreFileName(ssl.trustStoreFileName()).trustStorePassword(ssl.trustStorePassword()).trustStoreType(ssl.trustStoreType()).protocol(ssl.protocol()).sniHostName(ssl.sniHostName());
}
AuthenticationConfiguration auth = configuration.security().authentication();
if (auth.enabled()) {
builder.security().authentication().enable().callbackHandler(auth.callbackHandler()).clientSubject(auth.clientSubject()).saslMechanism(auth.saslMechanism()).serverName(auth.serverName()).saslProperties(auth.saslProperties()).username(auth.username()).password(auth.password()).realm(auth.realm());
}
Properties propertiesToUse;
Properties actualProperties = configuration.properties();
if (!actualProperties.contains("blocking")) {
// Need to make a copy to not change the actual configuration properties
propertiesToUse = new Properties(actualProperties);
// Make sure threads are marked as non blocking if user didn't specify
propertiesToUse.put("blocking", "false");
} else {
propertiesToUse = actualProperties;
}
builder.withProperties(propertiesToUse);
return builder;
}
use of org.infinispan.persistence.remote.configuration.RemoteServerConfiguration in project infinispan by infinispan.
the class RollingUpgradeDynamicStoreIT method connectTargetCluster.
protected void connectTargetCluster() throws IOException {
RestCacheClient client = target.getClient().cache(CACHE_NAME);
ConfigurationBuilder builder = new ConfigurationBuilder();
addRemoteStore(builder);
RemoteStoreConfiguration remoteStore = (RemoteStoreConfiguration) builder.build().persistence().stores().iterator().next();
RestEntity restEntity = RestEntity.create(MediaType.APPLICATION_JSON, SerializationUtils.toJson(remoteStore));
RestResponse response = join(client.connectSource(restEntity));
assertEquals(response.getBody(), 204, response.getStatus());
response = join(client.sourceConnection());
RemoteStoreConfiguration remoteStoreConfiguration = SerializationUtils.fromJson(response.getBody());
List<RemoteServerConfiguration> servers = remoteStoreConfiguration.servers();
assertEquals(1, servers.size());
RemoteServerConfiguration initialConfig = remoteStore.servers().iterator().next();
assertEquals(initialConfig.host(), servers.get(0).host());
assertEquals(initialConfig.port(), servers.get(0).port());
}
Aggregations