From bce66bf57f260eca84b275fc2f6f4dca5531f8ae Mon Sep 17 00:00:00 2001 From: catbref Date: Sat, 13 Mar 2021 18:14:11 +0000 Subject: [PATCH] Move HSQLDBRepositoryFactory.POOL_SIZE into Settings as "repositoryConnectionPoolSize" --- .../qortal/repository/hsqldb/HSQLDBRepositoryFactory.java | 4 ++-- src/main/java/org/qortal/settings/Settings.java | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/qortal/repository/hsqldb/HSQLDBRepositoryFactory.java b/src/main/java/org/qortal/repository/hsqldb/HSQLDBRepositoryFactory.java index 2f18720c..be9c09eb 100644 --- a/src/main/java/org/qortal/repository/hsqldb/HSQLDBRepositoryFactory.java +++ b/src/main/java/org/qortal/repository/hsqldb/HSQLDBRepositoryFactory.java @@ -14,11 +14,11 @@ import org.hsqldb.jdbc.HSQLDBPool; import org.qortal.repository.DataException; import org.qortal.repository.Repository; import org.qortal.repository.RepositoryFactory; +import org.qortal.settings.Settings; public class HSQLDBRepositoryFactory implements RepositoryFactory { private static final Logger LOGGER = LogManager.getLogger(HSQLDBRepositoryFactory.class); - private static final int POOL_SIZE = 100; /** Log getConnection() calls that take longer than this. (ms) */ private static final long SLOW_CONNECTION_THRESHOLD = 1000L; @@ -57,7 +57,7 @@ public class HSQLDBRepositoryFactory implements RepositoryFactory { HSQLDBRepository.attemptRecovery(connectionUrl); } - this.connectionPool = new HSQLDBPool(POOL_SIZE); + this.connectionPool = new HSQLDBPool(Settings.getInstance().getRepositoryConnectionPoolSize()); this.connectionPool.setUrl(this.connectionUrl); Properties properties = new Properties(); diff --git a/src/main/java/org/qortal/settings/Settings.java b/src/main/java/org/qortal/settings/Settings.java index 45d80d7d..fb068b8d 100644 --- a/src/main/java/org/qortal/settings/Settings.java +++ b/src/main/java/org/qortal/settings/Settings.java @@ -136,6 +136,8 @@ public class Settings { private Long slowQueryThreshold = null; /** Repository storage path. */ private String repositoryPath = "db"; + /** Repository connection pool size. Needs to be a bit bigger than maxNetworkThreadPoolSize */ + private int repositoryConnectionPoolSize = 100; // Auto-update sources private String[] autoUpdateRepos = new String[] { @@ -430,6 +432,10 @@ public class Settings { return this.repositoryPath; } + public int getRepositoryConnectionPoolSize() { + return this.repositoryConnectionPoolSize; + } + public boolean isAutoUpdateEnabled() { return this.autoUpdateEnabled; }