Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(38)

Issue 1626044: For consideration: base APIs supporting streaming fetch

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 7 months ago by johnfargo
Modified:
15 years, 7 months ago
Reviewers:
gagan.goku, shindig.remailer, zhoresh
Base URL:
http://svn.apache.org/repos/asf/shindig/trunk/
Visibility:
Public.

Description

This CL adds new stream-based APIs for getting content from and setting content to a MutableContent object, and extends this to the intended primary use, creation of HttpResponse objects. It extends byte[]-mutation APIs by adding an internal wrapper around the byte array; however, no existing method's semantics are modified by this change, the wrapper providing a layer of indirection. When using streaming-set/get APIs, the key limitation is put in place that a content stream may only be retrieved once. This (simplified) policy ensures that streaming content is accessed in a clear fashion. As well, when generating an HttpResponse from a content stream, byte[]-based content encoding detection is not supported. Adherence to these policies is intended, with this design approach (as opposed to building a completely parallel streaming pipeline), to be a function of wiring/configuration: proxies/rewriters that require streaming must *all* use streaming APIs. The implementation allows a streaming-set operation to later be compatible with buffered-read operations. In other words, setContentStream(InputStream) is functionally equivalent to setContentBytes(byte[]), with the former buffering all content before supporting existing operations. A direct consequence is that HttpFetcher implementations may now be "streaming-type" without having to modify any existing rewriter logic. The intent of this CL is to roll out support for streaming fetch operations in Shindig slowly: 1. As noted, allows HttpFetcher implementations to be streaming-type now. 2. Provides basis for streaming (pass-through) proxy support with little effort. 3. Provides basis for streaming rewrites (depending on type, will require additional work such as streaming parser). Sending CL for design review before augmenting tests enforcing streaming policy.

Patch Set 1 #

Patch Set 2 : Fixed patch. #

Total comments: 4

Patch Set 3 : Accommodate Ziv's comments. Lazy-detect encoding (still w/ header-set). #

Total comments: 3
Unified diffs Side-by-side diffs Delta from patch set Stats (+267 lines, -82 lines) Patch
java/gadgets/src/main/java/org/apache/shindig/gadgets/http/DefaultRequestPipeline.java View 1 chunk +1 line, -1 line 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponse.java View 1 2 14 chunks +111 lines, -44 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponseBuilder.java View 1 5 chunks +30 lines, -24 lines 0 comments Download
java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/MutableContent.java View 1 2 6 chunks +125 lines, -13 lines 3 comments Download

Messages

Total messages: 7
johnfargo
15 years, 7 months ago (2010-06-10 15:53:41 UTC) #1
johnfargo
Fixed patch.
15 years, 7 months ago (2010-06-11 15:27:47 UTC) #2
zhoresh
And don't forget to write tests... http://codereview.appspot.com/1626044/diff/5001/6002 File java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponse.java (right): http://codereview.appspot.com/1626044/diff/5001/6002#newcode498 java/gadgets/src/main/java/org/apache/shindig/gadgets/http/HttpResponse.java:498: if (body == ...
15 years, 7 months ago (2010-06-14 23:56:28 UTC) #3
johnfargo
Thanks for the feedback, Ziv! Comments inline. On Mon, Jun 14, 2010 at 4:56 PM, ...
15 years, 7 months ago (2010-06-15 00:54:30 UTC) #4
johnfargo
Accommodate Ziv's comments. Lazy-detect encoding (still w/ header-set).
15 years, 7 months ago (2010-06-15 01:02:44 UTC) #5
zhoresh
Some minor comments, mainly look good (tests...). I still wonder if we have code path ...
15 years, 7 months ago (2010-06-15 04:58:30 UTC) #6
johnfargo
15 years, 7 months ago (2010-06-16 01:33:28 UTC) #7
On Mon, Jun 14, 2010 at 9:58 PM, <zhoresh@gmail.com> wrote:

> Some minor comments, mainly look good (tests...).
> I still wonder if we have code path that do multiple getStream on the
> content.
> (I guess one way to test now would be to mimic the behavior in the byte
> array content, and test the server)
>
>
> http://codereview.appspot.com/1626044/diff/15001/16004
>
> File
>
>
java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/MutableContent.java
> (right):
>
> http://codereview.appspot.com/1626044/diff/15001/16004#newcode293
>
>
java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/MutableContent.java:293:
> public byte[] getBytes() {
> Add throw
>

It doesn't throw a checked exception though, just a RuntimeException. I
could add "throws StreamingException" all the way up the stack for
documentation purposes though... thoughts?


>
> http://codereview.appspot.com/1626044/diff/15001/16004#newcode304
>
>
java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/MutableContent.java:304:
> public InputStream getStream() {
> add "throw StreamingException"
>

same


>
> http://codereview.appspot.com/1626044/diff/15001/16004#newcode328
>
>
java/gadgets/src/main/java/org/apache/shindig/gadgets/rewrite/MutableContent.java:328:
> return stream != other.stream;
> is that always true?


Not if the other StreamingContentBytes is constructed w/ a different
underlying stream.


>
>
> http://codereview.appspot.com/1626044/show
>
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b