Search in sources :

Example 1 with MethodTypeEnum

use of com.navercorp.pinpoint.common.server.bo.MethodTypeEnum in project pinpoint by naver.

the class DefaultApiParser method parse.

@Override
public Api parse(ApiMetaDataBo apiMetadata) {
    Objects.requireNonNull(apiMetadata, "apiMetadata");
    MethodTypeEnum methodTypeEnum = apiMetadata.getMethodTypeEnum();
    Assert.isTrue(methodTypeEnum == MethodTypeEnum.DEFAULT, "Unexpected methodType:" + methodTypeEnum);
    try {
        ApiDescription apiDescription = parser.parse(apiMetadata);
        String method = apiDescription.getMethodDescription();
        String className = apiDescription.getSimpleClassName();
        String apiInfo = apiDescription.getApiDescription();
        return new Api(method, className, apiInfo, MethodTypeEnum.DEFAULT);
    } catch (Exception ignore) {
    // ignore
    }
    String description = apiMetadata.getDescription();
    return new Api(description, "", description, apiMetadata.getMethodTypeEnum());
}
Also used : MethodTypeEnum(com.navercorp.pinpoint.common.server.bo.MethodTypeEnum)

Example 2 with MethodTypeEnum

use of com.navercorp.pinpoint.common.server.bo.MethodTypeEnum in project pinpoint by naver.

the class ApiMetaDataMapper method mapRow.

@Override
public List<ApiMetaDataBo> mapRow(Result result, int rowNum) throws Exception {
    if (result.isEmpty()) {
        return Collections.emptyList();
    }
    final byte[] rowKey = getOriginalKey(result.getRow());
    final MetaDataRowKey key = decoder.decodeRowKey(rowKey);
    List<ApiMetaDataBo> apiMetaDataList = new ArrayList<>();
    for (Cell cell : result.rawCells()) {
        final byte[] value = getValue(cell);
        Buffer buffer = new FixedBuffer(value);
        final String apiInfo = buffer.readPrefixedString();
        final int lineNumber = buffer.readInt();
        MethodTypeEnum methodTypeEnum = MethodTypeEnum.DEFAULT;
        if (buffer.hasRemaining()) {
            methodTypeEnum = MethodTypeEnum.valueOf(buffer.readInt());
        }
        ApiMetaDataBo apiMetaDataBo = new ApiMetaDataBo(key.getAgentId(), key.getAgentStartTime(), key.getId(), lineNumber, methodTypeEnum, apiInfo);
        apiMetaDataList.add(apiMetaDataBo);
        if (logger.isDebugEnabled()) {
            logger.debug("read apiAnnotation:{}", apiMetaDataBo);
        }
    }
    return apiMetaDataList;
}
Also used : FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) Buffer(com.navercorp.pinpoint.common.buffer.Buffer) FixedBuffer(com.navercorp.pinpoint.common.buffer.FixedBuffer) MetaDataRowKey(com.navercorp.pinpoint.common.server.bo.serializer.metadata.MetaDataRowKey) ArrayList(java.util.ArrayList) MethodTypeEnum(com.navercorp.pinpoint.common.server.bo.MethodTypeEnum) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo) Cell(org.apache.hadoop.hbase.Cell)

Example 3 with MethodTypeEnum

use of com.navercorp.pinpoint.common.server.bo.MethodTypeEnum in project pinpoint by naver.

the class GrpcApiMetaDataHandler method handleApiMetaData.

private GeneratedMessageV3 handleApiMetaData(final PApiMetaData apiMetaData) {
    if (isDebug) {
        logger.debug("Handle PApiMetaData={}", MessageFormatUtils.debugLog(apiMetaData));
    }
    try {
        final Header header = ServerContext.getAgentInfo();
        final String agentId = header.getAgentId();
        final long agentStartTime = header.getAgentStartTime();
        final int line = LineNumber.defaultLineNumber(apiMetaData.getLine());
        final MethodTypeEnum type = MethodTypeEnum.defaultValueOf(apiMetaData.getType());
        final ApiMetaDataBo apiMetaDataBo = new ApiMetaDataBo(agentId, agentStartTime, apiMetaData.getApiId(), line, type, apiMetaData.getApiInfo());
        this.apiMetaDataService.insert(apiMetaDataBo);
        return PResult.newBuilder().setSuccess(true).build();
    } catch (Exception e) {
        logger.warn("Failed to handle apiMetaData={}", MessageFormatUtils.debugLog(apiMetaData), e);
        // Avoid detailed error messages.
        return PResult.newBuilder().setSuccess(false).setMessage("Internal Server Error").build();
    }
}
Also used : Header(com.navercorp.pinpoint.grpc.Header) MethodTypeEnum(com.navercorp.pinpoint.common.server.bo.MethodTypeEnum) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)

Example 4 with MethodTypeEnum

use of com.navercorp.pinpoint.common.server.bo.MethodTypeEnum in project pinpoint by naver.

the class ThriftApiMetaDataHandler method handleApiMetaData.

private TResult handleApiMetaData(TApiMetaData apiMetaData) {
    try {
        final String agentId = apiMetaData.getAgentId();
        final long agentStartTime = apiMetaData.getAgentStartTime();
        final int apiId = apiMetaData.getApiId();
        int lineNumber = LineNumber.NO_LINE_NUMBER;
        if (apiMetaData.isSetLine()) {
            lineNumber = apiMetaData.getLine();
        }
        MethodTypeEnum methodType = MethodTypeEnum.DEFAULT;
        if (apiMetaData.isSetType()) {
            methodType = MethodTypeEnum.valueOf(apiMetaData.getType());
        }
        final String apiInfo = apiMetaData.getApiInfo();
        final ApiMetaDataBo apiMetaDataBo = new ApiMetaDataBo(agentId, agentStartTime, apiId, lineNumber, methodType, apiInfo);
        this.apiMetaDataService.insert(apiMetaDataBo);
    } catch (Exception e) {
        logger.warn("Failed to handle apiMetaData={}, Caused:{}", apiMetaData, e.getMessage(), e);
        final TResult result = new TResult(false);
        result.setMessage(e.getMessage());
        return result;
    }
    return new TResult(true);
}
Also used : MethodTypeEnum(com.navercorp.pinpoint.common.server.bo.MethodTypeEnum) ApiMetaDataBo(com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo) TResult(com.navercorp.pinpoint.thrift.dto.TResult)

Aggregations

MethodTypeEnum (com.navercorp.pinpoint.common.server.bo.MethodTypeEnum)4 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)3 Buffer (com.navercorp.pinpoint.common.buffer.Buffer)1 FixedBuffer (com.navercorp.pinpoint.common.buffer.FixedBuffer)1 MetaDataRowKey (com.navercorp.pinpoint.common.server.bo.serializer.metadata.MetaDataRowKey)1 Header (com.navercorp.pinpoint.grpc.Header)1 TResult (com.navercorp.pinpoint.thrift.dto.TResult)1 ArrayList (java.util.ArrayList)1 Cell (org.apache.hadoop.hbase.Cell)1