Search in sources :

Example 1 with ConnectionPoolConfiguration

use of org.infinispan.persistence.remote.configuration.ConnectionPoolConfiguration 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;
}
Also used : RemoteServerConfiguration(org.infinispan.persistence.remote.configuration.RemoteServerConfiguration) AuthenticationConfiguration(org.infinispan.persistence.remote.configuration.AuthenticationConfiguration) ConfigurationBuilder(org.infinispan.client.hotrod.configuration.ConfigurationBuilder) SslConfiguration(org.infinispan.persistence.remote.configuration.SslConfiguration) Properties(java.util.Properties) ConnectionPoolConfiguration(org.infinispan.persistence.remote.configuration.ConnectionPoolConfiguration)

Aggregations

Properties (java.util.Properties)1 ConfigurationBuilder (org.infinispan.client.hotrod.configuration.ConfigurationBuilder)1 AuthenticationConfiguration (org.infinispan.persistence.remote.configuration.AuthenticationConfiguration)1 ConnectionPoolConfiguration (org.infinispan.persistence.remote.configuration.ConnectionPoolConfiguration)1 RemoteServerConfiguration (org.infinispan.persistence.remote.configuration.RemoteServerConfiguration)1 SslConfiguration (org.infinispan.persistence.remote.configuration.SslConfiguration)1