Changes to issue: MIFOSX-949
This commit is contained in:
committed by
Vishwas Babu A J
parent
e496ccf02a
commit
d079442e0e
@@ -73,6 +73,13 @@ CREATE TABLE `tenants` (
|
|||||||
`schema_username` varchar(100) NOT NULL DEFAULT 'root',
|
`schema_username` varchar(100) NOT NULL DEFAULT 'root',
|
||||||
`schema_password` varchar(100) NOT NULL DEFAULT 'mysql',
|
`schema_password` varchar(100) NOT NULL DEFAULT 'mysql',
|
||||||
`auto_update` tinyint(1) NOT NULL DEFAULT '1',
|
`auto_update` tinyint(1) NOT NULL DEFAULT '1',
|
||||||
|
`initial_size` int(5) DEFAULT NULL,
|
||||||
|
`validation_interval` int(60) DEFAULT NULL,
|
||||||
|
`remove_abandoned` varchar(10) DEFAULT NULL,
|
||||||
|
`remove_abandoned_timeout` int(10) DEFAULT NULL,
|
||||||
|
`log_abandoned` varchar(10) DEFAULT NULL,
|
||||||
|
`abondoned_when_percentage_full` int(10) DEFAULT NULL,
|
||||||
|
`test_on_borrow` varchar(10) DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`)
|
PRIMARY KEY (`id`)
|
||||||
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||||
|
|||||||
+45
-2
@@ -17,10 +17,18 @@ public class MifosPlatformTenant {
|
|||||||
private final String schemaPassword;
|
private final String schemaPassword;
|
||||||
private final String timezoneId;
|
private final String timezoneId;
|
||||||
private final boolean autoUpdateEnabled;
|
private final boolean autoUpdateEnabled;
|
||||||
|
private final int initialSize;
|
||||||
|
private final boolean testOnBorrow;
|
||||||
|
private final long validationInterval;
|
||||||
|
private final boolean removeAbandoned;
|
||||||
|
private final int removeAbandonedTimeout;
|
||||||
|
private final boolean logAbandoned;
|
||||||
|
private final int abandonWhenPercentageFull;
|
||||||
|
|
||||||
public MifosPlatformTenant(final Long id, final String tenantIdentifier, final String name, final String schemaName,
|
public MifosPlatformTenant(final Long id, final String tenantIdentifier, final String name, final String schemaName,
|
||||||
final String schemaServer, final String schemaServerPort, final String schemaUsername, final String schemaPassword,
|
final String schemaServer, final String schemaServerPort, final String schemaUsername, final String schemaPassword,
|
||||||
final String timezoneId, final boolean autoUpdateEnabled) {
|
final String timezoneId, final boolean autoUpdateEnabled,final int initialSize,final boolean testOnBorrow,final long validationInterval,
|
||||||
|
final boolean removeAbandoned,final int removeAbandonedTimeout,final boolean logAbandoned,final int abandonWhenPercentageFull) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.tenantIdentifier = tenantIdentifier;
|
this.tenantIdentifier = tenantIdentifier;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -31,6 +39,13 @@ public class MifosPlatformTenant {
|
|||||||
this.schemaPassword = schemaPassword;
|
this.schemaPassword = schemaPassword;
|
||||||
this.timezoneId = timezoneId;
|
this.timezoneId = timezoneId;
|
||||||
this.autoUpdateEnabled = autoUpdateEnabled;
|
this.autoUpdateEnabled = autoUpdateEnabled;
|
||||||
|
this.initialSize = initialSize;
|
||||||
|
this.testOnBorrow = testOnBorrow;
|
||||||
|
this.validationInterval = validationInterval;
|
||||||
|
this.removeAbandoned = removeAbandoned;
|
||||||
|
this.removeAbandonedTimeout = removeAbandonedTimeout;
|
||||||
|
this.logAbandoned = logAbandoned;
|
||||||
|
this.abandonWhenPercentageFull = abandonWhenPercentageFull;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String databaseURL() {
|
public String databaseURL() {
|
||||||
@@ -39,6 +54,34 @@ public class MifosPlatformTenant {
|
|||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getInitialSize() {
|
||||||
|
return initialSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTestOnBorrow() {
|
||||||
|
return testOnBorrow;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getValidationInterval() {
|
||||||
|
return validationInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRemoveAbandoned() {
|
||||||
|
return removeAbandoned;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRemoveAbandonedTimeout() {
|
||||||
|
return removeAbandonedTimeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLogAbandoned() {
|
||||||
|
return logAbandoned;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAbandonWhenPercentageFull() {
|
||||||
|
return abandonWhenPercentageFull;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getId() {
|
public Long getId() {
|
||||||
return this.id;
|
return this.id;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -73,7 +73,7 @@ public class TomcatJdbcDataSourcePerTenantService implements RoutingDataSourceSe
|
|||||||
poolConfiguration.setUsername(tenant.getSchemaUsername());
|
poolConfiguration.setUsername(tenant.getSchemaUsername());
|
||||||
poolConfiguration.setPassword(tenant.getSchemaPassword());
|
poolConfiguration.setPassword(tenant.getSchemaPassword());
|
||||||
|
|
||||||
poolConfiguration.setInitialSize(5);
|
poolConfiguration.setInitialSize(tenant.getInitialSize());
|
||||||
// poolConfiguration.setMaxActive(5);
|
// poolConfiguration.setMaxActive(5);
|
||||||
// poolConfiguration.setMinIdle(1);
|
// poolConfiguration.setMinIdle(1);
|
||||||
// poolConfiguration.setMaxIdle(4);
|
// poolConfiguration.setMaxIdle(4);
|
||||||
@@ -82,14 +82,14 @@ public class TomcatJdbcDataSourcePerTenantService implements RoutingDataSourceSe
|
|||||||
// poolConfiguration.setTimeBetweenEvictionRunsMillis(30000);
|
// poolConfiguration.setTimeBetweenEvictionRunsMillis(30000);
|
||||||
// poolConfiguration.setMinEvictableIdleTimeMillis(60000);
|
// poolConfiguration.setMinEvictableIdleTimeMillis(60000);
|
||||||
|
|
||||||
poolConfiguration.setTestOnBorrow(true);
|
poolConfiguration.setTestOnBorrow(tenant.isTestOnBorrow());
|
||||||
poolConfiguration.setValidationQuery("SELECT 1");
|
poolConfiguration.setValidationQuery("SELECT 1");
|
||||||
poolConfiguration.setValidationInterval(30000);
|
poolConfiguration.setValidationInterval(tenant.getValidationInterval());
|
||||||
|
|
||||||
poolConfiguration.setRemoveAbandoned(true);
|
poolConfiguration.setRemoveAbandoned(tenant.isRemoveAbandoned());
|
||||||
poolConfiguration.setRemoveAbandonedTimeout(60);
|
poolConfiguration.setRemoveAbandonedTimeout(tenant.getRemoveAbandonedTimeout());
|
||||||
poolConfiguration.setLogAbandoned(true);
|
poolConfiguration.setLogAbandoned(tenant.isLogAbandoned());
|
||||||
poolConfiguration.setAbandonWhenPercentageFull(50);
|
poolConfiguration.setAbandonWhenPercentageFull(tenant.getAbandonWhenPercentageFull());
|
||||||
|
|
||||||
poolConfiguration.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
|
poolConfiguration.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
|
||||||
+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport");
|
+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport");
|
||||||
|
|||||||
+10
-2
@@ -38,7 +38,7 @@ public class BasicAuthTenantDetailsServiceJdbc implements BasicAuthTenantDetails
|
|||||||
|
|
||||||
private final StringBuilder sqlBuilder = new StringBuilder(
|
private final StringBuilder sqlBuilder = new StringBuilder(
|
||||||
"id, name,identifier, schema_name as schemaName, schema_server as schemaServer, schema_server_port as schemaServerPort, auto_update as autoUpdate, ")//
|
"id, name,identifier, schema_name as schemaName, schema_server as schemaServer, schema_server_port as schemaServerPort, auto_update as autoUpdate, ")//
|
||||||
.append(" schema_username as schemaUsername, schema_password as schemaPassword , timezone_id as timezoneId ")//
|
.append(" schema_username as schemaUsername, schema_password as schemaPassword , timezone_id as timezoneId ,initial_size as initialSize,validation_interval as validationInterval,remove_abandoned as removeAbandoned,remove_abandoned_timeout as removeAbandonedTimeout,log_abandoned as logAbandoned,abondoned_when_percentage_full as abondonedWhenPercentageFull,test_on_borrow as testOnBorrow ")//
|
||||||
.append(" from tenants t");//
|
.append(" from tenants t");//
|
||||||
|
|
||||||
public String schema() {
|
public String schema() {
|
||||||
@@ -58,9 +58,17 @@ public class BasicAuthTenantDetailsServiceJdbc implements BasicAuthTenantDetails
|
|||||||
final String schemaPassword = rs.getString("schemaPassword");
|
final String schemaPassword = rs.getString("schemaPassword");
|
||||||
final String timezoneId = rs.getString("timezoneId");
|
final String timezoneId = rs.getString("timezoneId");
|
||||||
final boolean autoUpdateEnabled = rs.getBoolean("autoUpdate");
|
final boolean autoUpdateEnabled = rs.getBoolean("autoUpdate");
|
||||||
|
final int initialSize = rs.getInt("initialSize");
|
||||||
|
final boolean testOnBorrow = rs.getBoolean("testOnBorrow");
|
||||||
|
final long validationInterval = rs.getLong("validationInterval");
|
||||||
|
final boolean removeAbandoned = rs.getBoolean("removeAbandoned");
|
||||||
|
final int removeAbandonedTimeout = rs.getInt("removeAbandonedTimeout");
|
||||||
|
final boolean logAbandoned = rs.getBoolean("logAbandoned");
|
||||||
|
final int abandonWhenPercentageFull = rs.getInt("abondonedWhenPercentageFull");
|
||||||
|
|
||||||
return new MifosPlatformTenant(id, tenantIdentifier, name, schemaName, schemaServer, schemaServerPort, schemaUsername,
|
return new MifosPlatformTenant(id, tenantIdentifier, name, schemaName, schemaServer, schemaServerPort, schemaUsername,
|
||||||
schemaPassword, timezoneId, autoUpdateEnabled);
|
schemaPassword, timezoneId, autoUpdateEnabled,initialSize,testOnBorrow,validationInterval,removeAbandoned,removeAbandonedTimeout
|
||||||
|
,logAbandoned,abandonWhenPercentageFull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -39,7 +39,7 @@ public class JdbcTenantDetailsService implements TenantDetailsService {
|
|||||||
|
|
||||||
private final StringBuilder sqlBuilder = new StringBuilder(
|
private final StringBuilder sqlBuilder = new StringBuilder(
|
||||||
"id, name,identifier, schema_name as schemaName, schema_server as schemaServer, schema_server_port as schemaServerPort, auto_update as autoUpdate, ")//
|
"id, name,identifier, schema_name as schemaName, schema_server as schemaServer, schema_server_port as schemaServerPort, auto_update as autoUpdate, ")//
|
||||||
.append(" schema_username as schemaUsername, schema_password as schemaPassword , timezone_id as timezoneId ")//
|
.append(" schema_username as schemaUsername, schema_password as schemaPassword , timezone_id as timezoneId ,initial_size as initialSize,validation_interval as validationInterval,remove_abandoned as removeAbandoned,remove_abandoned_timeout as removeAbandonedTimeout,log_abandoned as logAbandoned,abondoned_when_percentage_full as abondonedWhenPercentageFull,test_on_borrow as testOnBorrow ")//
|
||||||
.append(" from tenants t");//
|
.append(" from tenants t");//
|
||||||
|
|
||||||
public String schema() {
|
public String schema() {
|
||||||
@@ -59,9 +59,17 @@ public class JdbcTenantDetailsService implements TenantDetailsService {
|
|||||||
final String schemaPassword = rs.getString("schemaPassword");
|
final String schemaPassword = rs.getString("schemaPassword");
|
||||||
final String timezoneId = rs.getString("timezoneId");
|
final String timezoneId = rs.getString("timezoneId");
|
||||||
final boolean autoUpdateEnabled = rs.getBoolean("autoUpdate");
|
final boolean autoUpdateEnabled = rs.getBoolean("autoUpdate");
|
||||||
|
final int initialSize = rs.getInt("initialSize");
|
||||||
|
final boolean testOnBorrow = rs.getBoolean("testOnBorrow");
|
||||||
|
final long validationInterval = rs.getLong("validationInterval");
|
||||||
|
final boolean removeAbandoned = rs.getBoolean("removeAbandoned");
|
||||||
|
final int removeAbandonedTimeout = rs.getInt("removeAbandonedTimeout");
|
||||||
|
final boolean logAbandoned = rs.getBoolean("logAbandoned");
|
||||||
|
final int abandonWhenPercentageFull = rs.getInt("abondonedWhenPercentageFull");
|
||||||
|
|
||||||
return new MifosPlatformTenant(id, tenantIdentifier, name, schemaName, schemaServer, schemaServerPort, schemaUsername,
|
return new MifosPlatformTenant(id, tenantIdentifier, name, schemaName, schemaServer, schemaServerPort, schemaUsername,
|
||||||
schemaPassword, timezoneId, autoUpdateEnabled);
|
schemaPassword, timezoneId, autoUpdateEnabled,initialSize,testOnBorrow,validationInterval,removeAbandoned,removeAbandonedTimeout
|
||||||
|
,logAbandoned,abandonWhenPercentageFull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user