From 1867617dbb6e9de6e59917a94568dfa2dbc154af Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Sat, 22 Oct 2016 00:46:28 +0200 Subject: [PATCH] Add option to override dbcp size --- src/main/java/fr/xephi/authme/datasource/MySQL.java | 7 ++++++- .../xephi/authme/settings/properties/DatabaseSettings.java | 4 ++++ src/main/resources/config.yml | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 9c613ec3..9da225b9 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -40,6 +40,7 @@ public class MySQL implements DataSource { private String password; private String database; private String tableName; + private int poolSize; private List columnOthers; private Columns col; private HashAlgorithm hashAlgorithm; @@ -98,6 +99,10 @@ public class MySQL implements DataSource { this.phpBbPrefix = settings.getProperty(HooksSettings.PHPBB_TABLE_PREFIX); this.phpBbGroup = settings.getProperty(HooksSettings.PHPBB_ACTIVATED_GROUP_ID); this.wordpressPrefix = settings.getProperty(HooksSettings.WORDPRESS_TABLE_PREFIX); + this.poolSize = settings.getProperty(DatabaseSettings.MYSQL_POOL_SIZE); + if(poolSize == -1) { + poolSize = RuntimeUtils.getCoreCount(); + } } private void setConnectionArguments() throws RuntimeException { @@ -105,7 +110,7 @@ public class MySQL implements DataSource { ds.setPoolName("AuthMeMYSQLPool"); // Pool size - ds.setMaximumPoolSize(RuntimeUtils.getCoreCount()); + ds.setMaximumPoolSize(poolSize); // Database URL ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database); diff --git a/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java b/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java index 2dc769ec..c82a7a81 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java @@ -98,6 +98,10 @@ public class DatabaseSettings implements SettingsHolder { public static final Property MYSQL_COL_GROUP = newProperty("ExternalBoardOptions.mySQLColumnGroup", ""); + @Comment("Overrides the size of the DB Connection Pool, -1 = Auto") + public static final Property MYSQL_POOL_SIZE = + newProperty("DataSource.poolSize", -1); + private DatabaseSettings() { } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index bed1d2c4..aba5a865 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -40,6 +40,8 @@ DataSource: mySQLlastlocWorld: world # Column for RealName mySQLRealName: realname + # Overrides the size of the DB Connection Pool, -1 = Auto + poolSize: -1 settings: sessions: # Do you want to enable the session feature?