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;
}
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;
}
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;
}
}
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;
}
}
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;
}
Aggregations