Skip to content

RUBY-932 Update Server Discovery and Monitoring code and tests #637

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

Merged
merged 18 commits into from
Jun 22, 2015

Conversation

estolfo
Copy link
Contributor

@estolfo estolfo commented Jun 12, 2015

No description provided.

@estolfo estolfo force-pushed the RUBY-932-duplicate-servers branch 5 times, most recently from 28b3a14 to 24e87cb Compare June 15, 2015 10:35
# @return [ true, false ] If the description is from the server.
#
# @since 2.0.6
def self?(server)
Copy link
Member

Choose a reason for hiding this comment

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

I might change this name to something else, given that self is reserved in Ruby and this might be a bit confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed it to Description#me?(server)

@estolfo estolfo force-pushed the RUBY-932-duplicate-servers branch from 24e87cb to 58def90 Compare June 15, 2015 10:53
@estolfo estolfo changed the title [WIP] RUBY-932 Update Server Discovery and Monitoring code and tests RUBY-932 Update Server Discovery and Monitoring code and tests Jun 15, 2015
@durran
Copy link
Member

durran commented Jun 15, 2015

👍

@servers = []
@servers_update = Mutex.new
Copy link
Member

Choose a reason for hiding this comment

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

I'd just put one big lock around Cluster and do all non-I/O operations (both reads and updates to all data structures) while holding the lock. If you do I/O, drop the lock, do your operation without touching any Cluster data structures, then reacquire the lock in order to update your data structures according to what you discovered from doing the I/O. So, no need to distinguish between these two mutexes, just lock the whole Cluster whenever you touch it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review.
I'm not going to take this approach because there is IO in a bunch of places that might not be obvious (like in the instantiation of an Address, for example) and the code would get messy if I was frequently grabbing and releasing the lock in between lines of code in Cluster.

I have taken your suggestion to only use one lock for both the servers and addresses list.

You're also right about having to copy the list. I've added that in as well.

Thanks again!

Copy link
Member

Choose a reason for hiding this comment

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

Glad I could help!

On Thu, Jun 18, 2015 at 9:43 AM, Emily [email protected] wrote:

In lib/mongo/cluster.rb
#637 (comment)
:

   @servers = []
  •  @servers_update = Mutex.new
    

Thanks for your review.
I'm not going to take this approach because there is IO in a bunch of
places that might not be obvious (like in the instantiation of an Address,
for example) and the code would get messy if I was frequently grabbing and
releasing the lock in between lines of code in Cluster.

I have taken your suggestion to only use one lock for both the servers and
addresses list.

You're also right about having to copy the list. I've added that in as
well.

Thanks again!


Reply to this email directly or view it on GitHub
https://github.com/mongodb/mongo-ruby-driver/pull/637/files#r32730474.

@estolfo estolfo force-pushed the RUBY-932-duplicate-servers branch from d633fae to 3f72d31 Compare June 22, 2015 09:06
estolfo added a commit that referenced this pull request Jun 22, 2015
RUBY-932 Update Server Discovery and Monitoring code and tests
@estolfo estolfo merged commit 721ed56 into mongodb:2.0-stable Jun 22, 2015
@estolfo estolfo deleted the RUBY-932-duplicate-servers branch July 7, 2015 09:54
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