use of com.pamirs.attach.plugin.c3p0.utils.C3p0MediaDataSource in project LinkAgent by shulieTech.
the class DataSourceGetConnectionArgsCutoffInterceptor method cutoff0.
@Override
public CutOffResult cutoff0(Advice advice) {
attachment(advice);
Object target = advice.getTarget();
ComboPooledDataSource dataSource = (ComboPooledDataSource) target;
DataSourceMeta<ComboPooledDataSource> dataSourceMeta = new DataSourceMeta<ComboPooledDataSource>(dataSource.getJdbcUrl(), dataSource.getUser(), dataSource);
ClusterTestUtils.validateClusterTest();
DataSourceWrapUtil.init(dataSourceMeta);
Connection connection = null;
/**
* 所有的流量均切换到此逻辑上,防止业务有连接缓存后无法进入
* 如果未找到配置情况下则当前流量为压测流量时返回null,非压测流量则执行业务连接池正常逻辑,此种情况可能由于数据源未配置的情况
* 如果获取连接出错时如果流量为压测流量则返回null,非压测流量则执行业务连接池正常逻辑
*/
if (DataSourceWrapUtil.pressureDataSources.containsKey(dataSourceMeta)) {
C3p0MediaDataSource mediatorDataSource = DataSourceWrapUtil.pressureDataSources.get(dataSourceMeta);
if (mediatorDataSource != null) {
try {
connection = mediatorDataSource.getConnection();
} catch (SQLException e) {
throw new PressureMeasureError(e);
}
} else {
if (!Pradar.isClusterTest()) {
return CutOffResult.passed();
}
}
return CutOffResult.cutoff(connection);
} else {
if (!Pradar.isClusterTest()) {
return CutOffResult.passed();
}
return CutOffResult.cutoff(null);
}
}
use of com.pamirs.attach.plugin.c3p0.utils.C3p0MediaDataSource in project LinkAgent by shulieTech.
the class DataSourceGetConnectionCutoffInterceptor method cutoff0.
@Override
public CutOffResult cutoff0(Advice advice) {
attachment(advice);
Object target = advice.getTarget();
ComboPooledDataSource dataSource = (ComboPooledDataSource) target;
DataSourceMeta<ComboPooledDataSource> dataSourceMeta = new DataSourceMeta<ComboPooledDataSource>(dataSource.getJdbcUrl(), dataSource.getUser(), dataSource);
ClusterTestUtils.validateClusterTest();
DataSourceWrapUtil.init(dataSourceMeta);
Connection connection = null;
/**
* 所有的流量均切换到此逻辑上,防止业务有连接缓存后无法进入
* 如果未找到配置情况下则当前流量为压测流量时返回null,非压测流量则执行业务连接池正常逻辑,此种情况可能由于数据源未配置的情况
* 如果获取连接出错时如果流量为压测流量则返回null,非压测流量则执行业务连接池正常逻辑
*
* 如果配置初始化异常或者没有对应配置
*/
if (DataSourceWrapUtil.pressureDataSources.containsKey(dataSourceMeta)) {
C3p0MediaDataSource mediatorDataSource = DataSourceWrapUtil.pressureDataSources.get(dataSourceMeta);
if (mediatorDataSource != null) {
try {
connection = mediatorDataSource.getConnection();
} catch (SQLException e) {
throw new PressureMeasureError(e);
}
} else {
if (!Pradar.isClusterTest()) {
return CutOffResult.passed();
}
}
return CutOffResult.cutoff(connection);
} else {
if (!Pradar.isClusterTest()) {
return CutOffResult.passed();
}
return CutOffResult.cutoff(null);
}
}
Aggregations