You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
allow overriding HttpResponse.getContent to install download throttler #586
We need to throttle downloads from cloud storage in order to minimize GC disturbances during (data) reload. I was unable to find a clean way to do this via existing API. Instead, the following workaround was implemented which suffers from extending HttpURLConnection. Is it possible to provide a proper hook for intercepting InputStream?
classThrottledUrlConnectionextendsHttpURLConnection {
HttpURLConnectiondelegate;
ThrottledUrlConnection(HttpURLConnectiondelegate, URLurl) {
super(url);
this.delegate = delegate;
}
@OverridepublicInputStreamgetInputStream() throwsIOException {
returnnewThrottledInputStream(delegate.getInputStream(), rateLimiter, throughputMeter);
}
// followed by a long list of overridden methods to redirect via 'delegate'
....
}
Activity
srosenberg commentedon Feb 10, 2019
Per @ajaaym suggestion in googleapis/google-cloud-java#3534, we should be able to use the interceptor (https://github.com/googleapis/google-http-java-client/blob/master/google-http-client/src/main/java/com/google/api/client/http/HttpResponseInterceptor.java); problem is
getContentneeds to be overridden in order to install the throttler.