org.apache.thrift.TBaseAsyncProcessor Java Examples

The following examples show how to use org.apache.thrift.TBaseAsyncProcessor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AsyncEchoTestServer.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
@Override
public void verifyServerTraces(PluginTestVerifier verifier) throws Exception {
    final InetSocketAddress socketAddress = super.environment.getServerAddress();
    final String address = SocketAddressUtils.getAddressFirst(socketAddress);
    verifier.verifyTraceCount(2);
    Method process = TBaseAsyncProcessor.class.getDeclaredMethod("process", AsyncFrameBuffer.class);
    // RootSpan
    verifier.verifyTrace(root("THRIFT_SERVER", // ServiceType,
            "Thrift Server Invocation", // Method
            "com/navercorp/pinpoint/plugin/thrift/dto/EchoService/echo", // rpc
            HostAndPort.toHostAndPortString(address, socketAddress.getPort()), // endPoint
            address // remoteAddress
    ));
    // SpanEvent - TBaseAsyncProcessor.process
    verifier.verifyTrace(event("THRIFT_SERVER_INTERNAL", process));
}
 
Example #2
Source File: TBaseAsyncProcessorProcessInterceptor.java    From pinpoint with Apache License 2.0 6 votes vote down vote up
private String getMethodUri(Object target) {
    String methodUri = ThriftConstants.UNKNOWN_METHOD_URI;
    InterceptorScopeInvocation currentTransaction = this.scope.getCurrentInvocation();
    Object attachment = currentTransaction.getAttachment();
    if (attachment instanceof ThriftClientCallContext && target instanceof TBaseAsyncProcessor) {
        ThriftClientCallContext clientCallContext = (ThriftClientCallContext)attachment;
        String methodName = clientCallContext.getMethodName();
        methodUri = ThriftUtils.getAsyncProcessorNameAsUri((TBaseAsyncProcessor<?>)target);
        StringBuilder sb = new StringBuilder(methodUri);
        if (!methodUri.endsWith("/")) {
            sb.append("/");
        }
        sb.append(methodName);
        methodUri = sb.toString();
    }
    return methodUri;
}
 
Example #3
Source File: ThriftServiceMetadata.java    From armeria with Apache License 2.0 5 votes vote down vote up
@Nullable
private static Map<String, AsyncProcessFunction<?, ?, ?>> getThriftAsyncProcessMap(
        @Nullable Object service, Class<?> iface) {

    final String name = iface.getName();
    if (!name.endsWith("$AsyncIface")) {
        return null;
    }

    final String processorName = name.substring(0, name.length() - 10) + "AsyncProcessor";
    try {
        final Class<?> processorClass = Class.forName(processorName, false, iface.getClassLoader());
        if (!TBaseAsyncProcessor.class.isAssignableFrom(processorClass)) {
            return null;
        }

        final Constructor<?> processorConstructor = processorClass.getConstructor(iface);

        @SuppressWarnings("rawtypes")
        final TBaseAsyncProcessor processor =
                (TBaseAsyncProcessor) processorConstructor.newInstance(service);

        @SuppressWarnings("unchecked")
        final Map<String, AsyncProcessFunction<?, ?, ?>> processMap =
                (Map<String, AsyncProcessFunction<?, ?, ?>>) processor.getProcessMapView();

        return processMap;
    } catch (Exception e) {
        logger.debug("Failed to retrieve the asynchronous process map from:: {}", iface, e);
        return null;
    }
}
 
Example #4
Source File: ThriftUtils.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
/**
 * Returns the name of the specified {@link org.apache.thrift.TBaseAsyncProcessor TBaseAsyncProcessor}
 * as uri to be used in Pinpoint.
 */
public static String getAsyncProcessorNameAsUri(TBaseAsyncProcessor<?> asyncProcessor) {
    String actualAsyncProcessorName = asyncProcessor.getClass().getName();
    return convertDotPathToUriPath(ThriftConstants.ASYNC_PROCESSOR_PATTERN.matcher(actualAsyncProcessorName).replaceAll("."));
}