From 3bdd3fdd531d8435205e1d36eda05397254d2fca Mon Sep 17 00:00:00 2001 From: Kyle Banker Date: Tue, 24 Nov 2009 14:04:39 -0500 Subject: [PATCH] Removed some unused methods. --- lib/mongo/connection.rb | 22 +--------------------- test/test_db_api.rb | 8 -------- test/test_slave_connection.rb | 3 ++- 3 files changed, 3 insertions(+), 30 deletions(-) diff --git a/lib/mongo/connection.rb b/lib/mongo/connection.rb index decbcc5..3cfd02f 100644 --- a/lib/mongo/connection.rb +++ b/lib/mongo/connection.rb @@ -288,6 +288,7 @@ module Mongo socket = TCPSocket.new(host, port) socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) + # If we're connected to master, set the @host and @port result = self['admin'].command({:ismaster => 1}, false, false, socket) if result['ok'] == 1 && ((is_master = result['ismaster'] == 1) || @slave_ok) @host, @port = host, port @@ -308,27 +309,6 @@ module Mongo raise ConnectionFailure, "failed to connect to any given host:port" unless socket end - # NOTE: might not need this. - # Are we connected to the master node? - def master? - doc = self['admin'].command(:ismaster => 1) - doc['ok'] == 1 && doc['ismaster'] == 1 - end - - # NOTE: might not need this. - # Returns a string of the form "host:port" that points to the master - # database. Works even if this _is_ the master database. - def master - doc = self['admin'].command(:ismaster => 1) - if doc['ok'] == 1 && doc['ismaster'] == 1 - "#@host:#@port" - elsif doc['remote'] - doc['remote'] - else - raise "Error retrieving master database: #{doc.inspect}" - end - end - # Are we connected to MongoDB? This is determined by checking whether # @host and @port have values, since they're set to nil on calls to #close. def connected? diff --git a/test/test_db_api.rb b/test/test_db_api.rb index f046a97..e3848d1 100644 --- a/test/test_db_api.rb +++ b/test/test_db_api.rb @@ -475,14 +475,6 @@ class DBAPITest < Test::Unit::TestCase end end - def test_ismaster - assert @@conn.master? - end - - def test_master - assert_equal "#{@@conn.host}:#{@@conn.port}", @@conn.master - end - def test_where @@coll.insert('a' => 2) @@coll.insert('a' => 3) diff --git a/test/test_slave_connection.rb b/test/test_slave_connection.rb index 84b9340..bffb4e7 100644 --- a/test/test_slave_connection.rb +++ b/test/test_slave_connection.rb @@ -10,7 +10,8 @@ class SlaveConnectionTest < Test::Unit::TestCase @@host = ENV['MONGO_RUBY_DRIVER_HOST'] || 'localhost' @@port = ENV['MONGO_RUBY_DRIVER_PORT'] || Connection::DEFAULT_PORT conn = Connection.new(@@host, @@port, :slave_ok => true) - !conn.master? + cmd = conn['admin'].command(:ismaster => 1) + cmd['ok'] == 1 && cmd['ismaster'] != 1 end if self.connect_to_slave