Search in sources :

Example 16 with TResult

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

the class DispatchHandlerWrapper method dispatchRequestMessage.

@Override
public TBase dispatchRequestMessage(TBase<?, ?> tBase) {
    if (checkAvaiable()) {
        return this.delegate.dispatchRequestMessage(tBase);
    }
    logger.debug("Handler is disabled. Skipping request message {}.", tBase);
    TResult result = new TResult(false);
    result.setMessage("Handler is disabled. Skipping request message.");
    return result;
}
Also used : TResult(com.navercorp.pinpoint.thrift.dto.TResult)

Example 17 with TResult

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

the class AgentInfoSenderListener method onComplete.

@Override
public void onComplete(Future<ResponseMessage> future) {
    try {
        if (future != null && future.isSuccess()) {
            TBase<?, ?> tbase = deserialize(future);
            if (tbase instanceof TResult) {
                TResult result = (TResult) tbase;
                if (result.isSuccess()) {
                    logger.debug("result success");
                    this.isSuccessful.set(true);
                    return;
                } else {
                    logger.warn("request fail. Caused:{}", result.getMessage());
                }
            } else {
                logger.warn("Invalid Class. {}", tbase);
            }
        }
    } catch (Exception e) {
        logger.warn("request fail. caused:{}", e.getMessage());
    }
}
Also used : TResult(com.navercorp.pinpoint.thrift.dto.TResult)

Example 18 with TResult

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

the class CommandDispatcher method handleRequest.

@Override
public void handleRequest(RequestPacket requestPacket, PinpointSocket pinpointSocket) {
    logger.info("handleRequest packet:{}, remote:{}", requestPacket, pinpointSocket.getRemoteAddress());
    final TBase<?, ?> request = SerializationUtils.deserialize(requestPacket.getPayload(), CommandSerializer.DESERIALIZER_FACTORY, null);
    logger.debug("handleRequest request:{}, remote:{}", request, pinpointSocket.getRemoteAddress());
    TBase response;
    if (request == null) {
        final TResult tResult = new TResult(false);
        tResult.setMessage("Unsupported ServiceTypeInfo.");
        response = tResult;
    } else {
        final ProfilerRequestCommandService service = commandServiceLocator.getRequestService(request);
        if (service == null) {
            TResult tResult = new TResult(false);
            tResult.setMessage("Can't find suitable service(" + request + ").");
            response = tResult;
        } else {
            response = service.requestCommandService(request);
        }
    }
    final byte[] payload = SerializationUtils.serialize(response, CommandSerializer.SERIALIZER_FACTORY, null);
    if (payload != null) {
        pinpointSocket.response(requestPacket, payload);
    }
}
Also used : TBase(org.apache.thrift.TBase) TResult(com.navercorp.pinpoint.thrift.dto.TResult)

Example 19 with TResult

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

the class DataReceiverGroupTest method receiverGroupTest2.

@Test
public void receiverGroupTest2() throws Exception {
    DataReceiverGroupConfiguration mockConfig = createMockConfig(true, false);
    TestDispatchHandler testDispatchHandler = new TestDispatchHandler(1, 1);
    TCPReceiverBean receiver = createTcpReceiverBean(mockConfig, testDispatchHandler);
    DataSender<TBase<?, ?>> udpDataSender = null;
    TcpDataSender<TBase<?, ?>> tcpDataSender = null;
    PinpointClientFactory pinpointClientFactory = null;
    try {
        receiver.afterPropertiesSet();
        udpDataSender = newUdpDataSender(mockConfig);
        udpDataSender.send(new TResult());
        Assert.assertFalse(testDispatchHandler.getSendLatch().await(1000, TimeUnit.MILLISECONDS));
        pinpointClientFactory = createPinpointClientFactory();
        tcpDataSender = new TcpDataSender<>(this.getClass().getName(), "127.0.0.1", mockConfig.getTcpBindPort(), pinpointClientFactory);
        Assert.assertTrue(tcpDataSender.isConnected());
        tcpDataSender.send(new TResult());
        tcpDataSender.request(new TResult());
        Assert.assertTrue(testDispatchHandler.getSendLatch().await(1000, TimeUnit.MILLISECONDS));
        Assert.assertTrue(testDispatchHandler.getRequestLatch().await(1000, TimeUnit.MILLISECONDS));
    } finally {
        closeDataSender(udpDataSender);
        closeDataSender(tcpDataSender);
        closeClientFactory(pinpointClientFactory);
        closeBean(receiver);
    }
}
Also used : PinpointClientFactory(com.navercorp.pinpoint.rpc.client.PinpointClientFactory) DefaultPinpointClientFactory(com.navercorp.pinpoint.rpc.client.DefaultPinpointClientFactory) DataReceiverGroupConfiguration(com.navercorp.pinpoint.collector.thrift.config.DataReceiverGroupConfiguration) TBase(org.apache.thrift.TBase) TCPReceiverBean(com.navercorp.pinpoint.collector.receiver.thrift.TCPReceiverBean) TResult(com.navercorp.pinpoint.thrift.dto.TResult) Test(org.junit.Test)

Example 20 with TResult

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

the class ThriftSqlMetaDataHandler method handleSqlMetaData.

private TResult handleSqlMetaData(TSqlMetaData sqlMetaData) {
    try {
        final SqlMetaDataBo sqlMetaDataBo = new SqlMetaDataBo(sqlMetaData.getAgentId(), sqlMetaData.getAgentStartTime(), sqlMetaData.getSqlId(), sqlMetaData.getSql());
        sqlMetaDataService.insert(sqlMetaDataBo);
    } catch (Exception e) {
        logger.warn("Failed to handle SqlMetaData={}, Caused:{}", sqlMetaData, e.getMessage(), e);
        final TResult result = new TResult(false);
        result.setMessage(e.getMessage());
        return result;
    }
    return new TResult(true);
}
Also used : SqlMetaDataBo(com.navercorp.pinpoint.common.server.bo.SqlMetaDataBo) TResult(com.navercorp.pinpoint.thrift.dto.TResult)

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