Search in sources :

Example 1 with HeaderTBaseDeserializer

use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer 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 2 with HeaderTBaseDeserializer

use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer 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 3 with HeaderTBaseDeserializer

use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer in project pinpoint by naver.

the class HeaderTBaseSerializerTest method testSerialize2.

@Test
public void testSerialize2() throws Exception {
    HeaderTBaseSerializer serializer = new HeaderTBaseSerializerFactory().createSerializer();
    HeaderTBaseDeserializer deserializer = new HeaderTBaseDeserializerFactory().createDeserializer();
    test(serializer, deserializer);
}
Also used : HeaderTBaseSerializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer) HeaderTBaseSerializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) HeaderTBaseDeserializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory) Test(org.junit.Test)

Example 4 with HeaderTBaseDeserializer

use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer in project pinpoint by naver.

the class HeaderTBaseSerializerTest method testSerialize1.

@Test
public void testSerialize1() throws Exception {
    HeaderTBaseSerializer serializer = new HeaderTBaseSerializerFactory(false).createSerializer();
    HeaderTBaseDeserializer deserializer = new HeaderTBaseDeserializerFactory().createDeserializer();
    test(serializer, deserializer);
}
Also used : HeaderTBaseSerializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer) HeaderTBaseSerializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) HeaderTBaseDeserializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory) Test(org.junit.Test)

Example 5 with HeaderTBaseDeserializer

use of com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer in project pinpoint by naver.

the class SpanChunkStreamSendDataPlanerTest method deserialize.

private List<TSpanEvent> deserialize(byte[] data) throws TException {
    ByteBuffer bb = ByteBuffer.wrap(data);
    bb.get();
    bb.get();
    int chunkSize = bb.get();
    List<TSpanEvent> eventList = new ArrayList<TSpanEvent>();
    for (int i = 0; i < chunkSize; i++) {
        short componentSize = bb.getShort();
        byte[] component = new byte[componentSize];
        bb.get(component);
        HeaderTBaseDeserializer deserialize = new HeaderTBaseDeserializerFactory().createDeserializer();
        List<TBase<?, ?>> value = deserialize.deserializeList(component);
        for (int j = 0; j < value.size(); j++) {
            TBase tbase = value.get(j);
            if (tbase instanceof TSpanEvent) {
                eventList.add((TSpanEvent) tbase);
            } else {
            }
        }
    }
    return eventList;
}
Also used : ArrayList(java.util.ArrayList) TBase(org.apache.thrift.TBase) ByteBuffer(java.nio.ByteBuffer) TSpanEvent(com.navercorp.pinpoint.thrift.dto.TSpanEvent) HeaderTBaseDeserializer(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer) HeaderTBaseDeserializerFactory(com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory)

Aggregations

HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)10 HeaderTBaseDeserializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializerFactory)6 Test (org.junit.Test)6 TSpanEvent (com.navercorp.pinpoint.thrift.dto.TSpanEvent)4 HeaderTBaseSerializerFactory (com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializerFactory)4 ByteBuffer (java.nio.ByteBuffer)4 TBase (org.apache.thrift.TBase)4 ResponseEvent (com.navercorp.pinpoint.collector.cluster.route.ResponseEvent)2 AgentEventBo (com.navercorp.pinpoint.common.server.bo.AgentEventBo)2 FutureListener (com.navercorp.pinpoint.rpc.FutureListener)2 ResponseMessage (com.navercorp.pinpoint.rpc.ResponseMessage)2 TResult (com.navercorp.pinpoint.thrift.dto.TResult)2 TCommandTransfer (com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer)2 TCommandTransferResponse (com.navercorp.pinpoint.thrift.dto.command.TCommandTransferResponse)2 HeaderTBaseSerializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseSerializer)2 ArrayList (java.util.ArrayList)2 AgentEventType (com.navercorp.pinpoint.common.server.util.AgentEventType)1 Span (com.navercorp.pinpoint.profiler.context.Span)1 SpanChunk (com.navercorp.pinpoint.profiler.context.SpanChunk)1 TSpan (com.navercorp.pinpoint.thrift.dto.TSpan)1