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

Issue 4 #5

Closed
wants to merge 3 commits into from
Closed

Issue 4 #5

wants to merge 3 commits into from

Conversation

werkshy
Copy link
Contributor

@werkshy werkshy commented Apr 8, 2013

Fix for issue #4, single commit on top of previous pull request.

- Only reconnect to new nsqd instances in lookupd response, not all of them
- Disconnect from removed nsqd instances in lookupd response.
- Connections with errors call back to NSQReader.remove()
  (Connection.close() does not do this implicitly).
- Add a unit test for NSQReader (and MockConnection class)
- Add a unit test for SyncResponseReader (and MockHandler class)
- Add some class and method comments
- Fix typo in public method 'Connection.decodeMesage()'

Refs Issue nsqio#3
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not import * here? We're pretty strict here at Bitly about explicit imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That must be an IDE setting. I will find it and kill it.

Andy O'Neill added 2 commits April 16, 2013 11:32
- New MessageCodec class
- Also remove all import foo.* in non-test code.

Refs Issue nsqio#4
@danielhfrank
Copy link
Contributor

So, I actually think that we should be leaving the lookupd response logic as it was. We never really want to disconnect from a nsqd if it is absent from a lookupd response, because the correct client behavior is to connect to the union of all the responses from the lookupds that it queries, in case existence of a producer has not propagated to all the lookupds. We also guard against attempting to make duplicate connections by checking if a connection already exists inside the connectToNsqd method, using the putIfAbsent method of the ConcurrentHashMap of connections. I didn't get a chance to look at the test code added, but I imagine it can be tweaked a little to ensure that we are behaving correctly. Let me know if you have any questions, thanks!

@werkshy
Copy link
Contributor Author

werkshy commented Apr 18, 2013

Ah, I missed this in the old version, which makes a world of difference:

if(stored != null){

return;
}

I see your point about not removing a connection just because a single
lookupd does not contain the producer. The spec for drivers that Matt was
working on suggests that servers /should/ be disconnected if removed from
the lookupd responses. Perhaps we should query all lookupds at once to
create the union of all producers, then decide which need to be
added/dropped. I could adapt my patch to do that if you agree.

Andy

On Tue, Apr 16, 2013 at 5:04 PM, Dan Frank [email protected] wrote:

So, I actually think that we should be leaving the lookupd response logic
as it was. We never really want to disconnect from a nsqd if it is absent
from a lookupd response, because the correct client behavior is to connect
to the union of all the responses from the lookupds that it queries, in
case existence of a producer has not propagated to all the lookupds. We
also guard against attempting to make duplicate connections by checking if
a connection already exists inside the connectToNsqd method, using the
putIfAbsent method of the ConcurrentHashMap of connections. I didn't get
a chance to look at the test code added, but I imagine it can be tweaked a
little to ensure that we are behaving correctly. Let me know if you have
any questions, thanks!


Reply to this email directly or view it on GitHubhttps://github.com//pull/5#issuecomment-16471677
.

@danielhfrank
Copy link
Contributor

Hi @werkshy , trying to do a little summer cleaning around here. I think there's some valuable stuff in this PR, but as I said above I don't think that the lookupd logic should be changed. I may spend some time pulling out some changes from here individually, so keep your eyes peeled

@mreiferson
Copy link
Member

👻

@werkshy werkshy closed this Mar 7, 2018
@werkshy werkshy deleted the issue-3 branch March 7, 2018 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants