use of com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler in project uavstack by uavorg.
the class JettyPlusIT method onServletRegist.
/**
* onServletRegist
*
* @param args
* @return
*/
public ServletContext onServletRegist(Object... args) {
ServletContext servletContext;
ServletContextEvent sce;
if (ServletContextEvent.class.isAssignableFrom(args[0].getClass())) {
sce = (ServletContextEvent) args[0];
servletContext = sce.getServletContext();
} else {
servletContext = (ServletContext) args[0];
}
ServletContext scProxy = (ServletContext) servletContext.getAttribute("com.creditease.uav.mof.tomcat.servletcontext");
if (scProxy == null) {
scProxy = JDKProxyInvokeUtil.newProxyInstance(ServletContext.class.getClassLoader(), new Class<?>[] { ServletContext.class }, new JDKProxyInvokeHandler<ServletContext>(servletContext, new DynamicServletContextProcessor()));
servletContext.setAttribute("com.creditease.uav.mof.tomcat.servletcontext", scProxy);
}
return scProxy;
}
use of com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler in project uavstack by uavorg.
the class ApacheAsyncHttpClientIT method doAsyncStart.
/**
* for async http client
*
* @param args
* @return
*/
@SuppressWarnings({ "rawtypes", "unused", "unchecked" })
public FutureCallback doAsyncStart(Object[] args) {
HttpAsyncRequestProducer requestProducer = null;
HttpAsyncResponseConsumer responseConsumer = null;
HttpContext context = null;
FutureCallback callback = null;
Map mObj = null;
if (args.length == 4) {
requestProducer = (HttpAsyncRequestProducer) args[0];
responseConsumer = (HttpAsyncResponseConsumer) args[1];
context = (HttpContext) args[2];
callback = (FutureCallback) args[3];
} else if (args.length == 5) {
requestProducer = (HttpAsyncRequestProducer) args[1];
responseConsumer = (HttpAsyncResponseConsumer) args[2];
context = (HttpContext) args[3];
callback = (FutureCallback) args[4];
}
String httpAction = null;
try {
HttpRequest hr = requestProducer.generateRequest();
/**
* 呵呵,就是把UAV的客户端标记加到http header里面,接收方就知道是哪个东东调用的了,便于实现来源快速匹配,这个模式只适合直连模式
*
* 对于代理模式,只匹配代理源即可
*/
hr.addHeader("UAV-Client-Src", MonitorServerUtil.getUAVClientSrc(this.applicationId));
RequestLine rl = hr.getRequestLine();
httpAction = rl.getMethod();
targetURL = rl.getUri();
// 部分HttpRequest中没有ip:port,需要从httpHost中拿到再拼接
if (!targetURL.startsWith("http")) {
targetURL = requestProducer.getTarget().toURI() + targetURL;
}
} catch (IOException e) {
// ignore thie exception
return null;
} catch (HttpException e) {
// ignore thie exception
return null;
}
Map<String, Object> params = new HashMap<String, Object>();
params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, targetURL);
params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, httpAction);
params.put(CaptureConstants.INFO_CLIENT_APPID, this.applicationId);
params.put(CaptureConstants.INFO_CLIENT_TYPE, "apache.http.AsyncClient");
if (logger.isDebugable()) {
logger.debug("Invoke START:" + targetURL + "," + httpAction + "," + this.applicationId, null);
}
/**
* for async, as not in the same thread
*/
ccMap = UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, Monitor.CapturePhase.PRECAP, params, null);
// register invokechain adapter
UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "registerAdapter", ApacheAsyncHttpClientAdapter.class);
ccMap4Chain = (Map<String, Object>) UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params, ApacheAsyncHttpClientAdapter.class, args);
if (callback == null) {
return null;
}
callback = JDKProxyInvokeUtil.newProxyInstance(HttpContext.class.getClassLoader(), new Class<?>[] { FutureCallback.class }, new JDKProxyInvokeHandler<FutureCallback>(callback, new FutureCallbackProxyInvokeProcessor(ccMap4Chain)));
return callback;
}
use of com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler in project uavstack by uavorg.
the class TomcatPlusIT method onServletRegist.
/**
* onServletRegist
*
* @param args
* @return
*/
public ServletContext onServletRegist(Object... args) {
ServletContext servletContext = (ServletContext) args[0];
// uav's inner app doesn't need Profiling,just return origin servletContext here.
if ("/com.creditease.uav".equals(servletContext.getContextPath())) {
return servletContext;
}
ServletContext scProxy = (ServletContext) servletContext.getAttribute("com.creditease.uav.mof.tomcat.servletcontext");
if (scProxy == null) {
scProxy = JDKProxyInvokeUtil.newProxyInstance(ServletContext.class.getClassLoader(), new Class<?>[] { ServletContext.class }, new JDKProxyInvokeHandler<ServletContext>(servletContext, new DynamicServletContextProcessor()));
servletContext.setAttribute("com.creditease.uav.mof.tomcat.servletcontext", scProxy);
}
return scProxy;
}
use of com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler in project uavstack by uavorg.
the class TransportIT method doAsyncStart.
@SuppressWarnings({ "rawtypes", "unchecked" })
public Object doAsyncStart(Object[] args) {
DiscoveryNode node = (DiscoveryNode) args[0];
esAction = (String) args[1];
TransportResponseHandler handler = (TransportResponseHandler) args[4];
String address = node.getHostAddress();
Integer port = node.getAddress().getPort();
targetURL = "elasticsearch://" + address + ":" + port;
if (logger.isDebugable()) {
logger.debug("Elastaicsearch INVOKE START: " + targetURL + " action: " + esAction, null);
}
Map<String, Object> params = new HashMap<String, Object>();
params.put(CaptureConstants.INFO_CLIENT_REQUEST_URL, targetURL);
params.put(CaptureConstants.INFO_CLIENT_REQUEST_ACTION, esAction);
params.put(CaptureConstants.INFO_CLIENT_APPID, appid);
params.put(CaptureConstants.INFO_CLIENT_TYPE, "elasticsearch.client");
ccMap = UAVServer.instance().runMonitorAsyncCaptureOnServerCapPoint(CaptureConstants.CAPPOINT_APP_CLIENT, Monitor.CapturePhase.PRECAP, params, null);
// register adapter
UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "registerAdapter", TransportAdapter.class);
ivcContextParams = (Map<String, Object>) UAVServer.instance().runSupporter("com.creditease.uav.apm.supporters.InvokeChainSupporter", "runCap", InvokeChainConstants.CHAIN_APP_CLIENT, InvokeChainConstants.CapturePhase.PRECAP, params, TransportAdapter.class, args);
if (handler == null) {
return null;
}
handler = JDKProxyInvokeUtil.newProxyInstance(TransportResponseHandler.class.getClassLoader(), new Class<?>[] { TransportResponseHandler.class }, new JDKProxyInvokeHandler<TransportResponseHandler>(handler, new ESHandlerProxyInvokeProcessor()));
return handler;
}
use of com.creditease.monitor.proxy.spi.JDKProxyInvokeHandler in project uavstack by uavorg.
the class JaxWSHookIT method createDispatch.
@SuppressWarnings("rawtypes")
public Dispatch createDispatch(Dispatch d, Service s, Object[] args) {
Binding binding = ((BindingProvider) d).getBinding();
List<Handler> handlerChain = binding.getHandlerChain();
handlerChain.add(this.handler);
binding.setHandlerChain(handlerChain);
final String wsdlLocation = getServiceURL(s);
Dispatch tProxy = JDKProxyInvokeUtil.newProxyInstance(this.getClass().getClassLoader(), new Class[] { Dispatch.class }, new JDKProxyInvokeHandler<Dispatch>(d, new DispatchProcessor(wsdlLocation.toString(), this.handler)));
return tProxy;
}
Aggregations