use of com.pamirs.pradar.internal.config.ShadowDatabaseConfig in project LinkAgent by shulieTech.
the class DataSourceWrapUtil method generate.
public static ComboPooledDataSource generate(ComboPooledDataSource sourceDatasource) {
Map<String, ShadowDatabaseConfig> conf = GlobalConfig.getInstance().getShadowDatasourceConfigs();
if (conf == null) {
return null;
}
ShadowDatabaseConfig ptDataSourceConf = selectMatchPtDataSourceConfiguration(sourceDatasource, conf);
if (ptDataSourceConf == null) {
return null;
}
String url = ptDataSourceConf.getShadowUrl();
String username = ptDataSourceConf.getShadowUsername();
String password = ptDataSourceConf.getShadowPassword();
if (StringUtils.isBlank(url) || StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
return null;
}
String driverClassName = ptDataSourceConf.getShadowDriverClassName();
if (StringUtils.isBlank(driverClassName)) {
driverClassName = sourceDatasource.getDriverClass();
}
ComboPooledDataSource target = null;
String identityToken = sourceDatasource.getIdentityToken();
String datasourceName = sourceDatasource.getDataSourceName();
if (StringUtils.isNotBlank(datasourceName)) {
try {
target = new ComboPooledDataSource(Pradar.addClusterTestPrefix(datasourceName));
} catch (Throwable e) {
if (StringUtils.isNotBlank(identityToken)) {
try {
target = new ComboPooledDataSource(true);
} catch (Throwable t) {
target = new ComboPooledDataSource();
}
} else {
target = new ComboPooledDataSource();
}
}
} else if (StringUtils.isNotBlank(identityToken)) {
try {
target = new ComboPooledDataSource(true);
} catch (Throwable t) {
target = new ComboPooledDataSource();
}
} else {
target = new ComboPooledDataSource();
}
target.setJdbcUrl(url);
target.setUser(username);
target.setPassword(password);
try {
target.setDriverClass(driverClassName);
} catch (PropertyVetoException e) {
logger.error("[c3p0] can't found driver class name:{}", driverClassName, e);
PradarSwitcher.invalid();
return null;
}
Integer checkoutTimeout = ptDataSourceConf.getIntProperty("checkoutTimeout");
if (checkoutTimeout != null) {
target.setCheckoutTimeout(checkoutTimeout);
} else {
target.setCheckoutTimeout(sourceDatasource.getCheckoutTimeout());
}
Integer acquireIncrement = ptDataSourceConf.getIntProperty("acquireIncrement");
if (acquireIncrement != null) {
target.setAcquireIncrement(Integer.valueOf(acquireIncrement));
} else {
target.setAcquireIncrement(sourceDatasource.getAcquireIncrement());
}
Integer acquireRetryDelay = ptDataSourceConf.getIntProperty("acquireRetryDelay");
if (acquireRetryDelay != null) {
target.setAcquireRetryDelay(Integer.valueOf(acquireRetryDelay));
} else {
target.setAcquireRetryDelay(sourceDatasource.getAcquireRetryDelay());
}
Boolean autoCommitOnClose = ptDataSourceConf.getBooleanProperty("autoCommitOnClose");
if (autoCommitOnClose != null) {
target.setAutoCommitOnClose(Boolean.valueOf(autoCommitOnClose));
} else {
target.setAutoCommitOnClose(sourceDatasource.isAutoCommitOnClose());
}
String connectionTesterClassName = ptDataSourceConf.getProperty("connectionTesterClassName");
if (StringUtils.isNotBlank(connectionTesterClassName)) {
try {
target.setConnectionTesterClassName(connectionTesterClassName);
} catch (PropertyVetoException e) {
logger.error("[c3p0] can't found connectionTesterClassName:{}", connectionTesterClassName, e);
}
} else {
try {
target.setConnectionTesterClassName(sourceDatasource.getConnectionTesterClassName());
} catch (PropertyVetoException e) {
logger.error("[c3p0] can't found connectionTesterClassName:{}", sourceDatasource.getConnectionTesterClassName(), e);
}
}
String automaticTestTable = ptDataSourceConf.getProperty("automaticTestTable");
if (StringUtils.isNotBlank(automaticTestTable)) {
target.setAutomaticTestTable(automaticTestTable);
} else {
target.setAutomaticTestTable(sourceDatasource.getAutomaticTestTable());
}
Boolean forceIgnoreUnresolvedTransactions = ptDataSourceConf.getBooleanProperty("forceIgnoreUnresolvedTransactions");
if (forceIgnoreUnresolvedTransactions != null) {
target.setForceIgnoreUnresolvedTransactions(forceIgnoreUnresolvedTransactions);
} else {
target.setForceIgnoreUnresolvedTransactions(sourceDatasource.isForceIgnoreUnresolvedTransactions());
}
Integer idleConnectionTestPeriod = ptDataSourceConf.getIntProperty("idleConnectionTestPeriod");
if (idleConnectionTestPeriod != null) {
target.setIdleConnectionTestPeriod(idleConnectionTestPeriod);
} else {
target.setIdleConnectionTestPeriod(sourceDatasource.getIdleConnectionTestPeriod());
}
Integer initialPoolSize = ptDataSourceConf.getIntProperty("initialPoolSize");
if (initialPoolSize != null) {
target.setInitialPoolSize(Integer.valueOf(initialPoolSize));
} else {
target.setInitialPoolSize(sourceDatasource.getInitialPoolSize());
}
Integer maxIdleTime = ptDataSourceConf.getIntProperty("maxIdleTime");
if (maxIdleTime != null) {
target.setMaxIdleTime(Integer.valueOf(maxIdleTime));
} else {
target.setMaxIdleTime(sourceDatasource.getMaxIdleTime());
}
Integer maxPoolSize = ptDataSourceConf.getIntProperty("maxPoolSize");
if (maxPoolSize != null) {
target.setMaxPoolSize(maxPoolSize);
} else {
target.setMaxPoolSize(sourceDatasource.getMaxPoolSize());
}
Integer maxStatements = ptDataSourceConf.getIntProperty("maxStatements");
if (maxStatements != null) {
target.setMaxStatements(Integer.valueOf(maxStatements));
} else {
target.setMaxStatements(sourceDatasource.getMaxStatements());
}
Integer maxStatementsPerConnection = ptDataSourceConf.getIntProperty("maxStatementsPerConnection");
if (maxStatementsPerConnection != null) {
target.setMaxStatementsPerConnection(maxStatementsPerConnection);
} else {
target.setMaxStatementsPerConnection(sourceDatasource.getMaxStatementsPerConnection());
}
Integer minPoolSize = ptDataSourceConf.getIntProperty("minPoolSize");
if (minPoolSize != null) {
target.setMinPoolSize(Integer.valueOf(minPoolSize));
} else {
target.setMinPoolSize(sourceDatasource.getMinPoolSize());
}
String overrideDefaultUser = ptDataSourceConf.getProperty("overrideDefaultUser");
if (StringUtils.isNotBlank(overrideDefaultUser)) {
target.setOverrideDefaultUser(overrideDefaultUser);
} else {
target.setOverrideDefaultUser(sourceDatasource.getOverrideDefaultUser());
}
String overrideDefaultPassword = ptDataSourceConf.getProperty("overrideDefaultPassword");
if (StringUtils.isNotBlank(overrideDefaultPassword)) {
target.setOverrideDefaultPassword(overrideDefaultPassword);
} else {
target.setOverrideDefaultPassword(sourceDatasource.getOverrideDefaultPassword());
}
Integer propertyCycle = ptDataSourceConf.getIntProperty("propertyCycle");
if (propertyCycle != null) {
target.setPropertyCycle(propertyCycle);
} else {
target.setPropertyCycle(sourceDatasource.getPropertyCycle());
}
Boolean breakAfterAcquireFailure = ptDataSourceConf.getBooleanProperty("breakAfterAcquireFailure");
if (breakAfterAcquireFailure != null) {
target.setBreakAfterAcquireFailure(breakAfterAcquireFailure);
} else {
target.setBreakAfterAcquireFailure(sourceDatasource.isBreakAfterAcquireFailure());
}
Boolean testConnectionOnCheckout = ptDataSourceConf.getBooleanProperty("testConnectionOnCheckout");
if (testConnectionOnCheckout != null) {
target.setTestConnectionOnCheckout(testConnectionOnCheckout);
} else {
target.setTestConnectionOnCheckout(sourceDatasource.isTestConnectionOnCheckout());
}
Boolean testConnectionOnCheckin = ptDataSourceConf.getBooleanProperty("testConnectionOnCheckin");
if (testConnectionOnCheckin != null) {
target.setTestConnectionOnCheckin(testConnectionOnCheckin);
} else {
target.setTestConnectionOnCheckin(sourceDatasource.isTestConnectionOnCheckin());
}
Boolean usesTraditionalReflectiveProxies = ptDataSourceConf.getBooleanProperty("usesTraditionalReflectiveProxies");
if (usesTraditionalReflectiveProxies != null) {
target.setUsesTraditionalReflectiveProxies(usesTraditionalReflectiveProxies);
} else {
target.setUsesTraditionalReflectiveProxies(sourceDatasource.isUsesTraditionalReflectiveProxies());
}
String preferredTestQuery = ptDataSourceConf.getProperty("preferredTestQuery");
if (StringUtils.isNotBlank(preferredTestQuery)) {
target.setPreferredTestQuery(preferredTestQuery);
} else {
target.setPreferredTestQuery(sourceDatasource.getPreferredTestQuery());
}
String userOverridesAsString = ptDataSourceConf.getProperty("userOverridesAsString");
if (StringUtils.isNotBlank(userOverridesAsString)) {
try {
target.setUserOverridesAsString(userOverridesAsString);
} catch (PropertyVetoException e) {
logger.error("[c3p0] can't found userOverridesAsString:{}", userOverridesAsString, e);
}
} else {
try {
target.setUserOverridesAsString(sourceDatasource.getUserOverridesAsString());
} catch (PropertyVetoException e) {
logger.error("[c3p0] can't found userOverridesAsString:{}", sourceDatasource.getUserOverridesAsString(), e);
}
}
Integer maxAdministrativeTaskTime = ptDataSourceConf.getIntProperty("maxAdministrativeTaskTime");
if (maxAdministrativeTaskTime != null) {
target.setMaxAdministrativeTaskTime(maxAdministrativeTaskTime);
} else {
target.setMaxAdministrativeTaskTime(sourceDatasource.getMaxAdministrativeTaskTime());
}
Integer maxIdleTimeExcessConnections = ptDataSourceConf.getIntProperty("maxIdleTimeExcessConnections");
if (maxIdleTimeExcessConnections != null) {
target.setMaxIdleTimeExcessConnections(maxIdleTimeExcessConnections);
} else {
target.setMaxIdleTimeExcessConnections(sourceDatasource.getMaxIdleTimeExcessConnections());
}
Integer maxConnectionAge = ptDataSourceConf.getIntProperty("maxConnectionAge");
if (maxConnectionAge != null) {
target.setMaxConnectionAge(maxConnectionAge);
} else {
target.setMaxConnectionAge(sourceDatasource.getMaxConnectionAge());
}
String connectionCustomizerClassName = ptDataSourceConf.getProperty("connectionCustomizerClassName");
if (StringUtils.isNotBlank(connectionCustomizerClassName)) {
target.setConnectionCustomizerClassName(connectionCustomizerClassName);
} else {
target.setConnectionCustomizerClassName(sourceDatasource.getConnectionCustomizerClassName());
}
Integer unreturnedConnectionTimeout = ptDataSourceConf.getIntProperty("unreturnedConnectionTimeout");
if (unreturnedConnectionTimeout != null) {
target.setUnreturnedConnectionTimeout(unreturnedConnectionTimeout);
} else {
target.setUnreturnedConnectionTimeout(sourceDatasource.getUnreturnedConnectionTimeout());
}
Boolean debugUnreturnedConnectionStackTraces = ptDataSourceConf.getBooleanProperty("debugUnreturnedConnectionStackTraces");
if (debugUnreturnedConnectionStackTraces != null) {
target.setDebugUnreturnedConnectionStackTraces(debugUnreturnedConnectionStackTraces);
} else {
target.setDebugUnreturnedConnectionStackTraces(sourceDatasource.isDebugUnreturnedConnectionStackTraces());
}
String factoryClassLocation = ptDataSourceConf.getProperty("factoryClassLocation");
if (StringUtils.isNotBlank(factoryClassLocation)) {
target.setFactoryClassLocation(factoryClassLocation);
} else {
target.setFactoryClassLocation(sourceDatasource.getFactoryClassLocation());
}
return target;
}
use of com.pamirs.pradar.internal.config.ShadowDatabaseConfig in project LinkAgent by shulieTech.
the class AtomikosDataSourceBeanWrapUtil method selectMatchPtDataSourceConfiguration.
private static ShadowDatabaseConfig selectMatchPtDataSourceConfiguration(AtomikosDataSourceBean source, Map<String, ShadowDatabaseConfig> shadowDbConfigurations) {
String key = DbUrlUtils.getKey(getUrl(source), getUsername(source));
ShadowDatabaseConfig shadowDatabaseConfig = shadowDbConfigurations.get(key);
if (shadowDatabaseConfig == null) {
key = DbUrlUtils.getKey(getUrl(source), null);
shadowDatabaseConfig = shadowDbConfigurations.get(key);
}
return shadowDatabaseConfig;
}
use of com.pamirs.pradar.internal.config.ShadowDatabaseConfig in project LinkAgent by shulieTech.
the class AtomikosNonXADataSourceBeanWrapUtil method generate.
public static AtomikosNonXADataSourceBean generate(AtomikosNonXADataSourceBean sourceDatasource) {
Map<String, ShadowDatabaseConfig> conf = GlobalConfig.getInstance().getShadowDatasourceConfigs();
if (conf == null) {
return null;
}
ShadowDatabaseConfig ptDataSourceConf = selectMatchPtDataSourceConfiguration(sourceDatasource, conf);
if (ptDataSourceConf == null) {
return null;
}
String url = ptDataSourceConf.getShadowUrl();
String username = ptDataSourceConf.getShadowUsername();
String password = ptDataSourceConf.getShadowPassword();
String driverClassName = ptDataSourceConf.getShadowDriverClassName();
if (StringUtils.isBlank(driverClassName)) {
driverClassName = sourceDatasource.getDriverClassName();
}
if (StringUtils.isBlank(url) || StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
logger.error("ATOMIKOS: url/username/password can't not be null,{} {} {}", url, username, password);
return null;
}
AtomikosNonXADataSourceBean target = new AtomikosNonXADataSourceBean();
target.setUrl(url);
target.setUser(username);
target.setPassword(password);
target.setDriverClassName(driverClassName);
Integer minPoolSize = ptDataSourceConf.getIntProperty("minPoolSize");
if (minPoolSize != null) {
target.setMinPoolSize(minPoolSize);
} else {
target.setMinPoolSize(sourceDatasource.getMinPoolSize());
}
Integer maxPoolSize = ptDataSourceConf.getIntProperty("maxPoolSize");
if (maxPoolSize != null) {
target.setMaxPoolSize(maxPoolSize);
} else {
target.setMaxPoolSize(sourceDatasource.getMaxPoolSize());
}
Integer poolSize = ptDataSourceConf.getIntProperty("poolSize");
if (poolSize != null) {
target.setPoolSize(poolSize);
}
Integer borrowConnectionTimeout = ptDataSourceConf.getIntProperty("borrowConnectionTimeout");
if (borrowConnectionTimeout != null) {
target.setBorrowConnectionTimeout(borrowConnectionTimeout);
} else {
target.setBorrowConnectionTimeout(sourceDatasource.getBorrowConnectionTimeout());
}
Integer reapTimeout = ptDataSourceConf.getIntProperty("reapTimeout");
if (reapTimeout != null) {
target.setReapTimeout(reapTimeout);
} else {
target.setReapTimeout(sourceDatasource.getReapTimeout());
}
Integer maintenanceInterval = ptDataSourceConf.getIntProperty("maintenanceInterval");
if (maintenanceInterval != null) {
target.setMaintenanceInterval(Integer.valueOf(maintenanceInterval));
} else {
target.setMaintenanceInterval(sourceDatasource.getMaintenanceInterval());
}
Integer maxIdleTime = ptDataSourceConf.getIntProperty("maxIdleTime");
if (maxIdleTime != null) {
target.setMaxIdleTime(Integer.valueOf(maxIdleTime));
} else {
target.setMaxIdleTime(sourceDatasource.getMaxIdleTime());
}
Integer maxLifetime = ptDataSourceConf.getIntProperty("maxLifetime");
if (maxLifetime != null) {
target.setMaxLifetime(Integer.valueOf(maxLifetime));
} else {
target.setMaxLifetime(sourceDatasource.getMaxLifetime());
}
String testQuery = ptDataSourceConf.getProperty("testQuery");
if (StringUtils.isNotBlank(testQuery)) {
target.setTestQuery(testQuery);
}
Boolean concurrentConnectionValidation = ptDataSourceConf.getBooleanProperty("concurrentConnectionValidation");
if (concurrentConnectionValidation != null) {
target.setConcurrentConnectionValidation(Boolean.valueOf(concurrentConnectionValidation));
}
String resourceName = ptDataSourceConf.getProperty("resourceName");
if (StringUtils.isNotBlank(resourceName)) {
target.setUniqueResourceName(resourceName);
} else {
target.setUniqueResourceName(Pradar.addClusterTestPrefix(sourceDatasource.getUniqueResourceName()));
}
Integer defaultIsolationLevel = ptDataSourceConf.getIntProperty("defaultIsolationLevel");
if (defaultIsolationLevel != null) {
target.setDefaultIsolationLevel(Integer.valueOf(defaultIsolationLevel));
}
return target;
}
use of com.pamirs.pradar.internal.config.ShadowDatabaseConfig in project LinkAgent by shulieTech.
the class ProxyStatementInvokeInterceptor method getParameter0.
@Override
public Object[] getParameter0(Advice advice) throws Throwable {
Object[] args = advice.getParameterArray();
if (!Pradar.isClusterTest() || args == null || args.length != 3) {
return args;
}
if (!(args[2] instanceof Object[])) {
return args;
}
Object[] methodArgs = (Object[]) args[2];
if (methodArgs == null || methodArgs.length == 0) {
return args;
}
if (!(methodArgs[0] instanceof String)) {
return args;
}
initConnectionPropertiesMethod(advice.getTarget());
Object connectionPool = Reflect.on(advice.getTarget()).call(getConnectionPoolMethod).get();
Object connectionPoolDefinition = Reflect.on(connectionPool).call(getDefinitionMethod).get();
String url = Reflect.on(connectionPoolDefinition).call(getUrlMethod).get();
if (url != null) {
final int index = url.indexOf('?');
if (index != -1) {
url = url.substring(0, index);
}
}
String username = Reflect.on(connectionPoolDefinition).call(getUserMethod).get();
String dbType = JdbcUtils.getDbType(url, JdbcUtils.getDriverClassName(url));
boolean useTable = !DatabaseUtils.isShadowDatasource(url, username);
String dbConnectionKey = DbUrlUtils.getKey(url, username);
if (!GlobalConfig.getInstance().containsShadowDatabaseConfig(dbConnectionKey)) {
dbConnectionKey = DbUrlUtils.getKey(url, null);
}
// 因为获取的 url 和 username 有可能是影子的 url 和 username,需要是影子的 url 和 username 需要将是否影子表以及 dbConnectionKey 重新拿业务的 url 和 username计算
if (!GlobalConfig.getInstance().containsShadowDatabaseConfig(dbConnectionKey)) {
for (Map.Entry<String, ShadowDatabaseConfig> entry : GlobalConfig.getInstance().getShadowDatasourceConfigs().entrySet()) {
if (StringUtils.equals(entry.getValue().getShadowUrl(), url) && StringUtils.equals(entry.getValue().getShadowUsername(), username)) {
String bizUrl = entry.getValue().getUrl();
String bizUser = entry.getValue().getUsername();
dbConnectionKey = DbUrlUtils.getKey(bizUrl, bizUser);
useTable = !DatabaseUtils.isShadowDatasource(bizUrl, bizUser);
break;
}
}
}
String sql = (String) methodArgs[0];
String ptSql = null;
if (useTable) {
try {
ptSql = SqlParser.replaceTable(sql, dbConnectionKey, dbType, "proxool");
} catch (SQLException e) {
throw new PressureMeasureError(e.getMessage());
}
} else {
ptSql = SqlParser.replaceSchema(sql, dbConnectionKey, dbType);
}
((Object[]) args[2])[0] = ptSql;
return args;
}
use of com.pamirs.pradar.internal.config.ShadowDatabaseConfig in project LinkAgent by shulieTech.
the class DataSourceWrapUtil method generate.
public static ProxoolDataSource generate(ProxoolDataSource sourceDatasource) {
Map<String, ShadowDatabaseConfig> conf = GlobalConfig.getInstance().getShadowDatasourceConfigs();
if (conf == null) {
return null;
}
ShadowDatabaseConfig ptDataSourceConf = selectMatchPtDataSourceConfiguration(sourceDatasource, conf);
if (ptDataSourceConf == null) {
return null;
}
String url = ptDataSourceConf.getShadowUrl();
String username = ptDataSourceConf.getShadowUsername();
String password = ptDataSourceConf.getShadowPassword();
if (StringUtils.isBlank(url) || StringUtils.isBlank(username) || StringUtils.isBlank(password)) {
return null;
}
String driverClassName = ptDataSourceConf.getShadowDriverClassName();
if (StringUtils.isBlank(driverClassName)) {
driverClassName = sourceDatasource.getDriver();
}
ProxoolDataSource target = null;
String datasourceName = sourceDatasource.getAlias();
if (StringUtils.isNotBlank(datasourceName)) {
try {
target = new ProxoolDataSource(Pradar.addClusterTestPrefix(datasourceName));
} catch (Throwable e) {
target = new ProxoolDataSource();
}
} else {
target = new ProxoolDataSource();
}
target.setDriverUrl(url);
target.setUser(username);
target.setPassword(password);
target.setDriver(driverClassName);
String checkoutTimeout = ptDataSourceConf.getProperty("fatal-sql-exception");
if (checkoutTimeout != null) {
target.setFatalSqlExceptionsAsString(checkoutTimeout);
} else {
target.setFatalSqlExceptionsAsString(sourceDatasource.getFatalSqlExceptionsAsString());
}
String fatalSqlExceptionWrapperClass = ptDataSourceConf.getProperty("fatal-sql-exception-wrapper-class");
if (fatalSqlExceptionWrapperClass != null) {
target.setFatalSqlExceptionWrapperClass(fatalSqlExceptionWrapperClass);
} else {
target.setFatalSqlExceptionWrapperClass(sourceDatasource.getFatalSqlExceptionWrapperClass());
}
Integer houseKeepingSleepTime = ptDataSourceConf.getIntProperty("house-keeping-sleep-time");
if (houseKeepingSleepTime != null) {
target.setHouseKeepingSleepTime(houseKeepingSleepTime);
} else {
target.setHouseKeepingSleepTime((int) sourceDatasource.getHouseKeepingSleepTime());
}
String houseKeepingTestSql = ptDataSourceConf.getProperty("house-keeping-test-sql");
if (houseKeepingTestSql != null) {
target.setHouseKeepingTestSql(houseKeepingTestSql);
} else {
target.setHouseKeepingTestSql(sourceDatasource.getHouseKeepingTestSql());
}
Boolean jmx = ptDataSourceConf.getBooleanProperty("jmx");
if (jmx != null) {
target.setJmx(jmx);
} else {
target.setJmx(sourceDatasource.isJmx());
}
String jmxAgentId = ptDataSourceConf.getProperty("jmx-agent-id");
if (jmxAgentId != null) {
target.setJmxAgentId(jmxAgentId);
} else {
target.setJmxAgentId(sourceDatasource.getJmxAgentId());
}
Integer maximumActiveTime = ptDataSourceConf.getIntProperty("maximum-active-time");
if (maximumActiveTime != null) {
target.setMaximumActiveTime(maximumActiveTime);
} else {
target.setMaximumActiveTime(sourceDatasource.getMaximumActiveTime());
}
Integer maximumConnectionCount = ptDataSourceConf.getIntProperty("maximum-connection-count");
if (maximumConnectionCount != null) {
target.setMaximumConnectionCount(maximumConnectionCount);
} else {
target.setMaximumConnectionCount(sourceDatasource.getMaximumConnectionCount());
}
Integer maximumConnectionLifetime = ptDataSourceConf.getIntProperty("maximum-connection-lifetime");
if (maximumConnectionLifetime != null) {
target.setMaximumConnectionLifetime(maximumConnectionLifetime);
} else {
target.setMaximumConnectionLifetime((int) sourceDatasource.getMaximumConnectionLifetime());
}
Integer maximumNewConnections = ptDataSourceConf.getIntProperty("maximum-new-connections");
if (maximumNewConnections != null) {
target.setMaximumConnectionCount(maximumNewConnections);
} else {
target.setMaximumConnectionCount(sourceDatasource.getMaximumConnectionCount());
}
Integer minimumConnectionCount = ptDataSourceConf.getIntProperty("minimum-connection-count");
if (minimumConnectionCount != null) {
target.setMinimumConnectionCount(minimumConnectionCount);
} else {
target.setMinimumConnectionCount(sourceDatasource.getMinimumConnectionCount());
}
Integer overloadWithoutRefusalLifetime = ptDataSourceConf.getIntProperty("overload-without-refusal-lifetime");
if (overloadWithoutRefusalLifetime != null) {
target.setOverloadWithoutRefusalLifetime(overloadWithoutRefusalLifetime);
} else {
target.setOverloadWithoutRefusalLifetime((int) sourceDatasource.getOverloadWithoutRefusalLifetime());
}
Integer prototypeCount = ptDataSourceConf.getIntProperty("prototype-count");
if (prototypeCount != null) {
target.setPrototypeCount(prototypeCount);
} else {
target.setPrototypeCount(sourceDatasource.getPrototypeCount());
}
Integer recentlyStartedThreshold = ptDataSourceConf.getIntProperty("recently-started-threshold");
if (recentlyStartedThreshold != null) {
target.setRecentlyStartedThreshold(recentlyStartedThreshold);
} else {
target.setRecentlyStartedThreshold((int) sourceDatasource.getRecentlyStartedThreshold());
}
Integer simultaneousBuildThrottle = ptDataSourceConf.getIntProperty("simultaneous-build-throttle");
if (simultaneousBuildThrottle != null) {
target.setSimultaneousBuildThrottle(simultaneousBuildThrottle);
} else {
target.setSimultaneousBuildThrottle(sourceDatasource.getSimultaneousBuildThrottle());
}
String statistics = ptDataSourceConf.getProperty("statistics");
if (statistics != null) {
target.setStatistics(statistics);
} else {
target.setStatistics(sourceDatasource.getStatistics());
}
String statisticsLogLevel = ptDataSourceConf.getProperty("statistics-log-level");
if (statisticsLogLevel != null) {
target.setStatisticsLogLevel(statisticsLogLevel);
} else {
target.setStatisticsLogLevel(sourceDatasource.getStatisticsLogLevel());
}
Boolean testBeforeUse = ptDataSourceConf.getBooleanProperty("test-before-use");
if (testBeforeUse != null) {
target.setTestBeforeUse(testBeforeUse);
} else {
target.setTestBeforeUse(sourceDatasource.isTestBeforeUse());
}
Boolean testAfterUse = ptDataSourceConf.getBooleanProperty("test-after-use");
if (testAfterUse != null) {
target.setTestAfterUse(testAfterUse);
} else {
target.setTestAfterUse(sourceDatasource.isTestAfterUse());
}
Boolean trace = ptDataSourceConf.getBooleanProperty("trace");
if (trace != null) {
target.setTrace(trace);
} else {
target.setTrace(sourceDatasource.isTrace());
}
Boolean verbose = ptDataSourceConf.getBooleanProperty("verbose");
if (verbose != null) {
target.setVerbose(verbose);
} else {
target.setVerbose(sourceDatasource.isVerbose());
}
return target;
}
Aggregations