use of org.apache.qpid.server.store.jdbc.bonecp.BoneCPConnectionProviderFactory.PARTITION_COUNT 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;
}
Aggregations