Search in sources :

Example 61 with PressureMeasureError

use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.

the class MongoDBMongoClientDelegateConstructorInterceptor method getParameter0.

@Override
public Object[] getParameter0(Advice advice) {
    Object[] args = advice.getParameterArray();
    Object target = advice.getTarget();
    if (MongoClientPtCreate.createPtMongoClient.get()) {
        BusinessDelegateOperationExecutor businessDelegateOperationExecutor = new BusinessDelegateOperationExecutor((MongoClientDelegate) target, args[2]);
        args[3] = businessDelegateOperationExecutor;
        if (MongoClientHolder.mongoHolder.get() == null) {
            throw new PressureMeasureError("mongo 业务数据源找不到");
        }
        // 存放业务数据源对象和影子对象的关系
        MongoClientHolder.mongoOperationExecutorMap.put(MongoClientHolder.mongoHolder.get(), businessDelegateOperationExecutor);
        MongoClientHolder.mongoHolder.remove();
        return args;
    }
    check(args[0], (Mongo) args[2]);
    BusinessDelegateOperationExecutor ptDelegateOperationExecutor = new BusinessDelegateOperationExecutor((MongoClientDelegate) target, args[2]);
    DelegateOperationExecutorWrapper delegateOperationExecutorWrapper = new DelegateOperationExecutorWrapper((MongoClientDelegate) target, args[2], ptDelegateOperationExecutor);
    args[3] = delegateOperationExecutorWrapper;
    return args;
}
Also used : DelegateOperationExecutorWrapper(com.pamirs.attach.plugin.mongodb.obj.DelegateOperationExecutorWrapper) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) BusinessDelegateOperationExecutor(com.pamirs.attach.plugin.mongodb.obj.BusinessDelegateOperationExecutor)

Example 62 with PressureMeasureError

use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.

the class DBCollectionGroupInterceptor method getMethod.

private Method getMethod(DBCollection dbCollection) {
    if (method == null) {
        Method[] methods = dbCollection.getClass().getSuperclass().getDeclaredMethods();
        for (Method method : methods) {
            if (method.getName().equals("group") && method.getParameterTypes().length == 1 && method.getParameterTypes()[0] == DBObject.class) {
                this.method = method;
                this.method.setAccessible(true);
            }
        }
    }
    if (method == null) {
        throw new PressureMeasureError("未支持的版本!");
    }
    return method;
}
Also used : PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) Method(java.lang.reflect.Method) DBObject(com.mongodb.DBObject)

Example 63 with PressureMeasureError

use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.

the class TraceInterceptor method doAfter.

@Override
public void doAfter(Advice advice) throws Throwable {
    if (!simulatorConfig.getBooleanProperty("plugin." + getPluginName() + ".trace.enabled", true)) {
        return;
    }
    ClusterTestUtils.validateClusterTest();
    Throwable throwable = null;
    try {
        afterFirst(advice);
    } catch (PradarException e) {
        LOGGER.error("TraceInterceptor afterFirst exec err:{}", this.getClass().getName(), e);
        throwable = e;
    } catch (PressureMeasureError e) {
        LOGGER.error("TraceInterceptor afterFirst exec err:{}", this.getClass().getName(), e);
        throwable = e;
    } catch (Throwable t) {
        LOGGER.error("TraceInterceptor afterFirst exec err:{}", this.getClass().getName(), t);
        throwable = t;
    }
    boolean clusterTest = Pradar.isClusterTest();
    try {
        if (isClient(advice)) {
            endClientInvoke(advice);
        } else {
            endServerInvoke(advice);
        }
    } catch (PradarException e) {
        LOGGER.error("TraceInterceptor after exec err:{}", this.getClass().getName(), e);
        if (clusterTest) {
            throw e;
        }
    } catch (PressureMeasureError e) {
        LOGGER.error("TraceInterceptor after exec err:{}", this.getClass().getName(), e);
        if (clusterTest) {
            throw e;
        }
    } catch (Throwable e) {
        if (clusterTest) {
            LOGGER.error("TraceInterceptor after exec err:{}", this.getClass().getName(), e);
            throw new PressureMeasureError(e);
        }
    } finally {
        try {
            afterLast(advice);
        } catch (PradarException e) {
            LOGGER.error("TraceInterceptor afterLast exec err:{}", this.getClass().getName(), e);
            throwable = e;
        } catch (PressureMeasureError e) {
            LOGGER.error("TraceInterceptor afterLast exec err:{}", this.getClass().getName(), e);
            throwable = e;
        } catch (Throwable t) {
            LOGGER.error("TraceInterceptor afterLast exec err:{}", this.getClass().getName(), t);
            throwable = t;
        }
    }
    if (throwable != null && clusterTest) {
        throw throwable;
    }
}
Also used : PradarException(com.pamirs.pradar.exception.PradarException) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError)

Example 64 with PressureMeasureError

use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.

the class TraceInterceptor method doException.

@Override
public final void doException(Advice advice) throws Throwable {
    if (!simulatorConfig.getBooleanProperty("plugin." + getPluginName() + ".trace.enabled", true)) {
        return;
    }
    Throwable throwable = null;
    try {
        exceptionFirst(advice);
    } catch (PradarException e) {
        LOGGER.error("TraceInterceptor exceptionFirst exec err:{}", this.getClass().getName(), e);
        throwable = e;
    } catch (PressureMeasureError e) {
        LOGGER.error("TraceInterceptor exceptionFirst exec err:{}", this.getClass().getName(), e);
        throwable = e;
    } catch (Throwable t) {
        LOGGER.error("TraceInterceptor exceptionFirst exec err:{}", this.getClass().getName(), t);
        throwable = t;
    }
    boolean clusterTest = Pradar.isClusterTest();
    try {
        if (isClient(advice)) {
            endClientInvokeException(advice);
        } else {
            endServerInvokeException(advice);
        }
    } catch (PradarException e) {
        LOGGER.error("TraceInterceptor exception exec err:{}", this.getClass().getName(), e);
        if (clusterTest) {
            throw e;
        }
    } catch (PressureMeasureError e) {
        LOGGER.error("TraceInterceptor exception exec err:{}", this.getClass().getName(), e);
        if (clusterTest) {
            throw e;
        }
    } catch (Throwable e) {
        if (clusterTest) {
            LOGGER.error("TraceInterceptor exception exec err:{}", this.getClass().getName(), e);
            throw new PressureMeasureError(e);
        }
    } finally {
        try {
            exceptionLast(advice);
        } catch (PradarException e) {
            LOGGER.error("TraceInterceptor exceptionLast exec err:{}", this.getClass().getName(), e);
            throwable = e;
        } catch (PressureMeasureError e) {
            LOGGER.error("TraceInterceptor exceptionLast exec err:{}", this.getClass().getName(), e);
            throwable = e;
        } catch (Throwable t) {
            LOGGER.error("TraceInterceptor exceptionLast exec err:{}", this.getClass().getName(), t);
            throwable = t;
        }
    }
    if (throwable != null && clusterTest) {
        throw throwable;
    }
}
Also used : PradarException(com.pamirs.pradar.exception.PradarException) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError)

Example 65 with PressureMeasureError

use of com.pamirs.pradar.exception.PressureMeasureError in project LinkAgent by shulieTech.

the class MockStrategy method processNonBlock.

@Override
public Object processNonBlock(Class returnType, ClassLoader classLoader, Object params, ExecutionCall call) throws ProcessControlException {
    if (Pradar.isClusterTest()) {
        if (params instanceof MatchConfig) {
            try {
                MatchConfig config = (MatchConfig) params;
                String scriptContent = config.getScriptContent();
                ScriptEvaluator evaluator = ScriptManager.getInstance().getScriptEvaluator("bsh");
                Object result = evaluator.evaluate(scriptContent, config.getArgs());
                return call.call(result);
            } catch (ProcessControlException e) {
                throw e;
            } catch (Throwable e) {
                LOGGER.error("mock处理异常 {}", e);
                ErrorReporter.buildError().setErrorType(ErrorTypeEnum.mock).setErrorCode("mock-0001").setMessage("mock处理异常!" + e.getMessage()).setDetail("脚本内容" + ((MatchConfig) params).getScriptContent()).report();
                throw new PressureMeasureError(e);
            }
        }
    }
    return true;
}
Also used : ScriptEvaluator(com.pamirs.pradar.script.ScriptEvaluator) ProcessControlException(com.shulie.instrument.simulator.api.ProcessControlException) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) MatchConfig(com.pamirs.pradar.internal.config.MatchConfig)

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