Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Instructions to build the JAR file

The tenants database connection details are configured [via environment variables (as with Docker container)](#instructions-to-run-using-docker-and-docker-compose), e.g. like this:

export fineract_tenants_pwd=verysecret
export FINERACT_HIKARI_PASSWORD=verysecret
...
java -jar fineract-provider.jar

Expand Down Expand Up @@ -179,6 +179,13 @@ _(Note that in previous versions, the `mysqlserver` environment variable used at
and the `mysqlserver` environment variable is now no longer supported.)_


Connection pool configuration
=============================

Please check `application.properties` to see which connection pool settings can be tweaked. The associated environment variables are prefixed with `FINERACT_HIKARI_*`. You can find more information about specific connection pool settings (Hikari) at https://github.com/brettwooldridge/HikariCP#configuration-knobs-baby

NOTE: we'll keep backwards compatibility until one of the next releases to ensure that things are working as expected. Environment variables prefixed `fineract_tenants_*` can still be used to configure the database connection, but we strongly encourage using `FINERACT_HIKARI_*` with more options.

Instructions to run on Kubernetes
=================================

Expand Down
44 changes: 36 additions & 8 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,47 @@ services:
fineractmysql:
condition: service_healthy
environment:
- DRIVERCLASS_NAME=org.mariadb.jdbc.Driver
- PROTOCOL=jdbc
- node_id=1
- SUB_PROTOCOL=mariadb
- fineract_tenants_driver=org.mariadb.jdbc.Driver
- fineract_tenants_url=jdbc:mariadb://fineractmysql:3306/fineract_tenants
- fineract_tenants_uid=root
- fineract_tenants_pwd=skdcnwauicn2ucnaecasdsajdnizucawencascdca
# TODO: env vars prefixed with "fineract_tenants_*" will be removed with one of the next releases
#- fineract_tenants_driver=org.mariadb.jdbc.Driver
#- fineract_tenants_url=jdbc:mariadb://fineractmysql:3306/fineract_tenants
#- fineract_tenants_uid=root
#- fineract_tenants_pwd=skdcnwauicn2ucnaecasdsajdnizucawencascdca
# NOTE: node aware scheduler
- FINERACT_NODE_ID=1
# NOTE: env vars prefixed "FINERACT_HIKARI_*" are used to configure the database connection pool
- FINERACT_HIKARI_DRIVER_CLASS_NAME=org.mariadb.jdbc.Driver
- FINERACT_HIKARI_JDBC_URL=jdbc:mariadb://fineractmysql:3306/fineract_tenants
- FINERACT_HIKARI_USERNAME=root
- FINERACT_HIKARI_PASSWORD=skdcnwauicn2ucnaecasdsajdnizucawencascdca
# ... following variables are optional; "application.properties" contains reasonable defaults (same as here)
- FINERACT_HIKARI_MINIMUM_IDLE=3
- FINERACT_HIKARI_MAXIMUM_POOL_SIZE=10
- FINERACT_HIKARI_IDLE_TIMEOUT=60000
- FINERACT_HIKARI_CONNECTION_TIMEOUT=20000
- FINERACT_HIKARI_TEST_QUERY=SELECT 1
- FINERACT_HIKARI_AUTO_COMMIT=true
- FINERACT_HIKARI_DS_PROPERTIES_CACHE_PREP_STMTS=true
- FINERACT_HIKARI_DS_PROPERTIES_PREP_STMT_CACHE_SIZE=250
- FINERACT_HIKARI_DS_PROPERTIES_PREP_STMT_CACHE_SQL_LIMIT=2048
- FINERACT_HIKARI_DS_PROPERTIES_USE_SERVER_PREP_STMTS=true
- FINERACT_HIKARI_DS_PROPERTIES_USE_LOCAL_SESSION_STATE=true
- FINERACT_HIKARI_DS_PROPERTIES_REWRITE_BATCHED_STATEMENTS=true
- FINERACT_HIKARI_DS_PROPERTIES_CACHE_RESULT_SET_METADATA=true
- FINERACT_HIKARI_DS_PROPERTIES_CACHE_SERVER_CONFIGURATION=true
- FINERACT_HIKARI_DS_PROPERTIES_ELIDE_SET_AUTO_COMMITS=true
- FINERACT_HIKARI_DS_PROPERTIES_MAINTAIN_TIME_STATS=false
- FINERACT_HIKARI_DS_PROPERTIES_LOG_SLOW_QUERIES=true
- FINERACT_HIKARI_DS_PROPERTIES_DUMP_QUERIES_IN_EXCEPTION=true
# NOTE: env vars prefixed "FINERACT_DEFAULT_TENANTDB_*" are used to create the default tenant database
- FINERACT_DEFAULT_TENANTDB_HOSTNAME=fineractmysql
- FINERACT_DEFAULT_TENANTDB_PORT=3306
- FINERACT_DEFAULT_TENANTDB_UID=root
- FINERACT_DEFAULT_TENANTDB_PWD=skdcnwauicn2ucnaecasdsajdnizucawencascdca
- FINERACT_DEFAULT_TENANTDB_CONN_PARAMS=
- FINERACT_DEFAULT_TENANTDB_TIMEZONE=Asia/Kolkata
- FINERACT_DEFAULT_TENANTDB_IDENTIFIER=default
- FINERACT_DEFAULT_TENANTDB_NAME=fineract_default
- FINERACT_DEFAULT_TENANTDB_DESCRIPTION=Default Demo Tenant

# Frontend service
community-app:
Expand Down
6 changes: 3 additions & 3 deletions fineract-provider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ configurations {
driver
}
dependencies {
driver 'org.mariadb.jdbc:mariadb-java-client:2.7.3'
driver 'org.mariadb.jdbc:mariadb-java-client:2.7.4'
}

URLClassLoader loader = GroovyObject.class.classLoader
Expand Down Expand Up @@ -238,7 +238,7 @@ bootRun {
]

dependencies {
implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.3'
implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.4'
}

classpath += files("build/generated/swagger-ui")
Expand Down Expand Up @@ -316,7 +316,7 @@ jib {
allowInsecureRegistries = true

dependencies {
implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.3'
implementation 'org.mariadb.jdbc:mariadb-java-client:2.7.4'
}

extraDirectories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@
*/
package org.apache.fineract.infrastructure.core.boot;

import org.apache.fineract.infrastructure.core.config.FineractProperties;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.transaction.annotation.EnableTransactionManagement;

Expand All @@ -36,12 +37,12 @@
*/

@Configuration
@PropertySource(value = "classpath:META-INF/spring/jdbc.properties")
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class, FlywayAutoConfiguration.class, GsonAutoConfiguration.class,
JdbcTemplateAutoConfiguration.class })
@EnableTransactionManagement
@EnableWebSecurity
@EnableConfigurationProperties({ FineractProperties.class })
@ComponentScan(basePackages = "org.apache.fineract.**")
public abstract class AbstractApplicationConfiguration {

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.fineract.infrastructure.core.config;

import com.zaxxer.hikari.HikariConfig;
import com.zaxxer.hikari.HikariDataSource;
import java.util.Properties;
import javax.annotation.PostConstruct;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

@Configuration
@ConditionalOnExpression("#{ systemEnvironment['fineract_tenants_driver'] != null }")
@Deprecated // NOTE: this will be removed in one of the next releases (probably around version 1.7.x or 1.8.x)
public class CompatibilityConfig {

private static final Logger LOG = LoggerFactory.getLogger(CompatibilityConfig.class);

@Autowired
ApplicationContext context;

@PostConstruct
public void init() {
Environment environment = context.getEnvironment();

LOG.warn("===============================================================================================\n");
LOG.warn("You are using a deprecated tenant DB configuration:\n");
LOG.warn("- Env var 'fineract_tenants_driver': {}",
environment.getProperty("fineract_tenants_driver"));
LOG.warn("- Env var 'fineract_tenants_url': {}",
environment.getProperty("fineract_tenants_url"));
LOG.warn("- Env var 'fineract_tenants_uid': {}",
environment.getProperty("fineract_tenants_uid"));
LOG.warn("- Env var 'fineract_tenants_pwd': ****\n");
LOG.warn("The preferred way to configure the tenant DB is now via these environment variables:\n");
LOG.warn("- Env var 'FINERACT_HIKARI_DRIVER_SOURCE_CLASS_NAME': {}",
environment.getProperty("FINERACT_HIKARI_DRIVER_SOURCE_CLASS_NAME"));
LOG.warn("- Env var 'FINERACT_HIKARI_JDBC_URL': {}",
environment.getProperty("FINERACT_HIKARI_JDBC_URL"));
LOG.warn("- Env var 'FINERACT_HIKARI_USERNAME': {}",
environment.getProperty("FINERACT_HIKARI_USERNAME"));
LOG.warn("- Env var 'FINERACT_HIKARI_PASSWORD': ****");
LOG.warn("- Env var 'FINERACT_HIKARI_MINIMUM_IDLE': {}",
environment.getProperty("FINERACT_HIKARI_MINIMUM_IDLE"));
LOG.warn("- Env var 'FINERACT_HIKARI_MAXIMUM_POOL_SIZE': {}",
environment.getProperty("FINERACT_HIKARI_MAXIMUM_POOL_SIZE"));
LOG.warn("- Env var 'FINERACT_HIKARI_IDLE_TIMEOUT': {}",
environment.getProperty("FINERACT_HIKARI_IDLE_TIMEOUT"));
LOG.warn("- Env var 'FINERACT_HIKARI_CONNECTION_TIMEOUT': {}",
environment.getProperty("FINERACT_HIKARI_CONNECTION_TIMEOUT"));
LOG.warn("- Env var 'FINERACT_HIKARI_TEST_QUERY': {}",
environment.getProperty("FINERACT_HIKARI_TEST_QUERY"));
LOG.warn("- Env var 'FINERACT_HIKARI_AUTO_COMMIT': {}",
environment.getProperty("FINERACT_HIKARI_AUTO_COMMIT"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_CACHE_PREP_STMTS': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_CACHE_PREP_STMTS"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_PREP_STMT_CACHE_SIZE': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_PREP_STMT_CACHE_SIZE"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_PREP_STMT_CACHE_SQL_LIMIT': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_PREP_STMT_CACHE_SQL_LIMIT"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_USE_SERVER_PREP_STMTS': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_USE_SERVER_PREP_STMTS"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_USE_LOCAL_SESSION_STATE': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_USE_LOCAL_SESSION_STATE"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_REWRITE_BATCHED_STATEMENTS': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_REWRITE_BATCHED_STATEMENTS"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_CACHE_RESULT_SET_METADATA': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_CACHE_RESULT_SET_METADATA"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_CACHE_SERVER_CONFIGURATION': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_CACHE_SERVER_CONFIGURATION"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_ELIDE_SET_AUTO_COMMITS': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_ELIDE_SET_AUTO_COMMITS"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_MAINTAIN_TIME_STATS': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_MAINTAIN_TIME_STATS"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_LOG_SLOW_QUERIES': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_LOG_SLOW_QUERIES"));
LOG.warn("- Env var 'FINERACT_HIKARI_DS_PROPERTIES_DUMP_QUERIES_IN_EXCEPTION': {}",
environment.getProperty("FINERACT_HIKARI_DS_PROPERTIES_DUMP_QUERIES_IN_EXCEPTION"));
LOG.warn("===============================================================================================\n");
}

@Bean(destroyMethod = "close")
public HikariDataSource hikariTenantDataSource(HikariConfig hc) {
return new HikariDataSource(hc);
}

@Bean
public HikariConfig hikariConfig() {
Environment environment = context.getEnvironment();
HikariConfig hc = new HikariConfig();

hc.setDriverClassName(environment.getProperty("fineract_tenants_driver"));
hc.setJdbcUrl(environment.getProperty("fineract_tenants_url"));
hc.setUsername(environment.getProperty("fineract_tenants_uid"));
hc.setPassword(environment.getProperty("fineract_tenants_pwd"));
hc.setMinimumIdle(3);
hc.setMaximumPoolSize(10);
hc.setIdleTimeout(60000);
hc.setConnectionTestQuery("SELECT 1");
hc.setDataSourceProperties(dataSourceProperties());

return hc;
}

// These are the properties for the all Tenants DB; the same configuration is also (hard-coded) in the
// TomcatJdbcDataSourcePerTenantService class -->
private Properties dataSourceProperties() {
Properties props = new Properties();

props.setProperty("cachePrepStmts", "true");
props.setProperty("prepStmtCacheSize", "250");
props.setProperty("prepStmtCacheSqlLimit", "2048");
props.setProperty("useServerPrepStmts", "true");
props.setProperty("useLocalSessionState", "true");
props.setProperty("rewriteBatchedStatements", "true");
props.setProperty("cacheResultSetMetadata", "true");
props.setProperty("cacheServerConfiguration", "true");
props.setProperty("elideSetAutoCommits", "true");
props.setProperty("maintainTimeStats", "false");

// https://github.com/brettwooldridge/HikariCP/wiki/JDBC-Logging#mysql-connectorj
// TODO FINERACT-890: <prop key="logger">com.mysql.cj.log.Slf4JLogger</prop>
props.setProperty("logSlowQueries", "true");
props.setProperty("dumpQueriesOnException", "true");

return props;
}
}
Loading