Search in sources :

Example 1 with MIN_CONNECTIONS_PER_PARTITION

use of org.apache.qpid.server.store.jdbc.bonecp.BoneCPConnectionProviderFactory.MIN_CONNECTIONS_PER_PARTITION in project qpid-broker-j by apache.

the class BoneCPConnectionProvider method createBoneCPConfig.

static BoneCPConfig createBoneCPConfig(final String connectionUrl, final String username, final String password, final Map<String, String> providerAttributes) {
    BoneCPConfig config = new BoneCPConfig();
    config.setJdbcUrl(connectionUrl);
    if (username != null) {
        config.setUsername(username);
        config.setPassword(password);
    }
    Map<String, String> attributes = new HashMap<>(providerAttributes);
    attributes.putIfAbsent(MIN_CONNECTIONS_PER_PARTITION, String.valueOf(DEFAULT_MIN_CONNECTIONS_PER_PARTITION));
    attributes.putIfAbsent(MAX_CONNECTIONS_PER_PARTITION, String.valueOf(DEFAULT_MAX_CONNECTIONS_PER_PARTITION));
    attributes.putIfAbsent(PARTITION_COUNT, String.valueOf(DEFAULT_PARTITION_COUNT));
    Map<String, String> propertiesMap = attributes.entrySet().stream().collect(Collectors.toMap(p -> p.getKey().substring(JDBCSTORE_PREFIX.length()), Map.Entry::getValue));
    Properties properties = new Properties();
    properties.putAll(propertiesMap);
    try {
        config.setProperties(properties);
    } catch (Exception e) {
        throw new IllegalConfigurationException("Unexpected exception on applying BoneCP configuration", e);
    }
    return config;
}
Also used : JDBCSTORE_PREFIX(org.apache.qpid.server.store.jdbc.bonecp.BoneCPConnectionProviderFactory.JDBCSTORE_PREFIX) Connection(java.sql.Connection) Properties(java.util.Properties) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) HashMap(java.util.HashMap) Collectors(java.util.stream.Collectors) MAX_CONNECTIONS_PER_PARTITION(org.apache.qpid.server.store.jdbc.bonecp.BoneCPConnectionProviderFactory.MAX_CONNECTIONS_PER_PARTITION) PARTITION_COUNT(org.apache.qpid.server.store.jdbc.bonecp.BoneCPConnectionProviderFactory.PARTITION_COUNT) SQLException(java.sql.SQLException) BoneCP(com.jolbox.bonecp.BoneCP) Map(java.util.Map) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException) MIN_CONNECTIONS_PER_PARTITION(org.apache.qpid.server.store.jdbc.bonecp.BoneCPConnectionProviderFactory.MIN_CONNECTIONS_PER_PARTITION) ConnectionProvider(org.apache.qpid.server.store.jdbc.ConnectionProvider) BoneCPConfig(com.jolbox.bonecp.BoneCPConfig) HashMap(java.util.HashMap) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) BoneCPConfig(com.jolbox.bonecp.BoneCPConfig) Properties(java.util.Properties) HashMap(java.util.HashMap) Map(java.util.Map) IllegalConfigurationException(org.apache.qpid.server.configuration.IllegalConfigurationException) SQLException(java.sql.SQLException) ServerScopedRuntimeException(org.apache.qpid.server.util.ServerScopedRuntimeException)

Aggregations

BoneCP (com.jolbox.bonecp.BoneCP)1 BoneCPConfig (com.jolbox.bonecp.BoneCPConfig)1 Connection (java.sql.Connection)1 SQLException (java.sql.SQLException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Properties (java.util.Properties)1 Collectors (java.util.stream.Collectors)1 IllegalConfigurationException (org.apache.qpid.server.configuration.IllegalConfigurationException)1 ConnectionProvider (org.apache.qpid.server.store.jdbc.ConnectionProvider)1 JDBCSTORE_PREFIX (org.apache.qpid.server.store.jdbc.bonecp.BoneCPConnectionProviderFactory.JDBCSTORE_PREFIX)1 MAX_CONNECTIONS_PER_PARTITION (org.apache.qpid.server.store.jdbc.bonecp.BoneCPConnectionProviderFactory.MAX_CONNECTIONS_PER_PARTITION)1 MIN_CONNECTIONS_PER_PARTITION (org.apache.qpid.server.store.jdbc.bonecp.BoneCPConnectionProviderFactory.MIN_CONNECTIONS_PER_PARTITION)1 PARTITION_COUNT (org.apache.qpid.server.store.jdbc.bonecp.BoneCPConnectionProviderFactory.PARTITION_COUNT)1 ServerScopedRuntimeException (org.apache.qpid.server.util.ServerScopedRuntimeException)1