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

nsqd/nsqlookupd: add --broadcast-address flag #142

Merged
merged 1 commit into from
Feb 6, 2013

Conversation

dustismo
Copy link
Contributor

replaces pull request #141

adds a "broadcast_address" field to the producer objects in nsqlookupd, and the corresponding --broadcast-address option to nsqd.

Additional thoughts?

@mreiferson
Copy link
Member

@dustismo thanks for taking a stab at this, I'll take a look in a few hours.

FYI, in the future feel free to just continue pushing changes to existing pull requests until we either merge or close the issue rather than opening new ones. (we squash intermediate commits into logical units before merging anyway...)

@dustismo
Copy link
Contributor Author

@mreiferson Yeah, sorry about the new pull. I wanted to start from a fresh branch rather then undo all the previous changes. Will not do that in the future.

@@ -28,6 +28,8 @@ func (n *NSQd) lookupLoop() {
ci["tcp_port"] = n.tcpAddr.Port
ci["http_port"] = n.httpAddr.Port
ci["address"] = hostname
ci["broadcast_address"] = n.options.broadcastAddress
Copy link
Member

Choose a reason for hiding this comment

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

so thinking through this a bit, I think what makes the most sense is for this to send both hostname and broadcast_address keys in the JSON dictionary.

on the nsqlookupd side we'll need to "auto-detect" based on the JSON coming in (old nsqd peers will be sending just address and new peers will be sending hostname and broadcast_address)

@mreiferson
Copy link
Member

the only other addition that probably belongs in this pull request is to update nsqadmin to display both values (hostname and broadcast_address)... but I understand if you don't want to step in the hell that is Go templating :)

@dustismo
Copy link
Contributor Author

think these last commits cover all the comments above. let me know of any additional thoughts.

@mreiferson
Copy link
Member

@dustismo, nice work.

Last request... can you update tests in two spots to validate these field changes?

  1. nsqlookupd/nsqlookupd_test.go in TestBasicLookupd()
  2. nsq/cluster_test.go in TestNsqdToLookupd()

thanks

@dustismo
Copy link
Contributor Author

@mreiferson sure thing, though I am a bit confused about how this cluster_test works.

I see this output

starting nsqlookupd
starting nsqd --data-path=/tmp --lookupd-tcp-address=127.0.0.1:4160

but I con't figure out where that is happening. can you point me to it?

@mreiferson
Copy link
Member

test.sh in the root of the repo starts things (when necessary) and runs go test in the right sub-dirs.

The cluster test file depends on test.sh to start local instances. We structured it like this because the cluster test is a layer above any particular daemon and can't start an instance in-process.

@mreiferson
Copy link
Member

@dustismo looks like a one of the recent merges conflicts with this... can you rebase whenever you decide to get back to this?

@dustismo
Copy link
Contributor Author

dustismo commented Feb 4, 2013

@mreiferson This should cover it I think. Let me know if you see anything else. Also, sorry, I did a merge of master rather then a rebase, is that a problem?

@@ -176,7 +176,8 @@ func tombstoneTopicProducerHandler(w http.ResponseWriter, req *http.Request) {
log.Printf("DB: setting tombstone for producer@%s of topic(%s)", node, topicName)
producers := lookupd.DB.FindProducers("topic", topicName, "")
for _, p := range producers {
thisNode := fmt.Sprintf("%s:%d", p.Address, p.HttpPort)
thisNode := fmt.Sprintf("%s:%d", p.BroadcastAddress, p.HttpPort)
log.Println("THIS NODE: " + thisNode + " EQUALS: " + node)
Copy link
Member

Choose a reason for hiding this comment

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

we can drop this debug line

@mreiferson
Copy link
Member

re: merge vs rebase... we take the approach that while we're working in branches we strictly rebase on master so as to not introduce merge commits.

when we're ready for this to go in we'll rebase/squash down to one commit and merge that into master.

@dustismo
Copy link
Contributor Author

dustismo commented Feb 5, 2013

@mreiferson I think that covers the broadcast-address flag addition for nsqlookupd.

@@ -231,7 +237,10 @@ func (p *LookupProtocolV1) IDENTIFY(client *ClientV1, reader *bufio.Reader, para
if err != nil {
log.Fatalf("ERROR: unable to get hostname %s", err.Error())
}
data["address"] = hostname
data["address"] = lookupd.broadcastAddress //TODO: remove for 1.0
Copy link
Member

Choose a reason for hiding this comment

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

address should continue to be just hostname (despite the fact that broadcastAddress defaults to hostname) for backward compatibility

@mreiferson
Copy link
Member

the nsqlookupd side changes look good... nsqd can now try to use BroadcastAddress if non-empty and Address otherwise at https://github.com/dustismo/nsq/blob/broadcast_address_flag/nsqd/lookup.go#L147.

Related to this, in https://github.com/dustismo/nsq/blob/broadcast_address_flag/nsq/lookup_peer.go#L23, we need to add BroadcastAddress string json:"broadcast_address"`` so that it will automagically decode into the structure.

@dustismo
Copy link
Contributor Author

dustismo commented Feb 5, 2013

@mreiferson hows that?

@mreiferson
Copy link
Member

sweet, i think this looks good!

can you do a final rebase on bitly/master and squash down to one commit?

add broadcast address

update test with broadcast addr

format

format

add hostname key to lookup

add hostname field

fmt

update test

add broadcast address and hostname to nodes admin page

fmt

more Address changes

update to use broadcast address with identify and all throughout the lookup

update test for broadcast_address

test broadcast address

remove debug line

add broadcast flag to lookupd

fmt

update readme

switch address back to hostname for backward compat

update to use broadcast address

fmt
@dustismo
Copy link
Contributor Author

dustismo commented Feb 6, 2013

phew, rebase and squash was a new git adventure for me :). Think it all looks good now.

@mreiferson
Copy link
Member

thanks for the contribution, LGTM

mreiferson added a commit that referenced this pull request Feb 6, 2013
nsqd/nsqlookupd: add --broadcast-address flag
@mreiferson mreiferson merged commit 6b0285d into nsqio:master Feb 6, 2013
arussellsaw pushed a commit to arussellsaw/nsq that referenced this pull request Mar 5, 2018
…ation

- responsibility has been moved to Consumer startStopContinueBackoff
- see PR nsqio#147 and nsqio#142
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants