Search in sources :

Example 21 with TResult

use of com.navercorp.pinpoint.thrift.dto.TResult 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)

Example 22 with TResult

use of com.navercorp.pinpoint.thrift.dto.TResult in project pinpoint by naver.

the class ThriftApiMetaDataHandler method handleRequest.

@Override
public void handleRequest(ServerRequest<TBase<?, ?>> serverRequest, ServerResponse<TBase<?, ?>> serverResponse) {
    final TBase<?, ?> data = serverRequest.getData();
    if (logger.isDebugEnabled()) {
        logger.debug("Handle request data={}", data);
    }
    if (data instanceof TApiMetaData) {
        TResult result = handleApiMetaData((TApiMetaData) data);
        serverResponse.write(result);
    } else {
        logger.warn("invalid serverRequest:{}", serverRequest);
    }
}
Also used : TApiMetaData(com.navercorp.pinpoint.thrift.dto.TApiMetaData) TResult(com.navercorp.pinpoint.thrift.dto.TResult)

Example 23 with TResult

use of com.navercorp.pinpoint.thrift.dto.TResult in project pinpoint by naver.

the class CommandDispatcher method processRequest.

private TBase<?, ?> processRequest(Message<TBase<?, ?>> message) {
    if (message == null) {
        final TResult tResult = new TResult(false);
        tResult.setMessage("Unsupported ServiceTypeInfo.");
        return tResult;
    }
    final short type = message.getHeader().getType();
    final ProfilerRequestCommandService<TBase<?, ?>, TBase<?, ?>> service = commandServiceLocator.getRequestService(type);
    if (service == null) {
        TResult tResult = new TResult(false);
        tResult.setMessage("Can't find suitable service(" + message + ").");
        return tResult;
    }
    final TBase<?, ?> request = message.getData();
    final TBase<?, ?> tResponse = service.requestCommandService(request);
    return tResponse;
}
Also used : TBase(org.apache.thrift.TBase) TResult(com.navercorp.pinpoint.thrift.dto.TResult)

Example 24 with TResult

use of com.navercorp.pinpoint.thrift.dto.TResult in project pinpoint by naver.

the class TCommandRegistryTest method registryTest5.

@Test
public void registryTest5() throws TException {
    TypeLocator<TBase<?, ?>> registry = TCommandRegistry.build(TCommandTypeVersion.V_1_0_2_SNAPSHOT);
    Header header = registry.headerLookup(new TResult());
    Assert.assertNotNull(header);
}
Also used : Header(com.navercorp.pinpoint.io.header.Header) TBase(org.apache.thrift.TBase) TResult(com.navercorp.pinpoint.thrift.dto.TResult) Test(org.junit.Test)

Example 25 with TResult

use of com.navercorp.pinpoint.thrift.dto.TResult in project pinpoint by naver.

the class CommandController method echo.

@GetMapping(value = "/echo")
public CodeResult echo(@RequestParam("applicationName") String applicationName, @RequestParam("agentId") String agentId, @RequestParam("startTimeStamp") long startTimeStamp, @RequestParam("message") String message) throws TException {
    AgentInfo agentInfo = agentService.getAgentInfo(applicationName, agentId, startTimeStamp);
    if (agentInfo == null) {
        return new CodeResult(CODE_FAIL, String.format("Can't find suitable PinpointServer(%s/%s/%d).", applicationName, agentId, startTimeStamp));
    }
    TCommandEcho echo = new TCommandEcho();
    echo.setMessage(message);
    try {
        PinpointRouteResponse pinpointRouteResponse = agentService.invoke(agentInfo, echo);
        if (pinpointRouteResponse != null && pinpointRouteResponse.getRouteResult() == TRouteResult.OK) {
            TBase<?, ?> result = pinpointRouteResponse.getResponse();
            if (result == null) {
                return new CodeResult(CODE_FAIL, "result null.");
            } else if (result instanceof TCommandEcho) {
                return new CodeResult(CODE_SUCCESS, ((TCommandEcho) result).getMessage());
            } else if (result instanceof TResult) {
                return new CodeResult(CODE_FAIL, ((TResult) result).getMessage());
            } else {
                return new CodeResult(CODE_FAIL, result.toString());
            }
        } else {
            return new CodeResult(CODE_FAIL, "unknown");
        }
    } catch (TException e) {
        return new CodeResult(CODE_FAIL, e.getMessage());
    }
}
Also used : TException(org.apache.thrift.TException) CodeResult(com.navercorp.pinpoint.web.vo.CodeResult) TCommandEcho(com.navercorp.pinpoint.thrift.dto.command.TCommandEcho) AgentInfo(com.navercorp.pinpoint.web.vo.AgentInfo) PinpointRouteResponse(com.navercorp.pinpoint.web.cluster.PinpointRouteResponse) TResult(com.navercorp.pinpoint.thrift.dto.TResult) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

TResult (com.navercorp.pinpoint.thrift.dto.TResult)26 TBase (org.apache.thrift.TBase)10 Test (org.junit.Test)7 ResponseMessage (com.navercorp.pinpoint.rpc.ResponseMessage)4 DataReceiverGroupConfiguration (com.navercorp.pinpoint.collector.thrift.config.DataReceiverGroupConfiguration)3 DefaultPinpointClientFactory (com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory)3 PinpointClientFactory (com.navercorp.pinpoint.rpc.client.PinpointClientFactory)3 TCPReceiverBean (com.navercorp.pinpoint.collector.receiver.thrift.TCPReceiverBean)2 UDPReceiverBean (com.navercorp.pinpoint.collector.receiver.thrift.UDPReceiverBean)2 FutureListener (com.navercorp.pinpoint.rpc.FutureListener)2 TAgentInfo (com.navercorp.pinpoint.thrift.dto.TAgentInfo)2 TApiMetaData (com.navercorp.pinpoint.thrift.dto.TApiMetaData)2 TSqlMetaData (com.navercorp.pinpoint.thrift.dto.TSqlMetaData)2 TStringMetaData (com.navercorp.pinpoint.thrift.dto.TStringMetaData)2 TCommandEcho (com.navercorp.pinpoint.thrift.dto.command.TCommandEcho)2 HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)2 GrpcAgentConnection (com.navercorp.pinpoint.collector.cluster.GrpcAgentConnection)1 PinpointGrpcServer (com.navercorp.pinpoint.collector.receiver.grpc.PinpointGrpcServer)1 AgentInfoBo (com.navercorp.pinpoint.common.server.bo.AgentInfoBo)1 ApiMetaDataBo (com.navercorp.pinpoint.common.server.bo.ApiMetaDataBo)1