Search in sources :

Example 1 with ResponseMessage

use of com.navercorp.pinpoint.rpc.ResponseMessage in project pinpoint by naver.

the class AgentInfoSenderListener method deserialize.

private TBase<?, ?> deserialize(Future<ResponseMessage> future) {
    final ResponseMessage responseMessage = future.getResult();
    // TODO Should we change this to thread local cache? This object's life cycle is different because it could be created many times.
    // Should we cache this?
    byte[] message = responseMessage.getMessage();
    return SerializationUtils.deserialize(message, HeaderTBaseDeserializerFactory.DEFAULT_FACTORY, null);
}
Also used : ResponseMessage(com.navercorp.pinpoint.rpc.ResponseMessage)

Example 2 with ResponseMessage

use of com.navercorp.pinpoint.rpc.ResponseMessage 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 ResponseMessage

use of com.navercorp.pinpoint.rpc.ResponseMessage 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 ResponseMessage

use of com.navercorp.pinpoint.rpc.ResponseMessage in project pinpoint by naver.

the class RequestManager method messageReceived.

public void messageReceived(ResponsePacket responsePacket, PinpointServer pinpointServer) {
    final int requestId = responsePacket.getRequestId();
    final DefaultFuture<ResponseMessage> future = removeMessageFuture(requestId);
    if (future == null) {
        logger.warn("future not found:{}, pinpointServer:{}", responsePacket, pinpointServer);
        return;
    } else {
        logger.debug("responsePacket arrived packet:{}, pinpointServer:{}", responsePacket, pinpointServer);
    }
    ResponseMessage response = new ResponseMessage();
    response.setMessage(responsePacket.getPayload());
    future.setResult(response);
}
Also used : ResponseMessage(com.navercorp.pinpoint.rpc.ResponseMessage)

Example 5 with ResponseMessage

use of com.navercorp.pinpoint.rpc.ResponseMessage in project pinpoint by naver.

the class RequestManager method register.

public ChannelWriteFailListenableFuture<ResponseMessage> register(RequestPacket requestPacket, long timeoutMillis) {
    // shutdown check
    final int requestId = getNextRequestId();
    requestPacket.setRequestId(requestId);
    final ChannelWriteFailListenableFuture<ResponseMessage> future = new ChannelWriteFailListenableFuture<ResponseMessage>(timeoutMillis);
    final DefaultFuture old = this.requestMap.put(requestId, future);
    if (old != null) {
        throw new PinpointSocketException("unexpected error. old future exist:" + old + " id:" + requestId);
    }
    // when future fails, put a handle in order to remove a failed future in the requestMap.
    FailureEventHandler removeTable = createFailureEventHandler(requestId);
    future.setFailureEventHandler(removeTable);
    addTimeoutTask(timeoutMillis, future);
    return future;
}
Also used : FailureEventHandler(com.navercorp.pinpoint.rpc.FailureEventHandler) PinpointSocketException(com.navercorp.pinpoint.rpc.PinpointSocketException) ResponseMessage(com.navercorp.pinpoint.rpc.ResponseMessage) ChannelWriteFailListenableFuture(com.navercorp.pinpoint.rpc.ChannelWriteFailListenableFuture) DefaultFuture(com.navercorp.pinpoint.rpc.DefaultFuture)

Aggregations

ResponseMessage (com.navercorp.pinpoint.rpc.ResponseMessage)12 PinpointSocketException (com.navercorp.pinpoint.rpc.PinpointSocketException)4 DefaultFuture (com.navercorp.pinpoint.rpc.DefaultFuture)2 FutureListener (com.navercorp.pinpoint.rpc.FutureListener)2 PinpointSocket (com.navercorp.pinpoint.rpc.PinpointSocket)2 PinpointServerAcceptor (com.navercorp.pinpoint.rpc.server.PinpointServerAcceptor)2 TResult (com.navercorp.pinpoint.thrift.dto.TResult)2 TCommandTransfer (com.navercorp.pinpoint.thrift.dto.command.TCommandTransfer)2 HeaderTBaseDeserializer (com.navercorp.pinpoint.thrift.io.HeaderTBaseDeserializer)2 DefaultPinpointRouteResponse (com.navercorp.pinpoint.web.cluster.DefaultPinpointRouteResponse)2 FailedPinpointRouteResponse (com.navercorp.pinpoint.web.cluster.FailedPinpointRouteResponse)2 PinpointRouteResponse (com.navercorp.pinpoint.web.cluster.PinpointRouteResponse)2 IOException (java.io.IOException)2 TBase (org.apache.thrift.TBase)2 TargetClusterPoint (com.navercorp.pinpoint.collector.cluster.TargetClusterPoint)1 ChannelWriteFailListenableFuture (com.navercorp.pinpoint.rpc.ChannelWriteFailListenableFuture)1 FailureEventHandler (com.navercorp.pinpoint.rpc.FailureEventHandler)1 Future (com.navercorp.pinpoint.rpc.Future)1 AgentInfo (com.navercorp.pinpoint.web.vo.AgentInfo)1 HashMap (java.util.HashMap)1