Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor DirectDruidClient, extract QueryContextInputStreamResponseHandler #8848

Closed
wants to merge 9 commits into from

Conversation

zhenxiao
Copy link
Contributor

@zhenxiao zhenxiao commented Nov 9, 2019

Fixes #8444
CC @leventov

import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;

public class BufferInputStreamResponseHandler implements HttpResponseHandler<InputStream, InputStream>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a class-level Javadoc explaining something about this class. Also, its name suggests that it could possibly be emulated by combining existing pieces (like BufferedInputStream + some other HttpResponseHandler). If that is not possible, or the semantics are actually different, it should be highlighted in the comment.

Optional: explain the concurrency (the class has a lot of it: Atomic fields, BlockingQueue, etc.) and add concurrent access documentation to the methods of this class.

@zhenxiao zhenxiao changed the title Refactor DirectDruidClient, extract BufferInputStreamResponseHandler Refactor DirectDruidClient, extract QueryContextInputStreamResponseHandler Nov 17, 2019
@zhenxiao
Copy link
Contributor Author

thank you, @leventov
get comments addressed

/**
* An HTTP response handler which uses sequence input streams to create a final InputStream.
*
* This implementation takes query context into consideration, e.g. timeout, maxQueuedBytes, backpressue.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo, "backpressure"

* may end with an IOException upon read()
*
* {@link org.apache.druid.java.util.http.client.response.SequenceInputStreamResponseHandler} also uses
* sequence input streams to create final InputStream, but it does not have timeout, backpressue,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

* An HTTP response handler which uses sequence input streams to create a final InputStream.
*
* This implementation takes query context into consideration, e.g. timeout, maxQueuedBytes, backpressue.
* It uses a blocking queue to feed a SequenceInputStream that is terminated whenever the handler's Done
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make "Done method" a javadoc link

* method is called or a throwable is detected.
*
* The resulting InputStream will attempt to terminate normally, but on exception in HttpResponseHandler
* may end with an IOException upon read()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And please make read() a javadoc link

@zhenxiao
Copy link
Contributor Author

thank you, @leventov
comments addressed

* method is called or a throwable is detected.
* This implementation takes query context into consideration, e.g. timeout, maxQueuedBytes, backpressure.
* It uses a blocking queue to feed a SequenceInputStream that is terminated whenever the handler's
* {@link #Done()} is called or a throwable is detected.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link is not valid.

*
* The resulting InputStream will attempt to terminate normally, but on exception in HttpResponseHandler
* may end with an IOException upon read()
* may end with an IOException upon {@link #read()}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this

@zhenxiao
Copy link
Contributor Author

thank you @leventov
how about this one?

Copy link
Member

@leventov leventov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please fix inspection errors

@zhenxiao
Copy link
Contributor Author

thank you, @leventov
inspection fixed

@leventov
Copy link
Member

CI still fails

@zhenxiao
Copy link
Contributor Author

Hi @leventov
seems CI failures are not related to this PR. Do you think I need to merge master commits into this one?

@leventov
Copy link
Member

leventov commented Dec 2, 2019

Yes, merge master

@zhenxiao zhenxiao force-pushed the direct-client branch 5 times, most recently from 09ccafb to 30868ef Compare December 3, 2019 07:46
@leventov
Copy link
Member

leventov commented Dec 3, 2019

@zhenxiao note for future: don't force push branches. merge master into PR branch, do not rebase.

@zhenxiao
Copy link
Contributor Author

zhenxiao commented Dec 3, 2019

whoops, CI pass now @leventov how about this one?
when merge master into my branch, let's say before merge my branch:
old-master -> my patch
after merge, it could be:
A. old-master -> my patch -> (old to new master patches)
or:
B. new master -> my patch

A will have conflicts with base brach. B will need force push. which one should I do?

@leventov
Copy link
Member

leventov commented Dec 6, 2019

When you are at the state "old-master -> my patch", you just need to run two actions: git fetch origin master and git merge origin/master. If there are conflicts, resolve them and commit.

Then history will look like this:

old-master -> your patch -> merge commit (HEAD of your PR branch)
   \____ new master _______/

@zhenxiao
Copy link
Contributor Author

zhenxiao commented Dec 6, 2019

thank you so much, @leventov I will do it next time
get inspection errors fixed. See how this goes

@zhenxiao
Copy link
Contributor Author

zhenxiao commented Dec 6, 2019

tests passed. @leventov could you please take a look?

@leventov
Copy link
Member

leventov commented Dec 7, 2019

@codecov-io
Copy link

codecov-io commented Jan 31, 2020

Codecov Report

Merging #8848 into master will increase coverage by 0.96%.
The diff coverage is 17.96%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #8848      +/-   ##
============================================
+ Coverage     62.93%    63.9%   +0.96%     
- Complexity    22577    22580       +3     
============================================
  Files          2980     2865     -115     
  Lines        123590   117386    -6204     
  Branches      17030    15646    -1384     
============================================
- Hits          77785    75010    -2775     
+ Misses        38708    35510    -3198     
+ Partials       7097     6866     -231
Impacted Files Coverage Δ Complexity Δ
...ava/org/apache/druid/client/DirectDruidClient.java 79.31% <100%> (+41.17%) 9 <0> (ø) ⬇️
...client/QueryContextInputStreamResponseHandler.java 16.26% <16.26%> (ø) 2 <2> (?)
...java/org/apache/druid/client/BrokerServerView.java 57.37% <50%> (+1.12%) 10 <1> (ø) ⬇️
.../server/coordination/SegmentChangeRequestNoop.java 20% <0%> (-20%) 1% <0%> (-1%)
.../apache/druid/client/BatchServerInventoryView.java 80.76% <0%> (-5.77%) 10% <0%> (-1%)
...ache/druid/indexing/overlord/RemoteTaskRunner.java 63.26% <0%> (-0.35%) 83% <0%> (-1%)
...che/druid/metadata/SqlSegmentsMetadataManager.java 71.69% <0%> (-0.27%) 66% <0%> (-1%)
...nsole/src/components/show-history/show-history.tsx
web-console/src/components/loader/loader.tsx
web-console/src/components/deferred/deferred.tsx
... and 123 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 204ba99...806825f. Read the comment docs.

@stale
Copy link

stale bot commented Mar 31, 2020

This pull request has been marked as stale due to 60 days of inactivity. It will be closed in 4 weeks if no further activity occurs. If you think that's incorrect or this pull request should instead be reviewed, please simply write any comment. Even if closed, you can still revive the PR at any time or discuss it on the dev@druid.apache.org list. Thank you for your contributions.

@stale stale bot added the stale label Mar 31, 2020
@stale
Copy link

stale bot commented Apr 28, 2020

This pull request/issue has been closed due to lack of activity. If you think that is incorrect, or the pull request requires review, you can revive the PR at any time.

@stale stale bot closed this Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor DirectDruidClient.run()
3 participants