use of com.linkedin.r2.message.stream.entitystream.FullEntityObserver in project rest.li by linkedin.
the class BackupRequestsClient method streamRequest.
@Override
public void streamRequest(StreamRequest request, RequestContext requestContext, Callback<StreamResponse> callback) {
// Currently only support backup requests with IS_FULL_REQUEST.
if (!isFullRequest(requestContext)) {
_d2Client.streamRequest(request, requestContext, callback);
return;
}
if (!isBuffered(requestContext)) {
final FullEntityObserver observer = new FullEntityObserver(new Callback<ByteString>() {
@Override
public void onError(Throwable e) {
LOG.warn("Failed to record request's entity for retrying backup request.");
}
@Override
public void onSuccess(ByteString result) {
requestContext.putLocalAttr(R2Constants.BACKUP_REQUEST_BUFFERED_BODY, result);
}
});
request.getEntityStream().addObserver(observer);
}
if (_isD2Async) {
requestAsync(request, requestContext, _d2Client::streamRequest, callback);
return;
}
_d2Client.streamRequest(request, requestContext, decorateCallbackSync(request, requestContext, _d2Client::streamRequest, callback));
}
Aggregations