use of com.pamirs.pradar.internal.adapter.ExecutionStrategy in project LinkAgent by shulieTech.
the class HttpURLConnectionGetInputStreamInterceptor method beforeLast.
@Override
public void beforeLast(Advice advice) throws ProcessControlException {
if (!Pradar.isClusterTest()) {
return;
}
Object target = advice.getTarget();
final HttpURLConnection request = (HttpURLConnection) target;
final URL url = request.getURL();
String fullPath = getService(url.getProtocol(), url.getHost(), url.getPort(), url.getPath());
String whiteList = request.getRequestProperty(PradarService.PRADAR_WHITE_LIST_CHECK);
MatchConfig config = ClusterTestUtils.httpClusterTest(fullPath);
ExecutionStrategy strategy = config.getStrategy();
// 仅mock在getInputStream里执行
if (!(strategy instanceof JsonMockStrategy) && !(strategy instanceof MockStrategy)) {
return;
}
config.addArgs(PradarService.PRADAR_WHITE_LIST_CHECK, whiteList);
// 白名单需要的信息
config.addArgs("url", fullPath);
// mock转发需要信息
config.addArgs("request", request);
config.addArgs("method", "url");
config.addArgs("isInterface", Boolean.FALSE);
config.getStrategy().processBlock(advice.getBehavior().getReturnType(), advice.getClassLoader(), config);
}
use of com.pamirs.pradar.internal.adapter.ExecutionStrategy in project LinkAgent by shulieTech.
the class HttpURLConnectionInterceptor method beforeLast.
@Override
public void beforeLast(Advice advice) throws ProcessControlException {
if (!Pradar.isClusterTest()) {
return;
}
/**
* 保持trace一致
*/
boolean connecting = advice.hasMark(MARK_CONNECTING);
boolean connected = advice.hasMark(MARK_CONNECTED);
if (connected || connecting) {
return;
}
Object target = advice.getTarget();
final HttpURLConnection request = (HttpURLConnection) target;
final URL url = request.getURL();
String fullPath = getService(url.getProtocol(), url.getHost(), url.getPort(), url.getPath());
String whiteList = request.getRequestProperty(PradarService.PRADAR_WHITE_LIST_CHECK);
MatchConfig config = ClusterTestUtils.httpClusterTest(fullPath);
ExecutionStrategy strategy = config.getStrategy();
// mock不在connect里执行
if (strategy instanceof JsonMockStrategy || strategy instanceof MockStrategy) {
return;
}
config.addArgs(PradarService.PRADAR_WHITE_LIST_CHECK, whiteList);
// 白名单需要的信息
config.addArgs("url", fullPath);
// mock转发需要信息
config.addArgs("request", request);
config.addArgs("method", "url");
config.addArgs("isInterface", Boolean.FALSE);
config.getStrategy().processBlock(advice.getBehavior().getReturnType(), advice.getClassLoader(), config);
}
Aggregations