support phyMaxUseCount

This commit is contained in:
wenshao
2018-10-13 20:09:22 +08:00
parent f69e367e65
commit 66bb235f9b
2 changed files with 23 additions and 0 deletions
@@ -333,6 +333,17 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
}
}
}
{
String property = properties.getProperty("druid.phyMaxUseCount");
if (property != null && property.length() > 0) {
try {
long value = Long.parseLong(property);
this.setPhyMaxUseCount(value);
} catch (NumberFormatException e) {
LOG.error("illegal property 'druid.phyMaxUseCount'", e);
}
}
}
{
String property = properties.getProperty("druid.minEvictableIdleTimeMillis");
if (property != null && property.length() > 0) {
@@ -21,6 +21,18 @@ public class DruidDataSourceTest9_phyMaxUseCount extends TestCase {
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setInitialSize(1);
dataSource.setPhyMaxUseCount(10);
assertEquals(10, dataSource.getPhyMaxUseCount());
Properties properties = new Properties();
properties.put("druid.phyMaxUseCount", "20");
dataSource.configFromPropety(properties);
assertEquals(20, dataSource.getPhyMaxUseCount());
properties.put("druid.phyMaxUseCount", "10");
dataSource.configFromPropety(properties);
assertEquals(10, dataSource.getPhyMaxUseCount());
dataSource.setFilters("log4j");
}