Search in sources :

Example 1 with PressureMeasureError

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);
    }
}
Also used : DbDruidMediatorDataSource(com.pamirs.attach.plugin.alibaba.druid.obj.DbDruidMediatorDataSource) SQLException(java.sql.SQLException) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) Connection(java.sql.Connection) DruidDataSource(com.alibaba.druid.pool.DruidDataSource) DataSourceMeta(com.pamirs.pradar.pressurement.agent.shared.service.DataSourceMeta)

Example 2 with PressureMeasureError

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);
    }
}
Also used : SQLException(java.sql.SQLException) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) DbcpMediaDataSource(com.pamirs.attach.plugin.dbcp2.utils.DbcpMediaDataSource) Connection(java.sql.Connection) BasicDataSource(org.apache.commons.dbcp2.BasicDataSource) DataSourceMeta(com.pamirs.pradar.pressurement.agent.shared.service.DataSourceMeta)

Example 3 with PressureMeasureError

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;
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) ShadowRedisConfig(com.pamirs.pradar.internal.config.ShadowRedisConfig)

Example 4 with PressureMeasureError

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);
    }
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) RequestIndexRename(com.pamirs.attach.plugin.es.common.RequestIndexRename)

Example 5 with PressureMeasureError

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);
}
Also used : ShadowEsServerConfig(com.pamirs.pradar.internal.config.ShadowEsServerConfig) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) TransportClientDefinition(com.pamirs.attach.plugin.es.shadowserver.rest.definition.TransportClientDefinition)

Aggregations

PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)150 PradarException (com.pamirs.pradar.exception.PradarException)34 DataSourceMeta (com.pamirs.pradar.pressurement.agent.shared.service.DataSourceMeta)14 Connection (java.sql.Connection)14 SQLException (java.sql.SQLException)13 ArrayList (java.util.ArrayList)13 Map (java.util.Map)11 MatchConfig (com.pamirs.pradar.internal.config.MatchConfig)8 ShadowDatabaseConfig (com.pamirs.pradar.internal.config.ShadowDatabaseConfig)8 HashMap (java.util.HashMap)8 MongoNamespace (com.mongodb.MongoNamespace)7 RequestIndexRename (com.pamirs.attach.plugin.es.common.RequestIndexRename)7 ProcessControlException (com.shulie.instrument.simulator.api.ProcessControlException)7 MQTraceContext (com.pamirs.attach.plugin.alibaba.rocketmq.common.MQTraceContext)6 SpanRecord (com.pamirs.pradar.interceptor.SpanRecord)6 ReflectException (com.shulie.instrument.simulator.api.reflect.ReflectException)6 List (java.util.List)6 ConsumeMessageContext (org.apache.rocketmq.client.hook.ConsumeMessageContext)6 ConsumeMessageContext (com.alibaba.rocketmq.client.hook.ConsumeMessageContext)5 WrapperRequest (com.pamirs.attach.plugin.hessian.common.WrapperRequest)5