Changes to issue: MIFOSX-949

This commit is contained in:
Channa Gayan
2014-03-18 20:51:28 -07:00
committed by Vishwas Babu A J
parent e496ccf02a
commit d079442e0e
5 changed files with 79 additions and 13 deletions
@@ -73,6 +73,13 @@ CREATE TABLE `tenants` (
`schema_username` varchar(100) NOT NULL DEFAULT 'root',
`schema_password` varchar(100) NOT NULL DEFAULT 'mysql',
`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`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;
@@ -17,10 +17,18 @@ public class MifosPlatformTenant {
private final String schemaPassword;
private final String timezoneId;
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,
final String schemaServer, final String schemaServerPort, final String schemaUsername, final String schemaPassword,
final String timezoneId, final boolean autoUpdateEnabled) {
final String schemaServer, final String schemaServerPort, final String schemaUsername, final String schemaPassword,
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.tenantIdentifier = tenantIdentifier;
this.name = name;
@@ -31,6 +39,13 @@ public class MifosPlatformTenant {
this.schemaPassword = schemaPassword;
this.timezoneId = timezoneId;
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() {
@@ -39,6 +54,34 @@ public class MifosPlatformTenant {
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() {
return this.id;
}
@@ -73,7 +73,7 @@ public class TomcatJdbcDataSourcePerTenantService implements RoutingDataSourceSe
poolConfiguration.setUsername(tenant.getSchemaUsername());
poolConfiguration.setPassword(tenant.getSchemaPassword());
poolConfiguration.setInitialSize(5);
poolConfiguration.setInitialSize(tenant.getInitialSize());
// poolConfiguration.setMaxActive(5);
// poolConfiguration.setMinIdle(1);
// poolConfiguration.setMaxIdle(4);
@@ -82,14 +82,14 @@ public class TomcatJdbcDataSourcePerTenantService implements RoutingDataSourceSe
// poolConfiguration.setTimeBetweenEvictionRunsMillis(30000);
// poolConfiguration.setMinEvictableIdleTimeMillis(60000);
poolConfiguration.setTestOnBorrow(true);
poolConfiguration.setTestOnBorrow(tenant.isTestOnBorrow());
poolConfiguration.setValidationQuery("SELECT 1");
poolConfiguration.setValidationInterval(30000);
poolConfiguration.setValidationInterval(tenant.getValidationInterval());
poolConfiguration.setRemoveAbandoned(true);
poolConfiguration.setRemoveAbandonedTimeout(60);
poolConfiguration.setLogAbandoned(true);
poolConfiguration.setAbandonWhenPercentageFull(50);
poolConfiguration.setRemoveAbandoned(tenant.isRemoveAbandoned());
poolConfiguration.setRemoveAbandonedTimeout(tenant.getRemoveAbandonedTimeout());
poolConfiguration.setLogAbandoned(tenant.isLogAbandoned());
poolConfiguration.setAbandonWhenPercentageFull(tenant.getAbandonWhenPercentageFull());
poolConfiguration.setJdbcInterceptors("org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"
+ "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer;org.apache.tomcat.jdbc.pool.interceptor.SlowQueryReport");
@@ -38,7 +38,7 @@ public class BasicAuthTenantDetailsServiceJdbc implements BasicAuthTenantDetails
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, ")//
.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");//
public String schema() {
@@ -58,9 +58,17 @@ public class BasicAuthTenantDetailsServiceJdbc implements BasicAuthTenantDetails
final String schemaPassword = rs.getString("schemaPassword");
final String timezoneId = rs.getString("timezoneId");
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,
schemaPassword, timezoneId, autoUpdateEnabled);
schemaPassword, timezoneId, autoUpdateEnabled,initialSize,testOnBorrow,validationInterval,removeAbandoned,removeAbandonedTimeout
,logAbandoned,abandonWhenPercentageFull);
}
}
@@ -39,7 +39,7 @@ public class JdbcTenantDetailsService implements TenantDetailsService {
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, ")//
.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");//
public String schema() {
@@ -59,9 +59,17 @@ public class JdbcTenantDetailsService implements TenantDetailsService {
final String schemaPassword = rs.getString("schemaPassword");
final String timezoneId = rs.getString("timezoneId");
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,
schemaPassword, timezoneId, autoUpdateEnabled);
schemaPassword, timezoneId, autoUpdateEnabled,initialSize,testOnBorrow,validationInterval,removeAbandoned,removeAbandonedTimeout
,logAbandoned,abandonWhenPercentageFull);
}
}