Browse Source

Configurable :P

t00thpick1 11 years ago
parent
commit
9a12d86eac

+ 2 - 0
src/main/java/com/gmail/nossr50/config/Config.java

@@ -313,6 +313,8 @@ public class Config extends AutoUpdateConfigLoader {
     public int getMySQLServerPort() { return config.getInt("MySQL.Server.Port", 3306); }
     public String getMySQLServerName() { return config.getString("MySQL.Server.Address", "localhost"); }
     public String getMySQLUserPassword() { return getStringIncludingInts("MySQL.Database.User_Password"); }
+    public int getMySQLMaxConnections() { return config.getInt("MySQL.Database.MaxConnections"); }
+    public int getMySQLMaxPoolSize() { return config.getInt("MySQL.Database.MaxPoolSize"); }
 
     private String getStringIncludingInts(String key) {
         String str = config.getString(key);

+ 2 - 2
src/main/java/com/gmail/nossr50/database/SQLDatabaseManager.java

@@ -52,8 +52,8 @@ public final class SQLDatabaseManager implements DatabaseManager {
             connectionProperties.put("autoReconnect", "false");
             connectionPool = new ConnectionPool("mcMMO-Pool",
                     1 /*Minimum of one*/,
-                    10 /*max pool size */,      // TODO Configurable?
-                    10 /*max num connections*/, // TODO Configurable?
+                    Config.getInstance().getMySQLMaxPoolSize() /*max pool size */,
+                    Config.getInstance().getMySQLMaxConnections() /*max num connections*/,
                     0 /* idle timeout of connections */,
                     connectionString,
                     connectionProperties);

+ 6 - 0
src/main/resources/config.yml

@@ -122,6 +122,12 @@ MySQL:
         User_Password: UserPassword
         Name: DataBaseName
         TablePrefix: mcmmo_
+        # This setting is the max simultaneous mysql connections allowed at a time, needs to be
+        # high enough to support multiple player logins in quick succession
+        MaxConnections: 30
+        # This setting is the max size of the pool of cached connections that we hold available
+        # at any given time
+        MaxPoolSize: 20
     Server:
         Port: 3306
         Address: localhost