Search in sources :

Example 1 with TResult

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

the class ProfilerCommandServiceLocatorTest method basicFunctionTest2.

@Test
public void basicFunctionTest2() throws Exception {
    ProfilerCommandLocatorBuilder builder = new ProfilerCommandLocatorBuilder();
    builder.addService(new MockCommandServiceGroup());
    ProfilerCommandServiceLocator commandServiceLocator = builder.build();
    TResult commandResult = new TResult();
    TCommandTransfer commandTransfer = new TCommandTransfer();
    Assert.assertEquals(2, commandServiceLocator.getCommandServiceClasses().size());
    Assert.assertEquals(2, commandServiceLocator.getCommandServiceCodes().size());
    Assert.assertTrue(commandServiceLocator.getCommandServiceCodes().contains(TCommandType.getType(commandResult.getClass()).getCode()));
    Assert.assertTrue(commandServiceLocator.getCommandServiceCodes().contains(TCommandType.getType(commandTransfer.getClass()).getCode()));
    Assert.assertNotNull(commandServiceLocator.getService(commandResult));
    Assert.assertNotNull(commandServiceLocator.getSimpleService(commandResult));
    Assert.assertNull(commandServiceLocator.getRequestService(commandResult));
    Assert.assertNull(commandServiceLocator.getStreamService(commandResult));
    Assert.assertNotNull(commandServiceLocator.getService(commandTransfer));
    Assert.assertNotNull(commandServiceLocator.getStreamService(commandTransfer));
    Assert.assertNull(commandServiceLocator.getSimpleService(commandTransfer));
    Assert.assertNull(commandServiceLocator.getRequestService(commandTransfer));
}
Also used : TCommandTransfer(com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer) TResult(com.navercorp.pinpoint.thrift.dto.TResult) Test(org.junit.Test)

Example 2 with TResult

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

the class TcpDataSender method doRequest.

// Separate doRequest method to avoid creating unnecessary objects. (Generally, sending message is successed when firt attempt.)
private void doRequest(final RetryMessage retryMessage) {
    FutureListener futureListener = (new FutureListener<ResponseMessage>() {

        @Override
        public void onComplete(Future<ResponseMessage> future) {
            if (future.isSuccess()) {
                // Should cache?
                HeaderTBaseDeserializer deserializer = HeaderTBaseDeserializerFactory.DEFAULT_FACTORY.createDeserializer();
                TBase<?, ?> response = deserialize(deserializer, future.getResult());
                if (response instanceof TResult) {
                    TResult result = (TResult) response;
                    if (result.isSuccess()) {
                        logger.debug("result success");
                    } else {
                        logger.info("request fail. request:{}, Caused:{}", retryMessage, result.getMessage());
                        retryRequest(retryMessage);
                    }
                } else {
                    logger.warn("Invalid response:{}", response);
                // This is not retransmission. need to log for debugging
                // it could be null
                //                        retryRequest(requestPacket);
                }
            } else {
                logger.info("request fail. request:{}, caused:{}", retryMessage, future.getCause().getMessage(), future.getCause());
                retryRequest(retryMessage);
            }
        }
    });
    doRequest(retryMessage.getBytes(), futureListener);
}
Also used : FutureListener(com.navercorp.pinpoint.rpc.FutureListener) TBase(org.apache.thrift.TBase) ResponseMessage(com.navercorp.pinpoint.rpc.ResponseMessage) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) TResult(com.navercorp.pinpoint.thrift.dto.TResult)

Example 3 with TResult

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

the class TcpDataSender method doRequest.

// Separate doRequest method to avoid creating unnecessary objects. (Generally, sending message is successed when firt attempt.)
private void doRequest(final byte[] requestPacket, final int maxRetryCount, final Object targetClass) {
    FutureListener futureListener = (new FutureListener<ResponseMessage>() {

        @Override
        public void onComplete(Future<ResponseMessage> future) {
            if (future.isSuccess()) {
                // Should cache?
                HeaderTBaseDeserializer deserializer = HeaderTBaseDeserializerFactory.DEFAULT_FACTORY.createDeserializer();
                TBase<?, ?> response = deserialize(deserializer, future.getResult());
                if (response instanceof TResult) {
                    TResult result = (TResult) response;
                    if (result.isSuccess()) {
                        logger.debug("result success");
                    } else {
                        logger.info("request fail. request:{} Caused:{}", targetClass, result.getMessage());
                        RetryMessage retryMessage = new RetryMessage(1, maxRetryCount, requestPacket, targetClass.getClass().getSimpleName());
                        retryRequest(retryMessage);
                    }
                } else {
                    logger.warn("Invalid respose:{}", response);
                // This is not retransmission. need to log for debugging
                // it could be null
                //                        retryRequest(requestPacket);
                }
            } else {
                logger.info("request fail. request:{} Caused:{}", targetClass, future.getCause().getMessage(), future.getCause());
                RetryMessage retryMessage = new RetryMessage(1, maxRetryCount, requestPacket, targetClass.getClass().getSimpleName());
                retryRequest(retryMessage);
            }
        }
    });
    doRequest(requestPacket, futureListener);
}
Also used : FutureListener(com.navercorp.pinpoint.rpc.FutureListener) TBase(org.apache.thrift.TBase) ResponseMessage(com.navercorp.pinpoint.rpc.ResponseMessage) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) TResult(com.navercorp.pinpoint.thrift.dto.TResult)

Example 4 with TResult

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

the class TCommandRegistryTest method registryTest2.

@Test(expected = TException.class)
public void registryTest2() throws TException {
    TCommandRegistry registry = new TCommandRegistry(TCommandTypeVersion.UNKNOWN);
    registry.headerLookup(new TResult());
}
Also used : TResult(com.navercorp.pinpoint.thrift.dto.TResult) Test(org.junit.Test)

Example 5 with TResult

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

the class ThriftAgentInfoHandler method handleAgentInfo.

private TResult handleAgentInfo(TAgentInfo agentInfo) {
    try {
        // agent info
        final AgentInfoBo agentInfoBo = this.agentInfoBoMapper.map(agentInfo);
        this.agentInfoService.insert(agentInfoBo);
        return new TResult(true);
    } catch (Exception e) {
        logger.warn("Failed to handle AgentInfo={}, Caused:{}", agentInfo, e.getMessage(), e);
        final TResult result = new TResult(false);
        result.setMessage(e.getMessage());
        return result;
    }
}
Also used : AgentInfoBo(com.navercorp.pinpoint.common.server.bo.AgentInfoBo) 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