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