FINERACT-1724: Ability to override tenant datasource min/max configuration from env variables
This commit is contained in:
committed by
Adam Saghy
parent
f24c9f8084
commit
7f5b87694b
+21
@@ -86,6 +86,27 @@ public class FineractProperties {
|
||||
private String readOnlyPassword;
|
||||
private String readOnlyParameters;
|
||||
private String readOnlyName;
|
||||
|
||||
private FineractConfigProperties config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configuration properties to override configurations stored in the tenants database
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class FineractConfigProperties {
|
||||
|
||||
private int minPoolSize;
|
||||
private int maxPoolSize;
|
||||
|
||||
public boolean isMinPoolSizeSet() {
|
||||
return minPoolSize != -1;
|
||||
}
|
||||
|
||||
public boolean isMaxPoolSizeSet() {
|
||||
return maxPoolSize != -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
|
||||
+24
-2
@@ -92,8 +92,8 @@ public class DataSourcePerTenantServiceFactory {
|
||||
config.setPoolName(schemaName + "_pool");
|
||||
config.setUsername(schemaUsername);
|
||||
config.setPassword(databasePasswordEncryptor.decrypt(schemaPassword));
|
||||
config.setMinimumIdle(tenantConnection.getInitialSize());
|
||||
config.setMaximumPoolSize(tenantConnection.getMaxActive());
|
||||
config.setMinimumIdle(getMinPoolSize(tenantConnection));
|
||||
config.setMaximumPoolSize(getMaxPoolSize(tenantConnection));
|
||||
config.setValidationTimeout(tenantConnection.getValidationInterval());
|
||||
config.setDriverClassName(hikariConfig.getDriverClassName());
|
||||
config.setConnectionTestQuery(hikariConfig.getConnectionTestQuery());
|
||||
@@ -111,4 +111,26 @@ public class DataSourcePerTenantServiceFactory {
|
||||
return hikariDataSourceFactory.create(config);
|
||||
}
|
||||
|
||||
private int getMaxPoolSize(FineractPlatformTenantConnection tenantConnection) {
|
||||
FineractProperties.FineractConfigProperties configOverride = fineractProperties.getTenant().getConfig();
|
||||
if (configOverride.isMaxPoolSizeSet()) {
|
||||
int maxPoolSize = configOverride.getMaxPoolSize();
|
||||
log.info("Overriding tenant datasource maximum pool size configuration to {}", maxPoolSize);
|
||||
return maxPoolSize;
|
||||
} else {
|
||||
return tenantConnection.getMaxActive();
|
||||
}
|
||||
}
|
||||
|
||||
private int getMinPoolSize(FineractPlatformTenantConnection tenantConnection) {
|
||||
FineractProperties.FineractConfigProperties configOverride = fineractProperties.getTenant().getConfig();
|
||||
if (configOverride.isMinPoolSizeSet()) {
|
||||
int minPoolSize = configOverride.getMinPoolSize();
|
||||
log.info("Overriding tenant datasource minimum pool size configuration to {}", minPoolSize);
|
||||
return minPoolSize;
|
||||
} else {
|
||||
return tenantConnection.getInitialSize();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+15
-12
@@ -19,6 +19,7 @@
|
||||
package org.apache.fineract.infrastructure.core.service.migration;
|
||||
|
||||
import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -29,7 +30,6 @@ import liquibase.exception.LiquibaseException;
|
||||
import liquibase.integration.spring.SpringLiquibase;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.fineract.infrastructure.core.boot.FineractProfiles;
|
||||
import org.apache.fineract.infrastructure.core.config.FineractProperties;
|
||||
import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
|
||||
@@ -102,19 +102,22 @@ public class TenantDatabaseUpgradeService implements InitializingBean {
|
||||
}
|
||||
|
||||
private void logTenantStoreDetails() {
|
||||
log.info("- fineract.tenant.username: {}", fineractProperties.getTenant().getUsername());
|
||||
FineractProperties.FineractTenantProperties tenant = fineractProperties.getTenant();
|
||||
log.info("- fineract.tenant.username: {}", tenant.getUsername());
|
||||
log.info("- fineract.tenant.password: ****");
|
||||
log.info("- fineract.tenant.parameters: {}", fineractProperties.getTenant().getParameters());
|
||||
log.info("- fineract.tenant.timezone: {}", fineractProperties.getTenant().getTimezone());
|
||||
log.info("- fineract.tenant.description: {}", fineractProperties.getTenant().getDescription());
|
||||
log.info("- fineract.tenant.identifier: {}", fineractProperties.getTenant().getIdentifier());
|
||||
log.info("- fineract.tenant.name: {}", fineractProperties.getTenant().getName());
|
||||
log.info("- fineract.tenant.parameters: {}", tenant.getParameters());
|
||||
log.info("- fineract.tenant.timezone: {}", tenant.getTimezone());
|
||||
log.info("- fineract.tenant.description: {}", tenant.getDescription());
|
||||
log.info("- fineract.tenant.identifier: {}", tenant.getIdentifier());
|
||||
log.info("- fineract.tenant.name: {}", tenant.getName());
|
||||
|
||||
log.info("- fineract.tenant.readonly.username: {}", fineractProperties.getTenant().getReadOnlyUsername());
|
||||
log.info("- fineract.tenant.readonly.password: {}",
|
||||
StringUtils.isNotBlank(fineractProperties.getTenant().getReadOnlyPassword()) ? "****" : "");
|
||||
log.info("- fineract.tenant.readonly.parameters: {}", fineractProperties.getTenant().getReadOnlyParameters());
|
||||
log.info("- fineract.tenant.readonly.name: {}", fineractProperties.getTenant().getReadOnlyName());
|
||||
String readOnlyUsername = tenant.getReadOnlyUsername();
|
||||
if (isNotBlank(readOnlyUsername)) {
|
||||
log.info("- fineract.tenant.readonly.username: {}", readOnlyUsername);
|
||||
log.info("- fineract.tenant.readonly.password: {}", isNotBlank(tenant.getReadOnlyPassword()) ? "****" : "");
|
||||
log.info("- fineract.tenant.readonly.parameters: {}", tenant.getReadOnlyParameters());
|
||||
log.info("- fineract.tenant.readonly.name: {}", tenant.getReadOnlyName());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,9 @@ fineract.tenant.read-only-password=${FINERACT_DEFAULT_TENANTDB_RO_PWD:}
|
||||
fineract.tenant.read-only-parameters=${FINERACT_DEFAULT_TENANTDB_RO_CONN_PARAMS:}
|
||||
fineract.tenant.read-only-name=${FINERACT_DEFAULT_TENANTDB_RO_NAME:}
|
||||
|
||||
fineract.tenant.config.min-pool-size=${FINERACT_CONFIG_MIN_POOL_SIZE:-1}
|
||||
fineract.tenant.config.max-pool-size=${FINERACT_CONFIG_MAX_POOL_SIZE:-1}
|
||||
|
||||
fineract.mode.read-enabled=${FINERACT_MODE_READ_ENABLED:true}
|
||||
fineract.mode.write-enabled=${FINERACT_MODE_WRITE_ENABLED:true}
|
||||
fineract.mode.batch-worker-enabled=${FINERACT_MODE_BATCH_WORKER_ENABLED:true}
|
||||
|
||||
Reference in New Issue
Block a user