Search in sources :

Example 1 with WrapperRequest

use of com.pamirs.attach.plugin.hessian.common.WrapperRequest in project LinkAgent by shulieTech.

the class HessianServiceExporterHandleRequestInterceptor method afterTrace.

@Override
public SpanRecord afterTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    Object target = advice.getTarget();
    if (args == null || args.length == 0) {
        return null;
    }
    if (!(args[0] instanceof HttpServletRequest)) {
        if (Pradar.isClusterTest()) {
            throw new PressureMeasureError("hessian servlet trace err! can't cast to HttpServletRequest");
        }
        return null;
    }
    WrapperRequest request = (WrapperRequest) args[0];
    if (!request.getMethod().equals("POST") && !request.getMethod().equals("post")) {
        return null;
    }
    String method = request.getHeader(HessianConstants.METHOD_HEADER);
    if (method == null) {
        method = Pradar.getMethod();
    }
    if (method != null && isSkip(method)) {
        return null;
    }
    SpanRecord spanRecord = new SpanRecord();
    return spanRecord;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) WrapperRequest(com.pamirs.attach.plugin.hessian.common.WrapperRequest)

Example 2 with WrapperRequest

use of com.pamirs.attach.plugin.hessian.common.WrapperRequest in project LinkAgent by shulieTech.

the class HessianServiceExporterHandleRequestInterceptor method exceptionTrace.

@Override
public SpanRecord exceptionTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    if (args == null || args.length == 0) {
        return null;
    }
    if (!(args[0] instanceof HttpServletRequest)) {
        if (Pradar.isClusterTest()) {
            throw new PressureMeasureError("hessian servlet trace err! can't cast to HttpServletRequest");
        }
        return null;
    }
    WrapperRequest request = (WrapperRequest) args[0];
    if (!request.getMethod().equals("POST") && !request.getMethod().equals("post")) {
        return null;
    }
    String method = request.getHeader(HessianConstants.METHOD_HEADER);
    if (method == null) {
        method = Pradar.getMethod();
    }
    if (method != null && isSkip(method)) {
        return null;
    }
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setResponse(advice.getThrowable());
    spanRecord.setResultCode(ResultCode.INVOKE_RESULT_FAILED);
    return spanRecord;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) WrapperRequest(com.pamirs.attach.plugin.hessian.common.WrapperRequest)

Example 3 with WrapperRequest

use of com.pamirs.attach.plugin.hessian.common.WrapperRequest in project LinkAgent by shulieTech.

the class HessianServiceExporterHandleRequestInterceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    Object target = advice.getTarget();
    if (args == null || args.length == 0) {
        return null;
    }
    if (!(args[0] instanceof HttpServletRequest)) {
        if (Pradar.isClusterTest()) {
            throw new PressureMeasureError("hessian servlet trace err! can't cast to HttpServletRequest");
        }
        return null;
    }
    WrapperRequest request = (WrapperRequest) args[0];
    if (!request.getMethod().equals("POST") && !request.getMethod().equals("post")) {
        return null;
    }
    String method = request.getHeader(HessianConstants.METHOD_HEADER);
    if (method != null && isSkip(method)) {
        return null;
    }
    HessianServiceExporter serviceExporter = (HessianServiceExporter) target;
    HessianSkeleton hessianSkeleton = null;
    try {
        hessianSkeleton = Reflect.on(serviceExporter).get(HessianConstants.DYNAMIC_FIELD_OBJECT_SKELETON);
    } catch (ReflectException e) {
    }
    SerializerFactory serializerFactory = null;
    try {
        serializerFactory = Reflect.on(serviceExporter).get(HessianConstants.DYNAMIC_FIELD_SERIALIZER_FACTORY);
    } catch (ReflectException e) {
    }
    Object[] result = getMethodArgs(request.getInputStream(), serializerFactory, hessianSkeleton);
    Object[] arguments = (Object[]) result[1];
    if (method == null) {
        method = (String) result[0];
    }
    Class<?> clazz = serviceExporter.getServiceInterface();
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setService(clazz.getName());
    spanRecord.setMethod(method);
    spanRecord.setRequest(arguments);
    return spanRecord;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) WrapperRequest(com.pamirs.attach.plugin.hessian.common.WrapperRequest) HessianSkeleton(com.caucho.hessian.server.HessianSkeleton) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException) HessianServiceExporter(org.springframework.remoting.caucho.HessianServiceExporter)

Example 4 with WrapperRequest

use of com.pamirs.attach.plugin.hessian.common.WrapperRequest in project LinkAgent by shulieTech.

the class HessianServletWrapperRequestInterceptor method getParameter0.

@Override
public Object[] getParameter0(Advice advice) {
    Object[] args = advice.getParameterArray();
    if (args == null || args.length == 0) {
        return args;
    }
    if (!(args[0] instanceof HttpServletRequest)) {
        return args;
    }
    args[0] = new WrapperRequest((HttpServletRequest) args[0]);
    return args;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) WrapperRequest(com.pamirs.attach.plugin.hessian.common.WrapperRequest)

Example 5 with WrapperRequest

use of com.pamirs.attach.plugin.hessian.common.WrapperRequest in project LinkAgent by shulieTech.

the class BurlapServletServiceInterceptor method beforeTrace.

@Override
public SpanRecord beforeTrace(Advice advice) {
    Object[] args = advice.getParameterArray();
    Object target = advice.getTarget();
    if (args == null || args.length == 0) {
        return null;
    }
    if (!(args[0] instanceof HttpServletRequest)) {
        if (Pradar.isClusterTest()) {
            throw new PressureMeasureError("hessian servlet trace err! can't cast to HttpServletRequest");
        }
        return null;
    }
    WrapperRequest request = (WrapperRequest) args[0];
    if (!request.getMethod().equals("POST") && !request.getMethod().equals("post")) {
        return null;
    }
    String method = request.getHeader(HessianConstants.METHOD_HEADER);
    BurlapServlet burlapServlet = (BurlapServlet) target;
    BurlapSkeleton hessianSkeleton = null;
    try {
        hessianSkeleton = Reflect.on(burlapServlet).get(HessianConstants.DYNAMIC_FIELD_SKELETON);
    } catch (ReflectException e) {
    }
    Object[] result = getMethodArgs(request.getInputStream(), hessianSkeleton);
    Object[] arguments = (Object[]) result[1];
    if (method == null) {
        method = (String) result[0];
    }
    Class<?> clazz = null;
    try {
        clazz = Reflect.on(burlapServlet).get(HessianConstants.DYNAMIC_FIELD_TYPE);
    } catch (ReflectException e) {
    }
    SpanRecord spanRecord = new SpanRecord();
    spanRecord.setService(clazz == null ? null : clazz.getName());
    spanRecord.setMethod(method);
    spanRecord.setRequest(arguments);
    spanRecord.setPort(request.getRemotePort());
    return spanRecord;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) BurlapServlet(com.caucho.burlap.server.BurlapServlet) SpanRecord(com.pamirs.pradar.interceptor.SpanRecord) PressureMeasureError(com.pamirs.pradar.exception.PressureMeasureError) WrapperRequest(com.pamirs.attach.plugin.hessian.common.WrapperRequest) BurlapSkeleton(com.caucho.burlap.server.BurlapSkeleton) ReflectException(com.shulie.instrument.simulator.api.reflect.ReflectException)

Aggregations

WrapperRequest (com.pamirs.attach.plugin.hessian.common.WrapperRequest)6 HttpServletRequest (javax.servlet.http.HttpServletRequest)6 PressureMeasureError (com.pamirs.pradar.exception.PressureMeasureError)5 SpanRecord (com.pamirs.pradar.interceptor.SpanRecord)5 ReflectException (com.shulie.instrument.simulator.api.reflect.ReflectException)3 HessianSkeleton (com.caucho.hessian.server.HessianSkeleton)2 BurlapServlet (com.caucho.burlap.server.BurlapServlet)1 BurlapSkeleton (com.caucho.burlap.server.BurlapSkeleton)1 HessianServlet (com.caucho.hessian.server.HessianServlet)1 HessianServiceExporter (org.springframework.remoting.caucho.HessianServiceExporter)1