diff --git a/docs/config.md b/docs/config.md index 2483ed4f..2a664563 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,5 +1,5 @@ - + ## AuthMe Configuration The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder, @@ -63,8 +63,8 @@ DataSource: mySQLlastlocYaw: 'yaw' # Column for storing player LastLocation - Pitch mySQLlastlocPitch: 'pitch' - # Overrides the size of the DB Connection Pool, -1 = Auto - poolSize: -1 + # Overrides the size of the DB Connection Pool, default = 10 + poolSize: 10 # 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 @@ -560,4 +560,4 @@ To change settings on a running server, save your changes to config.yml and use --- -This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Tue Nov 28 12:49:57 CET 2017 +This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Wed Dec 13 23:12:29 CET 2017 diff --git a/src/main/java/fr/xephi/authme/datasource/MySQL.java b/src/main/java/fr/xephi/authme/datasource/MySQL.java index eb6019ca..4e669578 100644 --- a/src/main/java/fr/xephi/authme/datasource/MySQL.java +++ b/src/main/java/fr/xephi/authme/datasource/MySQL.java @@ -98,9 +98,6 @@ public class MySQL implements DataSource { this.col = new Columns(settings); this.sqlExtension = extensionsFactory.buildExtension(col); this.poolSize = settings.getProperty(DatabaseSettings.MYSQL_POOL_SIZE); - if (poolSize == -1) { - poolSize = Utils.getCoreCount() * 3; - } this.maxLifetime = settings.getProperty(DatabaseSettings.MYSQL_CONNECTION_MAX_LIFETIME); this.useSsl = settings.getProperty(DatabaseSettings.MYSQL_USE_SSL); } @@ -116,7 +113,6 @@ public class MySQL implements DataSource { ds.setMaximumPoolSize(poolSize); ds.setMaxLifetime(maxLifetime * 1000); - // Database URL ds.setJdbcUrl("jdbc:mysql://" + this.host + ":" + this.port + "/" + this.database); diff --git a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java index 9be27880..641492be 100644 --- a/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java +++ b/src/main/java/fr/xephi/authme/settings/SettingsMigrationService.java @@ -70,6 +70,7 @@ public class SettingsMigrationService extends PlainMigrationService { | performMailTextToFileMigration(resource) | migrateJoinLeaveMessages(resource) | migrateForceSpawnSettings(resource) + | migratePoolSizeSetting(resource) | changeBooleanSettingToLogLevelProperty(resource) | hasOldHelpHeaderProperty(resource) | hasSupportOldPasswordProperty(resource) @@ -194,6 +195,21 @@ public class SettingsMigrationService extends PlainMigrationService { | moveProperty(oldForceWorlds, FORCE_SPAWN_ON_WORLDS, resource); } + /** + * Detects the old auto poolSize value and replaces it with the default value. + * + * @param resource The property resource + * @return True if the configuration has changed, false otherwise + */ + private static boolean migratePoolSizeSetting(PropertyResource resource) { + Integer oldValue = resource.getInt("DataSource.poolSize"); + if(oldValue == null || oldValue > 0) { + return false; + } + resource.setValue("DataSource.poolSize", 10); + return true; + } + /** * Changes the old boolean property "hide spam from console" to the new property specifying * the log level. 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 31c62983..66ddd3cd 100644 --- a/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java +++ b/src/main/java/fr/xephi/authme/settings/properties/DatabaseSettings.java @@ -123,9 +123,9 @@ public final 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") + @Comment("Overrides the size of the DB Connection Pool, default = 10") public static final Property MYSQL_POOL_SIZE = - newProperty("DataSource.poolSize", -1); + newProperty("DataSource.poolSize", 10); @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"}) diff --git a/src/main/java/fr/xephi/authme/util/Utils.java b/src/main/java/fr/xephi/authme/util/Utils.java index ad4ccb9e..4db7f61b 100644 --- a/src/main/java/fr/xephi/authme/util/Utils.java +++ b/src/main/java/fr/xephi/authme/util/Utils.java @@ -96,15 +96,6 @@ public final class Utils { return coll == null || coll.isEmpty(); } - /** - * Return the available core count of the JVM. - * - * @return the core count - */ - public static int getCoreCount() { - return Runtime.getRuntime().availableProcessors(); - } - /** * Returns whether the given email is empty or equal to the standard "undefined" email address. * diff --git a/src/test/java/fr/xephi/authme/util/UtilsTest.java b/src/test/java/fr/xephi/authme/util/UtilsTest.java index 87fc308c..154137ef 100644 --- a/src/test/java/fr/xephi/authme/util/UtilsTest.java +++ b/src/test/java/fr/xephi/authme/util/UtilsTest.java @@ -117,12 +117,6 @@ public class UtilsTest { assertThat(Utils.isCollectionEmpty(null), equalTo(true)); } - @Test - public void shouldReturnCoreCount() { - // given / when / then - assertThat(Utils.getCoreCount(), greaterThan(0)); - } - @Test public void shouldLogAndSendWarning() { // given