Add option to override dbcp size

This commit is contained in:
Gabriele C 2016-10-22 00:46:28 +02:00
parent 627b9dd5c5
commit 1867617dbb
3 changed files with 12 additions and 1 deletions

View File

@ -40,6 +40,7 @@ public class MySQL implements DataSource {
private String password; private String password;
private String database; private String database;
private String tableName; private String tableName;
private int poolSize;
private List<String> columnOthers; private List<String> columnOthers;
private Columns col; private Columns col;
private HashAlgorithm hashAlgorithm; private HashAlgorithm hashAlgorithm;
@ -98,6 +99,10 @@ public class MySQL implements DataSource {
this.phpBbPrefix = settings.getProperty(HooksSettings.PHPBB_TABLE_PREFIX); this.phpBbPrefix = settings.getProperty(HooksSettings.PHPBB_TABLE_PREFIX);
this.phpBbGroup = settings.getProperty(HooksSettings.PHPBB_ACTIVATED_GROUP_ID); this.phpBbGroup = settings.getProperty(HooksSettings.PHPBB_ACTIVATED_GROUP_ID);
this.wordpressPrefix = settings.getProperty(HooksSettings.WORDPRESS_TABLE_PREFIX); 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 { private void setConnectionArguments() throws RuntimeException {
@ -105,7 +110,7 @@ public class MySQL implements DataSource {
ds.setPoolName("AuthMeMYSQLPool"); ds.setPoolName("AuthMeMYSQLPool");
// Pool size // Pool size
ds.setMaximumPoolSize(RuntimeUtils.getCoreCount()); ds.setMaximumPoolSize(poolSize);
// Database URL // Database URL
ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database); ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);

View File

@ -98,6 +98,10 @@ public class DatabaseSettings implements SettingsHolder {
public static final Property<String> MYSQL_COL_GROUP = public static final Property<String> MYSQL_COL_GROUP =
newProperty("ExternalBoardOptions.mySQLColumnGroup", ""); newProperty("ExternalBoardOptions.mySQLColumnGroup", "");
@Comment("Overrides the size of the DB Connection Pool, -1 = Auto")
public static final Property<Integer> MYSQL_POOL_SIZE =
newProperty("DataSource.poolSize", -1);
private DatabaseSettings() { private DatabaseSettings() {
} }

View File

@ -40,6 +40,8 @@ DataSource:
mySQLlastlocWorld: world mySQLlastlocWorld: world
# Column for RealName # Column for RealName
mySQLRealName: realname mySQLRealName: realname
# Overrides the size of the DB Connection Pool, -1 = Auto
poolSize: -1
settings: settings:
sessions: sessions:
# Do you want to enable the session feature? # Do you want to enable the session feature?