Commit 7c927885 authored by Matija Obreza's avatar Matija Obreza
Browse files

Database pool configuration updated to allow for better handling of failover-to-readonly database

parent ab6ee26d
......@@ -58,10 +58,28 @@ public class SpringDataBaseConfig {
@Value("${db.hbm2ddl}")
private boolean dbGenerateDdl;
@Value("${hibernate.dialect}")
private String hibernateDialect;
/*
* db.pool.initialSize=1 db.pool.maxIdle=10 db.pool.maxActive=20 db.pool.maxIdleTime=15
*/
@Value("${db.pool.initialSize}")
private int initialSize;
@Value("${db.pool.maxIdle}")
private int maxIdle;
@Value("${db.pool.maxActive}")
private int maxActive;
// max allowed age for any connection
private long maxAgeSeconds = 60 * 5;
@Value("${db.pool.maxIdleSeconds}")
private int maxIdleSeconds;
@Bean
public DataSource dataSource() {
final DataSource dataSource = new DataSource();
......@@ -72,10 +90,15 @@ public class SpringDataBaseConfig {
dataSource.setValidationQuery("SELECT 1");
dataSource.setTestWhileIdle(true);
dataSource.setTestOnBorrow(true);
dataSource.setInitialSize(initialSize);
dataSource.setMaxIdle(maxIdle);
dataSource.setMaxActive(maxActive);
dataSource.setMaxAge(maxAgeSeconds * 1000);
dataSource.setMinEvictableIdleTimeMillis(maxIdleSeconds * 1000);
return dataSource;
}
@Bean
public JdbcTemplate jdbcTemplate(DataSource dataSource) {
return new JdbcTemplate(dataSource);
......
......@@ -36,10 +36,10 @@ google.api.key=AIzaSyBEvPuc8j5ps5GDQ3tdnTJaffKhfOdxFVc
google.url.shortener=https://www.googleapis.com/urlshortener/v1/url
news.menu.abbreviate.length=22
c3p0.acquireIncrement=1
c3p0.minPoolSize=1
c3p0.maxPoolSize=5
c3p0.maxIdleTime=10
db.pool.initialSize=1
db.pool.maxIdle=15
db.pool.maxActive=30
db.pool.maxIdleSeconds=30
# reCAPTCHA API: These are our keys for localhost
captcha.privateKey=6Lfb5w4TAAAAADoSaBZsxx832HH5YHdCdEiS2v0s
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment