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);
}
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);
}
}
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;
}
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);
}
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());
}
}
Aggregations