From c3ed77193966940089d91a63e0691e0042ee0581 Mon Sep 17 00:00:00 2001 From: Gabriele C Date: Wed, 25 Nov 2015 17:06:00 +0100 Subject: [PATCH] WIP new hikari parameters --- .../fr/xephi/authme/datasource/MySQL.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index 605e80a4a..976cb56e3 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -12,6 +12,7 @@ import fr.xephi.authme.settings.Settings; import java.sql.*; import java.util.ArrayList; import java.util.List; +import java.util.Properties; /** */ @@ -39,7 +40,7 @@ public class MySQL implements DataSource { private final List columnOthers; private HikariDataSource ds; private final String columnRealName; - private final int maxConnections; + //private final int maxConnections; /** * Constructor for MySQL. @@ -68,7 +69,7 @@ public class MySQL implements DataSource { this.columnID = Settings.getMySQLColumnId; this.columnLogged = Settings.getMySQLColumnLogged; this.columnRealName = Settings.getMySQLColumnRealName; - this.maxConnections = Settings.getMySQLMaxConnections; + //this.maxConnections = Settings.getMySQLMaxConnections; // Set the connection arguments (and check if connection is ok) try { @@ -107,18 +108,22 @@ public class MySQL implements DataSource { private synchronized void setConnectionArguments() throws IllegalArgumentException { HikariConfig config = new HikariConfig(); - config.setPoolName("AuthMeMYSQLPool"); + Properties mySqlProps = new Properties(); + mySqlProps.setProperty("useConfigs", "maxPerformance"); config.setDriverClassName("com.mysql.jdbc.Driver"); config.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database); config.setUsername(this.username); config.setPassword(this.password); - config.addDataSourceProperty("cachePrepStmts", "false"); - config.addDataSourceProperty("autoReconnect", false); - config.setInitializationFailFast(true); // Don't start the plugin if the database is unavailable - config.setMaxLifetime(180000); // 3 Min - config.setIdleTimeout(60000); // 1 Min - config.setMinimumIdle(2); - config.setMaximumPoolSize(maxConnections); + config.setMaximumPoolSize((Runtime.getRuntime().availableProcessors() * 2) + 1); + config.setDataSourceProperties(mySqlProps); + //config.setPoolName("AuthMeMYSQLPool"); + //config.addDataSourceProperty("cachePrepStmts", "false"); + //config.addDataSourceProperty("autoReconnect", false); + //config.setInitializationFailFast(true); // Don't start the plugin if the database is unavailable + //config.setMaxLifetime(180000); // 3 Min + //config.setIdleTimeout(60000); // 1 Min + //config.setMinimumIdle(2); + //config.setMaximumPoolSize(maxConnections); ds = new HikariDataSource(config); ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!"); }