Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Target:druid, Action:connectionpoolfull cannot take effect #58

Open
canyuns opened this issue Jul 15, 2019 · 1 comment
Open

Target:druid, Action:connectionpoolfull cannot take effect #58

canyuns opened this issue Jul 15, 2019 · 1 comment
Labels
type/bug Category issues or prs related to bug.

Comments

@canyuns
Copy link

canyuns commented Jul 15, 2019

Target:druid
Action:connectionpoolfull
现象:不能生效

初步诊断:如下位置加入日志,未打印,代码没进来,同时其他 Target,像 dubbo、jvm 都能生效,说明 sandbox 挂载没问题。
`
public class DruidDataSourceEnhancer extends BeforeEnhancer {
private static final Logger LOGGER = LoggerFactory.getLogger(DruidDataSourceEnhancer.class);

@Override
public EnhancerModel doBeforeAdvice(ClassLoader classLoader, String className, Object object, Method method,
                                    Object[] methodArguments) throws Exception {
    LOGGER.info("before if");
    if (object != null && DataSource.class.isInstance(object)) {
        LOGGER.info("in if");
        DruidConnectionPoolFullExecutor.INSTANCE.setDataSource(object);
    }
    return null;
}

}
`

版本信息:
chaosblade-exec-jvm:v0.1.0;
druid-spring-boot-starter-1.0.2.3-RELEASE
druid:druid-1.1.3

使用方式:
`
DataSource xDataSource() {
return DataSourceConfigurationSupport.dataSourceOf(xDataSourceProperties());
}

public static DruidDataSource dataSourceOf(DruidDataSourceProperties properties) {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName(properties.getDriverClassName());
dataSource.setUrl(properties.getUrl());
dataSource.setUsername(properties.getUsername());
dataSource.setPassword(properties.getPassword());
dataSource.setInitialSize(properties.getInitialSize());
dataSource.setMaxActive(properties.getMaxActive());
dataSource.setMinIdle(properties.getMinIdle());
dataSource.setMaxWait((long)properties.getMaxWait());
dataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements());
dataSource.setMaxPoolPreparedStatementPerConnectionSize(properties.getMaxPoolPreparedStatementPerConnectionSize());
dataSource.setValidationQuery(properties.getValidationQuery());
dataSource.setValidationQueryTimeout(properties.getValidationQueryTimeout());
dataSource.setTestOnBorrow(properties.isTestOnBorrow());
dataSource.setTestOnReturn(properties.isTestOnReturn());
dataSource.setTestWhileIdle(properties.isTestWhileIdle());
dataSource.setTimeBetweenEvictionRunsMillis((long)properties.getTimeBetweenEvictionRunsMillis());
dataSource.setMinEvictableIdleTimeMillis((long)properties.getMinEvictableIdleTimeMillis());
dataSource.setMaxEvictableIdleTimeMillis((long)properties.getMaxEvictableIdleTimeMillis());
dataSource.setPhyTimeoutMillis((long)properties.getPhyTimeoutMillis());
dataSource.setRemoveAbandoned(properties.isRemoveAbandoned());
dataSource.setRemoveAbandonedTimeout(properties.getRemoveAbandonedTimeout());
dataSource.setConnectProperties(toProperties(properties.getConnectionProperties()));
dataSource.setDefaultAutoCommit(properties.isDefaultAutoCommit());
dataSource.setLogAbandoned(properties.isLogAbandoned());
dataSource.setProxyFilters(properties.getFilters());
return dataSource;
}
`

@chaosblade-bot
Copy link
Collaborator

Hi @canyuns, we detect non-English characters in the issue. This comment is an auto translation from @chaosblade-bot to help other users to understand this issue.
We encourage you to describe your issue in English which is more friendly to other users.

Target:druid, Action:connectionpoolfull cannot take effect

Target:druid
Action:connectionpoolfull
Phenomenon: Cannot take effect

Initial diagnosis: the following location is added to the log, not printed, the code does not come in, and other Targets, such as dubbo and jvm, can take effect, indicating that the sandbox is mounted without problems.
`
public class DruidDataSourceEnhancer extends BeforeEnhancer {
private static final Logger LOGGER = LoggerFactory.getLogger(DruidDataSourceEnhancer.class);

@Override
public EnhancerModel doBeforeAdvice(ClassLoader classLoader, String className, Object object, Method method,
                                    Object[] methodArguments) throws Exception {
    LOGGER.info("before if");
    if (object != null && DataSource.class.isInstance(object)) {
        LOGGER.info("in if");
        DruidConnectionPoolFullExecutor.INSTANCE.setDataSource(object);
    }
    return null;
}

}
`

Version Information:
chaosblade-exec-jvm:v0.1.0;
druid-spring-boot-starter-1.0.2.3-RELEASE
druid:druid-1.1.3

How to use:
`
DataSource xDataSource() {
return DataSourceConfigurationSupport.dataSourceOf(xDataSourceProperties());
}

public static DruidDataSource dataSourceOf(DruidDataSourceProperties properties) {
DruidDataSource dataSource = new DruidDataSource();
dataSource.setDriverClassName(properties.getDriverClassName());
dataSource.setUrl(properties.getUrl());
dataSource.setUsername(properties.getUsername());
dataSource.setPassword(properties.getPassword());
dataSource.setInitialSize(properties.getInitialSize());
dataSource.setMaxActive(properties.getMaxActive());
dataSource.setMinIdle(properties.getMinIdle());
dataSource.setMaxWait((long)properties.getMaxWait());
dataSource.setPoolPreparedStatements(properties.isPoolPreparedStatements());
dataSource.setMaxPoolPreparedStatementPerConnectionSize(properties.getMaxPoolPreparedStatementPerConnectionSize());
dataSource.setValidationQuery(properties.getValidationQuery());
dataSource.setValidationQueryTimeout(properties.getValidationQueryTimeout());
dataSource.setTestOnBorrow(properties.isTestOnBorrow());
dataSource.setTestOnReturn(properties.isTestOnReturn());
dataSource.setTestWhileIdle(properties.isTestWhileIdle());
dataSource.setTimeBetweenEvictionRunsMillis((long)properties.getTimeBetweenEvictionRunsMillis());
dataSource.setMinEvictableIdleTimeMillis((long)properties.getMinEvictableIdleTimeMillis());
dataSource.setMaxEvictableIdleTimeMillis((long)properties.getMaxEvictableIdleTimeMillis());
dataSource.setPhyTimeoutMillis((long)properties.getPhyTimeoutMillis());
dataSource.setRemoveAbandoned(properties.isRemoveAbandoned());
dataSource.setRemoveAbandonedTimeout(properties.getRemoveAbandonedTimeout());
dataSource.setConnectProperties(toProperties(properties.getConnectionProperties()));
dataSource.setDefaultAutoCommit(properties.isDefaultAutoCommit());
dataSource.setLogAbandoned(properties.isLogAbandoned());
dataSource.setProxyFilters(properties.getFilters());
return dataSource;
}
`

@chaosblade-bot chaosblade-bot changed the title Target:druid, Action:connectionpoolfull 不能生效 Target:druid, Action:connectionpoolfull cannot take effect Jul 15, 2019
@chaosblade-bot chaosblade-bot added the type/bug Category issues or prs related to bug. label Jul 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug Category issues or prs related to bug.
Projects
None yet
Development

No branches or pull requests

2 participants