use of com.navercorp.pinpoint.rpc.FutureListener 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.FutureListener 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);
}
Aggregations