use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class DruidInjectGetConnectionInterceptor method cutoff0.
@Override
public CutOffResult cutoff0(Advice advice) {
DruidDataSource target1 = (DruidDataSource) advice.getTarget();
addAttachment(advice);
DataSourceMeta<DruidDataSource> dataSourceMeta = new DataSourceMeta<DruidDataSource>(target1.getUrl(), target1.getUsername(), target1);
ClusterTestUtils.validateClusterTest();
DbDruidMediatorDataSource mediatorDataSource = DataSourceWrapUtil.doWrap(dataSourceMeta);
// 判断带有压测标示,是否初始化
// 初始化
Connection connection = null;
/**
* 所有的流量均切换到此逻辑上,防止业务有连接缓存后无法进入
* 如果未找到配置情况下则当前流量为压测流量时返回null,非压测流量则执行业务连接池正常逻辑,此种情况可能由于数据源未配置的情况
* 如果获取连接出错时如果流量为压测流量则返回null,非压测流量则执行业务连接池正常逻辑
*/
if (mediatorDataSource != null) {
try {
connection = mediatorDataSource.getConnection();
} catch (SQLException e) {
throw new PressureMeasureError(e);
}
return CutOffResult.cutoff(connection);
} else {
if (!Pradar.isClusterTest()) {
return CutOffResult.passed();
}
return CutOffResult.cutoff(null);
}
}
use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class DataSourceGetConnectionCutoffInterceptor method cutoff0.
@Override
public CutOffResult cutoff0(Advice advice) {
DataSourceWrapUtil.attachment(advice);
Object target = advice.getTarget();
addListener();
ClusterTestUtils.validateClusterTest();
BasicDataSource dataSource = (BasicDataSource) target;
DataSourceMeta<BasicDataSource> dataSourceMeta = new DataSourceMeta<BasicDataSource>(dataSource.getUrl(), dataSource.getUsername(), dataSource);
DataSourceWrapUtil.init(dataSourceMeta);
Connection connection = null;
/**
* 所有的流量均切换到此逻辑上,防止业务有连接缓存后无法进入
* 如果未找到配置情况下则当前流量为压测流量时返回null,非压测流量则执行业务连接池正常逻辑,此种情况可能由于数据源未配置的情况
* 如果获取连接出错时如果流量为压测流量则返回null,非压测流量则执行业务连接池正常逻辑
*/
if (DataSourceWrapUtil.pressureDataSources.containsKey(dataSourceMeta)) {
DbcpMediaDataSource 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.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class AbstractRedisServerFactory method create.
private RedisClientMediator<?> create(Object obj) {
ShadowRedisConfig shadowRedisConfig = serverMatch.getConfig(obj);
if (null == shadowRedisConfig) {
ErrorReporter.buildError().setErrorType(ErrorTypeEnum.RedisServer).setErrorCode("redisServer-0001").setMessage("没有配置影子Redis Server").setDetail("没有配置影子Redis Server").report();
// 抛出相关异常信息
throw new PressureMeasureError("not found redis shadow server config error1.");
}
validationConfig(shadowRedisConfig);
RedisClientMediator<T> mediator = createMediator(obj, shadowRedisConfig);
putMediator(obj, mediator);
return mediator;
}
use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class RestHighLevelClientInterceptor method beforeFirst.
@Override
public void beforeFirst(Advice advice) {
Object[] args = advice.getParameterArray();
ClusterTestUtils.validateClusterTest();
if (!Pradar.isClusterTest()) {
return;
}
if (GlobalConfig.getInstance().isShadowEsServer()) {
return;
}
RequestIndexRename requestIndexRename = RequestIndexRenameProvider.get(args[0]);
if (requestIndexRename == null) {
throw new PressureMeasureError("elasticsearch " + args[0].getClass().getName() + " is not supported!");
}
if (requestIndexRename.supportedDirectReindex(args[0])) {
requestIndexRename.reindex(args[0]);
} else {
Object index = requestIndexRename.indirectIndex(args[0]);
advice.changeParameter(0, index);
}
}
use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.
the class ShadowEsClientHolder method createShadowTransportClient.
private static TransportClient createShadowTransportClient(TransportClient target) {
List<String> nodesAddressAsString = getNodesAddressAsString(target);
ShadowEsServerConfig shadowEsServerConfig = findMatchShadowEsServerConfig(nodesAddressAsString);
if (shadowEsServerConfig == null) {
throw new PressureMeasureError(String.format("影子集群未配置,业务节点:%s", StringUtils.join(nodesAddressAsString, ",")));
}
TransportClientDefinition transportClientDefinition = TransportClientDefinitionStrategy.match(target);
return transportClientDefinition.solve(target, shadowEsServerConfig);
}
Aggregations