mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-16 08:57:59 +02:00
Add database setting to configure HikariCP 'maxLifetime' #1279
This commit is contained in:
parent
e1826c75c8
commit
87b9bf140d
@ -58,6 +58,9 @@ DataSource:
|
|||||||
mySQLlastlocPitch: 'pitch'
|
mySQLlastlocPitch: 'pitch'
|
||||||
# Overrides the size of the DB Connection Pool, -1 = Auto
|
# Overrides the size of the DB Connection Pool, -1 = Auto
|
||||||
poolSize: -1
|
poolSize: -1
|
||||||
|
# The maximum lifetime of a connection in the pool, default = 1800 seconds
|
||||||
|
# You should set this at least 30 seconds less than mysql server wait_timeout
|
||||||
|
maxLifetime: 1800
|
||||||
ExternalBoardOptions:
|
ExternalBoardOptions:
|
||||||
# Column for storing players passwords salts
|
# Column for storing players passwords salts
|
||||||
mySQLColumnSalt: ''
|
mySQLColumnSalt: ''
|
||||||
|
@ -41,6 +41,7 @@ public class MySQL implements DataSource {
|
|||||||
private String database;
|
private String database;
|
||||||
private String tableName;
|
private String tableName;
|
||||||
private int poolSize;
|
private int poolSize;
|
||||||
|
private int maxLifetime;
|
||||||
private List<String> columnOthers;
|
private List<String> columnOthers;
|
||||||
private Columns col;
|
private Columns col;
|
||||||
private HashAlgorithm hashAlgorithm;
|
private HashAlgorithm hashAlgorithm;
|
||||||
@ -116,6 +117,7 @@ public class MySQL implements DataSource {
|
|||||||
if (poolSize == -1) {
|
if (poolSize == -1) {
|
||||||
poolSize = Utils.getCoreCount() * 3;
|
poolSize = Utils.getCoreCount() * 3;
|
||||||
}
|
}
|
||||||
|
this.maxLifetime = settings.getProperty(DatabaseSettings.MYSQL_CONNECTION_MAX_LIFETIME);
|
||||||
this.useSsl = settings.getProperty(DatabaseSettings.MYSQL_USE_SSL);
|
this.useSsl = settings.getProperty(DatabaseSettings.MYSQL_USE_SSL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,8 +128,10 @@ public class MySQL implements DataSource {
|
|||||||
ds = new HikariDataSource();
|
ds = new HikariDataSource();
|
||||||
ds.setPoolName("AuthMeMYSQLPool");
|
ds.setPoolName("AuthMeMYSQLPool");
|
||||||
|
|
||||||
// Pool size
|
// Pool Settings
|
||||||
ds.setMaximumPoolSize(poolSize);
|
ds.setMaximumPoolSize(poolSize);
|
||||||
|
ds.setMaxLifetime(maxLifetime * 1000);
|
||||||
|
|
||||||
|
|
||||||
// Database URL
|
// Database URL
|
||||||
ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
|
ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database);
|
||||||
|
@ -10,7 +10,7 @@ import static ch.jalu.configme.properties.PropertyInitializer.newProperty;
|
|||||||
public final class DatabaseSettings implements SettingsHolder {
|
public final class DatabaseSettings implements SettingsHolder {
|
||||||
|
|
||||||
@Comment({"What type of database do you want to use?",
|
@Comment({"What type of database do you want to use?",
|
||||||
"Valid values: SQLITE, MYSQL"})
|
"Valid values: SQLITE, MYSQL"})
|
||||||
public static final Property<DataSourceType> BACKEND =
|
public static final Property<DataSourceType> BACKEND =
|
||||||
newProperty(DataSourceType.class, "DataSource.backend", DataSourceType.SQLITE);
|
newProperty(DataSourceType.class, "DataSource.backend", DataSourceType.SQLITE);
|
||||||
|
|
||||||
@ -114,6 +114,11 @@ public final class DatabaseSettings implements SettingsHolder {
|
|||||||
public static final Property<Integer> MYSQL_POOL_SIZE =
|
public static final Property<Integer> MYSQL_POOL_SIZE =
|
||||||
newProperty("DataSource.poolSize", -1);
|
newProperty("DataSource.poolSize", -1);
|
||||||
|
|
||||||
|
@Comment({"The maximum lifetime of a connection in the pool, default = 1800 seconds",
|
||||||
|
"You should set this at least 30 seconds less than mysql server wait_timeout"})
|
||||||
|
public static final Property<Integer> MYSQL_CONNECTION_MAX_LIFETIME =
|
||||||
|
newProperty("DataSource.maxLifetime", 1800);
|
||||||
|
|
||||||
private DatabaseSettings() {
|
private DatabaseSettings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user